• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Cloning objects on the fly?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1Sheep  Members

Posted 26 August 2001 - 03:31 AM

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.

### #2GuyJohnston  Members

Posted 26 August 2001 - 06:53 AM

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

### #3GuyJohnston  Members

Posted 26 August 2001 - 11:40 AM

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.