Sign in to follow this  
ryan554

Enemies in Scrolling Space Shooter

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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;
}

Share this post


Link to post
Share on other sites
Hidden
I think the "classic" space shooter spawns mobs in "waves", rather than from pre-defined positions on a map. I don't think those old-school shooters use any kind of map-file/map-array at all. They just have a scrolling background (to make it look like you're flying in space), and when you've cleared a wave of monsters a new one spawns a few seconds later. The good thing with this method is that you can spawn endless waves of monsters without the program taking much memory or diskspace. If you go for a mapfile technique instead, be prepared, 'cause the map will have to be very, veeeeeery long if the level is gonna be interresting. Good luck!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this