procedure TFormMain.moveEnemies(value: TGameStatus);
var
fieldX, fieldY: Integer;
i,k,j: Integer;
tmpField :
array of TNextField;
begin
SetLength(tmpField,High(EnemyManager.enemys[FPlayerLevel])-1);
for k := 0
to High(EnemyManager.enemys[FPlayerLevel])
do
begin
fieldX := (EnemyManager.enemys[FPlayerLevel][k].Pixels.X )
div 32;
fieldY := (EnemyManager.enemys[FPlayerLevel][k].Pixels.Y )
div 32;
tmpField[k] := map.Playground[fieldX][fieldY].nextField;
end;
for j := 0
to 31
do
begin
for i := 0
to High(EnemyManager.enemys[FPlayerLevel])
do
begin
if EnemyManager.enemys[FPlayerLevel][i].isRunning
then
begin
case tmpField[i]
of
nfDown: EnemyManager.moveEnemy(EnemyManager.enemys[FPlayerLevel][i],nfDown);
nfRight: EnemyManager.moveEnemy(EnemyManager.enemys[FPlayerLevel][i],nfRight);
nfLeft: EnemyManager.moveEnemy(EnemyManager.enemys[FPlayerLevel][i],nfLeft);
nfUp: EnemyManager.moveEnemy(EnemyManager.enemys[FPlayerLevel][i],nfUp);
nfStay:
begin
EnemyManager.enemys[FPlayerLevel][i].isRunning := false;
Dec(FPlayerLives);
initLabels;
if FPlayerLives = 0
then
begin
SetGameStatus(gsGAMEOVER);
exit;
end;
end;
end;
end;
end;
Draw;
end;
end;