Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CoNdOrX

while..loop prevents other fuctions

This topic is 6113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi i''ve tried to develop a very simple game that has a jet(:-> ) and this jet has an abilty to fire.for creating this fire fnction i created fire() and in this funtion i used "while" my code is this: void fire() { firex=x+4; firey=y; // for(firex=x+4;firex>85;firex++) { do { delay(50); gotoxy(firex,firey);printf("."); gotoxy(firex-1,firey);printf(" "); firex++; if(firex==shipx && firey==shipy) { animation(); firex=60; } }while(firex!=82) ; this function launches when you press "p".and do while loop begins.but the prblem occurs here!!!when this do while loop begins,i can not move my jet until this fuctions work finish. what should i do?i tried using for loop but i cant do ...

Share this post


Link to post
Share on other sites
Advertisement
Changing the loop type won''t resolve that. You need to have a ''list of events'' that is kept and is handled every time you go through your ''game loop'' (where you get input, draw, et cetera). When the jet ''fires'' you add a ''firing event'' to this list along with enough information to do whatever needs to be done for it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try making the jets and shots OBJECTS in a list, and program it such that the shot, when animated each tick, has the same behavior as you programmed in your loop.

When you detect the jet firing, create a shot object in your list. The loop that parses the list and makes each object behave should call a function related to the object type (BehaveJet(), BehaveShot()).

Don''t have time to really detail out an algorithm for you, but I hope this gives you some ideas!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!