Android shooter. Robust enemy patterns for complex group behavior

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)); // new WaveInfo(NumberOfGroups, spawn interval)
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));
// new EnemyGroup(NumberOfEnemies, EnemyType, FlightPathType)
// new EnemyGroup(NumberOfEnemies, EnemyType, FlightPathType, ShipColour)

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; // Stores duration of instruction to be done, the spreadTime, totalFrameTime and enemyIntervalTime
public int shipNumber; // Stores which ship out of group this FlightPath is attached to
public int totalShips; // Stores total number of ships in this EnemyShip group
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

+5
2

FlightPath - . , . . : flightPath.getX(1200) โ†’ X 1200 ?

EnemyShip FlightPath. EnemyShip , .

EnemyGroup EnemyShip. 8 EnemyShips EnemyGroup, FlightPath, , EnemyGroup 500 , .

, EnemyShip world/screen, .

+1

:

  • . currentEnemyArrivalTime += (X - rand(2*X)).

  • . .

  • . (, spline) - . , .

+1

All Articles