I'm creating a small shoot 'em up game for 7210 and have created a Laser class which will is responsible for painting and moving the laser sprite.
Is it best to create a fixed size array of, say 10 Laser, items and kill and revive these as the game is played or is it best to create new instances of the laser class each time the fire button is pressed(i.e. have a vector of Laser objects... no array... that I create new and delete old Laser items from the list as the game is played)?
Basically, is one way faster than the other? I assume there must be some overhead creating the Laser instances as the player hits the fire button? So I thought the fixed array would be faster?
The fixed array is faster. The disadvantage is that you can't have more than 10 shots. In general, you should keep object creation (and object destruction~garbage creation) to a minimum, since creating new objects is expensive and collecting the garbage you're creating is also expensive.