How to store a shmup level?
Posted
by
pek
on Game Development
See other posts from Game Development
or by pek
Published on 2011-03-03T17:54:34Z
Indexed on
2011/03/04
7:33 UTC
Read the original article
Hit count: 437
I am developing a 2D shmup (i.e. Aero Fighters) and I was wondering what are the various ways to store a level. Assuming that enemies are defined in their own xml file, how would you define when an enemy spawns in the level?
Would it be based on time? Updates? Distance?
Currently I do this based on "level time" (the amount of time the level is running - pausing doesn't update the time). Here is an example (the serialization was done by XNA):
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:level="pekalicious.xanor.XanorContentShared.content.level">
<Asset Type="level:Level">
<Enemies>
<Enemy>
<EnemyType>data/enemies/smallenemy</EnemyType>
<SpawnTime>PT0S</SpawnTime>
<NumberOfSpawns>60</NumberOfSpawns>
<SpawnOffset>PT0.2S</SpawnOffset>
</Enemy>
<Enemy>
<EnemyType>data/enemies/secondenemy</EnemyType>
<SpawnTime>PT0S</SpawnTime>
<NumberOfSpawns>10</NumberOfSpawns>
<SpawnOffset>PT0.5S</SpawnOffset>
</Enemy>
<Enemy>
<EnemyType>data/enemies/secondenemy</EnemyType>
<SpawnTime>PT20S</SpawnTime>
<NumberOfSpawns>10</NumberOfSpawns>
<SpawnOffset>PT0.5S</SpawnOffset>
</Enemy>
<Enemy>
<EnemyType>data/enemies/boss1</EnemyType>
<SpawnTime>PT30S</SpawnTime>
<NumberOfSpawns>1</NumberOfSpawns>
<SpawnOffset>PT0S</SpawnOffset>
</Enemy>
</Enemies>
</Asset>
</XnaContent>
Each Enemy element is basically a wave of specific enemy types. The type is defined in EnemyType while SpawnTime is the "level time" this wave should appear. NumberOfSpawns and SpawnOffset is the number of enemies that will show up and the time it takes between each spawn respectively.
This could be a good idea or there could be better ones out there. I'm not sure. I would like to see some opinions and ideas.
I have two problems with this: spawning an enemy correctly and creating a level editor. The level editor thing is an entirely different problem (which I will probably post in the future :P).
As for spawning correctly, the problem lies in the fact that I have a variable update time and so I need to make sure I don't miss an enemy spawn because the spawn offset is too small, or because the update took a little more time. I kinda fixed it for the most part, but it seems to me that the problem is with how I store the level.
So, any ideas? Comments?
Thank you in advance.
© Game Development or respective owner