🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Cloning objects on the fly?

Started by
1 comment, last by Sheep 22 years, 10 months ago
Hello everyone. Well, once again I have encountered a problem. I am creating a small subhunt clone, and I am having trouble with firing multiple depth charges, namely that I don''t know to make them work. So far, the part of the main game loop that relates to this ship looks something like this: if(Spacebar is down) // fire the torpedo { // set position of the depth charge to that of the ship Set_Position (ship_pos_x and ship_pos_y); // set the downward velocity velocity = 4; } if (Space was pressed) { Draw_Depth_Charge (); } With the code like this, I can only fire one depth charge. How could I make it so that if space has been pressed more than once, It will draw another depth charge? I know the answer is probably rather simple, but I am rather high on jellybeans, and my brain is not functioning correctly. Thanks, your "wannabe" friend.
Advertisement
You might do something like this:

  struct weapon { float x, y, z;                BOOL  active; // note set all active to FALSE              } depth_charge [ 25 ];int dch_count = 0;// a globalif ( Space Bar is Down )   {     Set_Position( ship_position_x ,ship_position_y );     // of depth_charge [ dch_count ].x,     //    depth_charge [ dch_count ].y       velocity = 4;     depth_charge [ dch_cnt ].active = TRUE;     if ( dch_count++ > 24 )               dch_count = 24;   }// end ifIf ( Space was pressed ){  // loop through the active depth charges drawing the  // active ones  for ( int count = 0 ; count < 25 ; count++ )      {        if ( depth_charge [ count ].active == TRUE )             Draw_Depth_Charge( depth_charge [ count ].x,                                depth_charge [ count ].y );      }// end for count}// end for Space  
Adulthood is the vehicle for making you childhood dreams come true.
I sent you an E-MAIL, not sure if you got it.

It went:

Sorry to hear it did''nt work for you.
I can''t do much without seeing the code.
I assume you where adjusting the view matrix for
each missle drawn. But I don''t know how your code
was laid out ? I used similar code for multiple pixel
explosion algorithms.

Can you E-MAIL it me ?

guyjohnston@kawartha.com
Adulthood is the vehicle for making you childhood dreams come true.

This topic is closed to new replies.

Advertisement