I've gotten past the collision detection part of coding my shmup's engine, and am stuck at designing my level editor. I spent some time searching through the forums but again, results weren't what I expected so I opened a new thread instead.
How do level editors normally work? I'm not sure what exactly is the elegant way of designing it, but here was my attempt:
- The camera has a global trigger
- The background is a long vertical map, filled with "enemy wave triggers"
- The background scrolls down slowly, giving the feel that the "players are flying forward"
- When a wave trigger touches the global trigger, the appropriate enemy wave/pattern is generated
I'm satisfied with this approach of "making enemy waves appear" at the exact time I want, as long as I adjust the position of the wave triggers.
Here comes my problem:
How are enemy waves designed? I could think of adding enemy "actions" to a list, which would execute in sequential order, like this:
Code: Select all
// pseudocode
// 1) The code below is attached to every enemy object
// 2) The enemy trigger objects will call the Start() of every enemy object
// 3) Every Update() will trigger each enemy object's Update() to execute their actions accordingly
GameActionList _actionList = new GameActionList();
bool isBusy = false;
void Start(){
_actionList.add("enemy1", "moveTo", position, moveSpeed, duration);
_actionList.add("enemy1", "pause", duration);
_actionList.add("enemy1", "moveTo", position, moveSpeed, duration);
// ... and so on ...
}
void Update(){
if (_actionList.length > 0){
if (isBusy == false){
ExecuteNewAction( _actionList[0] );
_actionList.removeAt(0);
isBusy = true;
}
else{
ContinueAction(); // when the action is complete, will set isBusy = false
}
}
else{
destroyThis();
}
}
- at time 0:00, move somewhere for 5 seconds
- at time 0:02, shoot at player
- at time 0:05, move somewhere
- at time 0:05, shoot at player again
Does anyone have any ideas on how enemy movement and bullet sequences are designed? I appreciate the response, and thank you in advance!