Monday, October 02, 2006

Killed by a Bomb and Game Over

Then lets code what happens when the main character is hit by a bomb; and after 3 miss the Game is Over:

// Killed by bomb A
if ((BombAPos=5) and (PosChar=0)) or
((BombAPos=5) and (PosChar=1)) or
((BombAPos=4) and (PosChar=4)) or
((BombAPos=3) and (PosChar=7)) or
// Killed by bomb B
((BombBPos=5) and (PosChar=2)) or
((BombBPos=4) and (PosChar=5)) or
((BombBPos=3) and (PosChar=8)) or
// Killed by bomb C
((BombCPos=5) and (PosChar=3)) or
((BombCPos=4) and (PosChar=6)) or
((BombCPos=3) and (PosChar=9)) or
((BombCPos=2) and (PosChar=10)) then begin
Cntrls:=false;
Blocked:=true;
StopAllTimers;
CicloTimer:=1;
TimerBombMiss.interval:=500;
TimerBombMiss.Enabled:=true;
PlaySound(pfMiss);
end;


And the animated sequence:

case CicloTimer
of 1: begin ArrayMan[PosChar].visible:=(not ArrayMan[PosChar].visible); end;
2: begin ArrayMan[PosChar].visible:=(not ArrayMan[PosChar].visible); end;
3: begin ArrayMan[PosChar].visible:=(not ArrayMan[PosChar].visible); end;
4: begin ArrayMan[PosChar].visible:=(not ArrayMan[PosChar].visible); end;
5: begin TimerBombMiss.Enabled:=false; Life:=Life-1;
// -----------------------------
// Game Over - Level 1
// -----------------------------
case Life // Life indicator display
of 2: begin ImageLife2.visible:=false; end;
1: begin ImageLife3.visible:=false; end;
end;
// Game Over
if Life=0 then begin
Cntrls:=false;
StopAllTimers;
PlaySound(pfEnd);
Select:=0;
bStart:=false;
end;
if Life<>0 then begin SetupGame; TimerLevel1.Enabled:=true; end;
end;
end;
Inc(CicloTimer);

No comments: