Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with Tony's Oval Collision.
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
recneps




PostPosted: Wed Jan 28, 2004 6:46 pm   Post subject: Help with Tony's Oval Collision.

Help with Tony's Oval Collision please! I'm going to include a racing game in my FP (a real crappy one, but its better than my High/Low game ;p)
Anyways, i got the car movement down, and i tried tony's oval collison so that it would stop at the oval (well move back 10 spots) but its not working... anyone help me? Very Happy (Credit will be shown on the FP submission Smile)



racing.zip
 Description:
My Crappy Racing Game! Yay!

Download
 Filename:  racing.zip
 Filesize:  1.5 KB
 Downloaded:  158 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
poly




PostPosted: Wed Jan 28, 2004 6:49 pm   Post subject: (No subject)

so when the car hits the oval, it gets sent flying back 10 spots?
- try using View.Update so there is no blinking
recneps




PostPosted: Wed Jan 28, 2004 6:52 pm   Post subject: (No subject)

I have view.update in there... im thinking i put one in the procedure, but not the loop Smile (too lazy to check right now) and yeah, i have it move back 10 pixels, just cause i dont know how far forward its going Very Happy (because of the two lines i borrowed, because i dont know sine and cosine yet)
santabruzer




PostPosted: Wed Jan 28, 2004 6:57 pm   Post subject: (No subject)

dont' forgot to put the screen mode before the procedure, or the other way around example :

code:
setscreen ("graphics,offscreenonly")


instead of
code:
setscreen ("graphics:offscreenonly")


Reduces Flicker
McKenzie




PostPosted: Wed Jan 28, 2004 7:04 pm   Post subject: (No subject)

Distance formula is wrong. (no need for credit)
Cervantes




PostPosted: Thu Jan 29, 2004 8:30 am   Post subject: (No subject)

If you're using turing 4.0.5 you can just use Math.Distance (x1, y1, x2, y2)

cheers
shorthair




PostPosted: Thu Jan 29, 2004 8:55 am   Post subject: (No subject)

im not to sure how exactly t ochange this , but i am aware that you can have a much better turning and drving game , so that you can drive while your turning , that would be really cool
Delta




PostPosted: Thu Jan 29, 2004 9:11 am   Post subject: (No subject)

you should have the turning do like a little arc (sin or cos type deal) so the car doesn't just go up,down,left,right... as for the turning a moving at the same time use Key.Down ... ummm ya... have fuN!
Sponsor
Sponsor
Sponsor
sponsor
McKenzie




PostPosted: Thu Jan 29, 2004 9:57 am   Post subject: (No subject)

basically you want to see the velocity of the car as a vector (magnitude (speed) and direction (angle that you already have)). Just break this vector into it's x any components and that is how much to add on when it moves. Here is a simple vector example to get you on your way.


vectors.t
 Description:

Download
 Filename:  vectors.t
 Filesize:  894 Bytes
 Downloaded:  210 Time(s)

Delta




PostPosted: Thu Jan 29, 2004 11:45 am   Post subject: (No subject)

wow... mckenzie you should make a yo yo game with that code... it'd be super kewl.. like wow... now if you don't (i think you should Smile ) then I'm going to later on ... after the pic2code program Smile
Cervantes




PostPosted: Fri Jan 30, 2004 9:30 am   Post subject: (No subject)

wow I like that program McKenzie.... yeeees.. like it I do...

a yoyo program, that is original!! but it would only be cool if you could do all sorts of cool tricks... but the tricks would have to actually be done, not by hitting a certain button comination and then it does the trick (like what you have in mortal combat or games like those)

Cheers
recneps




PostPosted: Fri Jan 30, 2004 6:44 pm   Post subject: (No subject)

ok, i got it to stop at the edge of the circle, but how can i get it to move out of it?


code:
const maxframerate : int := 30
const numframes : int := 18
var keys : array char of boolean
const up : char := chr (200)
const left : char := chr (203)
const right : char := chr (205)
const esc : char := chr (27)
const carrad : int := 19
var car : array 0 .. (numframes - 1) of int
var angle : int
var x, y, dx, dy : real

var midx : int := maxx div 2
var midy : int := maxy div 2
var radius : int := maxx div 5
procedure drawscreen

    delay (10)
    cls
    %draw the center Ring
    drawoval (midx, midy, radius, radius, 0)
    %draw the car with the appropriate angle.
    Pic.Draw (car (angle),
        round (x) - carrad,
        round (y) - carrad, picMerge)

    View.Update
end drawscreen

setscreen ("graphics:nooffscreenonly")
car (0) := Pic.FileNew ("crappycar.bmp")
Pic.SetTransparentColour (car (0), black)
for i : 1 .. (numframes - 1) %make all frames of the ship.(-1 because the 0 is already set.)
    car (i) := Pic.Rotate (car (0), i * (360 div numframes), carrad, carrad)
end for
angle := 0
x := midx - radius - 10
y := midy
dx := 0
dy := 0

colourback (black)
loop %get key info
   
    Input.KeyDown (keys)
    if keys (up) then
        dx -= sind (angle * 20) %This and next line only two lines that arent mine :(
        dy += cosd (angle * 20) %^^^^^^^^
    end if
    if keys (right) then %rotate if right
        angle := (angle - 1) mod numframes
        delay (50)
    end if
    if keys (left) then %rotate if left
        angle := (angle + 1) mod numframes
        delay (50)
    end if
    if keys (esc) then %exit when hit esc
        exit
    end if
    dx := min (max (dx, -20), 20) %Set "speed limit"
    dy := min (max (dy, -20), 20)
   
    if x > maxx then
        x := maxx %keep car in bounds for x
    end if
    if x < 0 then
        x := 0
    end if
    if y > maxy then
        y := maxy %keep car in bounds for y
    end if
    if y < 0 then
        y := 0
    end if
 if Math.Distance (x, y, midx, midy) < radius then
        dx:=0
        dy:=0
    end if
    x += dx
    y += dy
    drawscreen
    dx := 0
    dy := 0
end loop
McKenzie




PostPosted: Sat Jan 31, 2004 12:50 am   Post subject: (No subject)

Prevention is the key (see code)


race.t
 Description:

Download
 Filename:  race.t
 Filesize:  2.07 KB
 Downloaded:  151 Time(s)

Andy




PostPosted: Sat Jan 31, 2004 3:35 pm   Post subject: (No subject)

turing now has a built in function to check the distance between two points
Cervantes




PostPosted: Sat Jan 31, 2004 3:43 pm   Post subject: (No subject)

called Math.Distance
*points to 6th post from top*
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: