Advertisement

Cloning objects on the fly?

Started by August 26, 2001 09:31 AM
1 comment, last by Sheep 23 years, 3 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.
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.
Advertisement
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