How to use Vectors for a game
Ok so i'm making a frogger game, and for the enemies i would like to put them into vectors as currently the way i do it at the moment is rather clunky (code follows)
My enemies need to have:
- A X and Y Pos, the Y pos will stay the same for each 'set' of enemies, but the X pos needs to change for each one
- A X velocity
I'm just not sure how to put all this into a vector the main thing that's confusing me is the X position how i can have it change each time a new item is put into the vector.
Of course the code is put in the correct sections of my game.cpp:
e1.setPosX(e1.getPosX() + elapsedTime * e1.getVelX());
if (e1.getPosX() < -55) //wrap function for the x axis
define a class. then vector<your_class>
Topic archived. No new replies allowed.