I am working on an arcade shooter game for Android similar to Ikaruga. The problem I am facing is that it is quite difficult to create moving and firing patterns for enemies. At the moment, I have created two abstract classes EnemyShip and FlightPath, of which each individual enemy and movement pattern are received respectively. When the world creates an instance of LevelManager, which stores level information in the form:
waveInfos.add(new WaveInfo(3, 3f));
enemyGroups.add(new EnemyGroup(8, EnemyGroup.TYPE_SCOUT_SHIP, EnemyGroup.F_PATH_INVADERS));
enemyGroups.add(new EnemyGroup(1, EnemyGroup.TYPE_QUAD_SPHERE, EnemyGroup.F_PATH_QUAD_SPHERE_L, World.BLACK));
enemyGroups.add(new EnemyGroup(8, EnemyGroup.TYPE_SCOUT_SHIP, EnemyGroup.F_PATH_INVADERS));
waveInfos.add(new WaveInfo(2, 0.33f));
enemyGroups.add(new EnemyGroup(1, EnemyGroup.TYPE_QUAD_SPHERE, EnemyGroup.F_PATH_QUAD_SPHERE_L, World.WHITE));
enemyGroups.add(new EnemyGroup(1, EnemyGroup.TYPE_QUAD_SPHERE, EnemyGroup.F_PATH_QUAD_SPHERE_R, World.WHITE));
totalWaves = waveInfos.size();
Levels are divided into waves of groups of enemies, and now the EnemyGroup class handles the creation of an instance by adding the specified FlightPath to the newly created enemy and transferring this enemy to ArrayList in the LevelManager for storage until it appears in the world on time.
, FlightPath , stateTime, FlightPath EnemyShip, , .
EnemyShip , moveTo (float x, float y, ) shoot(), FlightPath , , .
FlightPath :
public int currentKeyFrame = 0;
public int totalKeyFrames;
public KeyFrame[] keyFrames;
public int shipNumber;
public int totalShips;
public float stateTime = 0;
KeyFrame.spreadTime - , / .
KeyFrame.totalFrameTime = KeyFrame.duration + KeyFrame.spreadTime
KeyFrame.enemyIntervalTime = KeyFrame.spreadTime/
, .
, . , , if(), , ..
, , , . , . , .
EDIT: , , , , ,
http://www.yaldex.com/games-programming/0672323699_ch12lev1sec3.html