Enemies in Scrolling Space Shooter
I am relativly new to game programming, I have started several projects but somehow I never finish them. I am hoping to finish the vertical scrolling shooter I am working on. I am not sure how I should deal with the enemies.
Should I draw them randomly?
Store them in an array the size of my map?
Or is there another, better way?
Thanx in advance.
Well, what I did for my game (wasn't a side-scroller, but same principle should still work), is I had an array of a monster class, and the monster class itself held the X and Y coords of the monster, along with other stuff.
Well, what I did for my game (wasn't a side-scroller, but same principle should still work), is I had an array of a monster class, and the monster class itself held the X and Y coords of the monster, along with other stuff.
i would go with Eddy there, except a linkedlist is probably a better option (since its easier to add/remove enemies)
Hi,
I did a side scrolling before, what I did :
As said you hold a link list of the monster. It is more a queue. You have an active list of active ennemy. When it goes out (bottom) you simply delete it.
And, you know what is the next monster in the queue to popup at the top. You just compare :
if (firstInQueue->Y < levelPosition)
Then, you pop this element from the queue and put it in the active list, and check the next one in the list each time.
I did a side scrolling before, what I did :
As said you hold a link list of the monster. It is more a queue. You have an active list of active ennemy. When it goes out (bottom) you simply delete it.
And, you know what is the next monster in the queue to popup at the top. You just compare :
if (firstInQueue->Y < levelPosition)
Then, you pop this element from the queue and put it in the active list, and check the next one in the list each time.
I made a horizontal side scroller,but you can use the same idea here. What i did was on my map file, set coordinates of where the enemies would appear, and how many. Then I would save those coordinates in an array. Then whenever i would move forward, just check to see if i hit an spot where enemies should appear. If so, make them do their thing :P.
Quote:Original post by tont
I made a horizontal side scroller,but you can use the same idea here. What i did was on my map file, set coordinates of where the enemies would appear, and how many. Then I would save those coordinates in an array. Then whenever i would move forward, just check to see if i hit an spot where enemies should appear. If so, make them do their thing :P.
hmmm kind off like hotspots.... I like that idea.
Quote:Original post by tont
I made a horizontal side scroller,but you can use the same idea here. What i did was on my map file, set coordinates of where the enemies would appear, and how many. Then I would save those coordinates in an array. Then whenever i would move forward, just check to see if i hit an spot where enemies should appear. If so, make them do their thing :P.
I would expand that a little and have a distance travelled before each new wave of enemies appeared. You would define each wave using things such as number of enemies, formations, movement paths and AI behaviours.
e.g.
class EnemyWave
{
explicit EnemyWave( ... )
{
...
}
private:
int m_startPosition;
int m_numShips;
Formation m_formation;
MovementPath m_movement;
AIBehaviour m_AI;
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement