Hello Haz
I don't use C++, but concerning to your game's logic, i tell you what i generally do (you can see it in my poor Sonic game)
You have a group of enemies (or entities); i suggest Enemy (or Entity) should be a class of objects; then EntityGroup should be another class. In the 1st you could define everything related to the Enemies: moves, collisions, attacks, explosions, and so; but you define that just once in the class code. In the 2nd, you could define how many Enemy objects there are, and make it draw (and execute their logic) all the Enemies in the EnemyGroup that are Alive.
the following is in C#, i don't know C++, please could some member translate for Haz? (Thanks)
class Enemy
{ private int x, y, sense, life
; public Enemy
(int x,
int y
) {this.x = x
; this.y = y
; this.sense = 1; this.life = 1; } private void Movement
() { this.x = this.x + 4 * this.sense; \\ or
this.x += 4 * this.sense; if (this.x >= screenWidth
|| this.x <= 0) this.sense = -this.sense; \\ or
this.sense *= -1; change the sense right
/left when reachs the borders
if (this.y < screenHeight
/ 2) this.y = this.y + 2; \\ or
this.y += 2; suppose the Enemy goes forward up to the middle of the screen
\\ maybe then, they could go backwards to the screen top
} public Boolean IsAlive
() { if (this.life > 0) return true; return false; } private void Attack
() { \\
throw bullets, each a randomized number of seconds
} private void TestDestroyed
() { \\ see
if some bullet hit the Enemy
} public void Draw
() { this.Movement(); \\
add Attack and
/or Being Destroyed stuff here
\\ AND draw the Sprite
}}class EnemyGroup
{ private Enemy
[] vector
; public EnemyGroup
(int numberOfEnemies
) { this.vector = new Enemy
[numberOfEnemies
]; for (int a
= 0; a
< numberOfEnemies
; a
++) this.vector[a
] = new Enemy
((a
* 40) % screenWidth,
(a
* 40) / screenWidth
); \\
set the Enemies together spaced
by 40 px
(to be changed
),
from one
's to another's begginig,
\\ and
continue in the following line when reach the right screen border
} public DrawAllEnemies
() { for (int a
= 0; a
< this.vector.Length; a
++) if (this.vector[a
].IsAlive()) this.vector[a
].Draw(); }} Also you can write the player's class' code but that you move and shoot by the keyboard
Hope this helps.
Pablo