motorollin
Member
- Joined
- Jul 31, 2007
- Messages
- 163
I have created an Enemy class. I want lots of enemies on screen, so I have created an array of enemies:
CODE
Enemy myEnemy[5];
In my main loop I have lines like the following to make all of the enemies do their processing:
CODE
for ( int i = 0; i <= 4; i++ ) if ( myEnemy.alive == true ) myEnemy.move();
This works. However, I want to be able to add enemies as and when I want to, and then change the for loops to check the size of the array. In the Lazy Foo tutorials I have seen the array.size() function which returns the current size of the array, and the array.resize() function which resizes it. However my Enemy class doesn't recognise these functions. How can I achieve this?
TIA
CODE
Enemy myEnemy[5];
In my main loop I have lines like the following to make all of the enemies do their processing:
CODE
for ( int i = 0; i <= 4; i++ ) if ( myEnemy.alive == true ) myEnemy.move();
This works. However, I want to be able to add enemies as and when I want to, and then change the for loops to check the size of the array. In the Lazy Foo tutorials I have seen the array.size() function which returns the current size of the array, and the array.resize() function which resizes it. However my Enemy class doesn't recognise these functions. How can I achieve this?
TIA