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

Username:   Password: 
 RegisterRegister   
 Shooting problems
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ssr




PostPosted: Fri Jan 07, 2005 10:52 pm   Post subject: Shooting problems

Ok Im kinda new at turing and now I need to make a game like shooting from an airplane
However, whenever I press the 'y' which is the shooting button, the bullet would shoot out and the plane wouldn't move until its finished, is there anyway to solve this? Thank you! Question Exclamation



Turing Airplane.rar
 Description:

Download
 Filename:  Turing Airplane.rar
 Filesize:  7.57 KB
 Downloaded:  115 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Neo




PostPosted: Fri Jan 07, 2005 11:01 pm   Post subject: (No subject)

Take your shooting procedure out of that for loop and use the main loop instead. Also you should do something about those delays. If you structure your code correctly you should really only need 1 at the end.
Cervantes




PostPosted: Sat Jan 08, 2005 10:39 am   Post subject: (No subject)

Neo is right: so long as you use a for loop inside your main loop like that, you can't move the plane at the same time as the missle is moving.
When Neo says:
Neo wrote:

Take your shooting procedure out of that for loop and use the main loop instead.

He means to eliminate the for loop that we're talking about and put the missle movement code directly into the main loop, so that it can run simotaneously with your plane movement. How to do that is a little bit tricky, however. What you'l probably want to do is store information about your missle in terms of: x, y, and x_velocity. Then, in your main loop, add x_velocity (you can just call it vx) to the x position of the missle. And then draw the missle at (x,y).
Now there's another problem, though. Since everything is working simotaneously, you can probably just hold down 'y' and fire a bunch of missles at once. Well, you can either make it so that a new missle is only created if 'y' is pressed and if the old missle has reached the end of the screen. Or, you could make a Flexible Array to store a bunch of information about several different missles. This will be tricky, mid you. If you don't know Arrays yet, I suggest you learn them before flexible arrays. records would also be useful to know.

Best of luck!
-Cervantes
ssr




PostPosted: Tue Feb 01, 2005 6:19 pm   Post subject: (No subject)

Thanks, that helped me alot Very Happy
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  [ 4 Posts ]
Jump to:   


Style:  
Search: