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

Username:   Password: 
 RegisterRegister   
 I need help with a drag racing game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dark_knight_97




PostPosted: Thu Sep 19, 2002 2:55 pm   Post subject: 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.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Sep 19, 2002 3:57 pm   Post subject: (No subject)

Welcome to the SWAT, enjoy your stay. Very Happy

Now then, to move the sprite you just need to change its X and Y coordinates
code:
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.

code:
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:
code:
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.1[p] has a Pic.Rotate feature, but unfortunatly it doesn't support sprites. So its ether sprites or rotating regulat bmp/jpeg images.

What you can do now is to draw another image of the wheel in different position and change sprites when you want to rotate the wheel.

code:
Sprite.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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
dark_knight_97




PostPosted: Thu Sep 19, 2002 5:52 pm   Post subject: Thanks for the help Tony

Just saying thanks for the help u guys.. i'll probly be back with more questions. Thanks!
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 1  [ 3 Posts ]
Jump to:   


Style:  
Search: