
-----------------------------------
dark_knight_97
Thu Sep 19, 2002 2:55 pm

I need help with a drag racing game
-----------------------------------
Tony sent me here from the turing tutor site. Heres the deal, i need to know how to make my sprites move across the screen which i have done, now i need to make my rpm gauge, speed and anything else i want to have, move at the same time, but at different ratios. At the same time as that i need my car to move,(btw this is a sideveiw race if that helps any). I also need the wheels which are detached sprites from the car to move and spin at the same and different ratios. I also need to figure out if i am reving the engin how to make it come back down. Any fixes to these problems would be great thanks.

-----------------------------------
Tony
Thu Sep 19, 2002 3:57 pm


-----------------------------------
Welcome to the SWAT, enjoy your stay.  :D 

Now then, to move the sprite you just need to change its X and Y coordinates
Sprite.SetPosition (spriteID, x, y : int, centered : boolean)

The good thing about sprites is that you don't have to redraw them and they don't flash like Pic.Draw

Now about moving things at same time. There are 2 ways to do so:

process
fork allows to run 2 or more procedures at the very same time, but the drawback is that the order of execution of procedures is unpredictable. They tend to run about evenly, but sertain procedures might get ahead of others, especially if theres more then 2 running.

var car1, car2:int
car1 := 0
car2 := 0

process move1
loop
car1 := car1 + 1
locate(1,1)
put "car 1 : ", car1
end loop
end move1

process move2
loop
car2 := car2 + 1
locate(2,1)
put "car 2 : ", car2
end loop
end move2

fork move1
fork move2


Code above would show how processes work. At sertain points 1 car was ahead of the other by over 5 points, so you should keep that in mind.

Note: fork processName is used to call the process and execute it as same time as other code.


Second way - loops with ratio multiplier
Basically what this does is that you run your loops with single counter, but for each value you need to change, you change it by the counter multiplied by the specific ratio of that object to the counter. For example:
for i:1..25
locate(1,1)
put "object 1 :", i*2
put "object 2 :", i*3
delay(100)
end for

About spinning wheels - winoot 4.0.1Sprite.Animate (spriteID, picID, x, y : int,
centered : boolean)

Where spriteID is the variable. picID is the id of the new picture it want your image change to. X and Y are new coordinates and cenetered is ether true or false.

I hope this helped you out. If you got any future questions, let us know.

-----------------------------------
dark_knight_97
Thu Sep 19, 2002 5:52 pm

Thanks for the help Tony
-----------------------------------
Just saying thanks for the help u guys.. i'll probly be back with more questions. Thanks!
