Archived

This topic is now archived and is closed to further replies.

2D Space Shooter Map Structure

This topic is 5376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lo All, I''m trying to figure out the best way to structure a map for a 2d space shooter, I haven''t yet decided whether I''m going to use a tilemap, starfield, or just a scrolling BMP background. My main problem is how to put the enemies on the map, like when should certain enemies attack/appear/disappear. I was thinking of a couple of ways to do it, like: 1. Random spawning enemies of certain types. 2. Enemies spawning after a length of time, or at specific time intervals. 3. Enemies spawn at certain points on the map. Then there is the problem of putting all this in the map file. Any ideas of how this should be done? Thanks... Coin

Share this post


Link to post
Share on other sites
You could have an abstract class Spawn and have the classes:

RandomSpawn
TimeSpawn
PointSpawn all implement the virtual method spawn.

RandomSpawn would just pick a random point on the map and create a new enemy there. Time spawn would do the same perhaps at a random location, but at timed intervals, and point spawn would just spawn enemies at certain points. THe more I think i about it I would just have one Spawn class that has a more robust spawn method that could account for random placement, any sort of timing types of enemies, etc.

THen in the map file you just have a section:
SPAWNING_BEGIN
spawn time 1 x 50 y 50 enemy random
spawn x 75 y 75 enemy "your_enemy_type_here"
spawn x random y random enemy . . .
SPAWNING_END

then you just parse these into the appropriate data structure. thats how i would do it off the top of my head. This would make it really easy to get a level up and running and to tweak the behavior of levels.

[edited by - mstein on March 26, 2003 1:25:56 PM]

Share this post


Link to post
Share on other sites
I think the best way to go about this is to use timer.
Each timer contains a Time(of spawn), a Type(of ship) and a Position(out of screen).

When the current time is greater or equal to it spawn a Type ship at that Position and start updating it. A sorted timer list would be best.

Share this post


Link to post
Share on other sites
A while ago I tried my hand at the ol'' side scrolling space shooter... in VB no less.
I played with a few different ways of storing enemy positions and the timed method ended up being the easiest way. The background was just a tiled scrolling bitmap(s) and levels were simply described in text files as :
...
[WAVES]
---------------------------------
-- Format :
-- Wave#, Path, StartDelay
-- StaggerTime, NMEType, Speed
---------------------------------
#1, 9, 2
0, Bubble, 10
0.5, Bubble, 10
1, Bubble, 10

#2, 2, 4
0, Bubble, 8
0.6, Bubble, 8
1.2, Bubble, 8
1.8, Bubble, 8
2.4, Saucer, 6
0, Saucer, 6
...

The path is just an index to a game dependant array which contains different way-points for the enemies to follow. A wave is a group of enemies that follow the same path. The rest of the definitions speak for themselves. This was written just for the enemy spawning, but would also be easily extended so you could spawn background features, etc.
Just my experiences.
Crow.

Share this post


Link to post
Share on other sites