Wednesday, October 04, 2006

Killed by the terrorist and Game Over

Here is the code when the terrorist's bullet hits the main character; and after 3 miss the Game is Over:

// Killed by terrorist - Loose a life
if ((PosChar=1) and (BulletATerroristPos=5)) or
((PosChar=2) and (BulletBTerroristPos=5)) or
((PosChar=3) and (BulletCTerroristPos=5)) or
((PosChar=4) and (BulletDTerroristPos=5)) then begin
Cntrls:=false;
Blocked:=true;
StopAllTimers;
CicloTimer:=1;
TimerHeroMiss.interval:=500;
TimerHeroMiss.Enabled:=true;
PlaySound(pfMiss);
end;


And the animated sequence:

case CicloTimer
of 1: begin ArrayHero[PosChar].visible:=(not ArrayHero[PosChar].visible); end;
2: begin ArrayHero[PosChar].visible:=(not ArrayHero[PosChar].visible); end;
3: begin ArrayHero[PosChar].visible:=(not ArrayHero[PosChar].visible); end;
4: begin ArrayHero[PosChar].visible:=(not ArrayHero[PosChar].visible); end;
5: begin TimerHeroMiss.Enabled:=false; Life:=Life-1;
// -----------------------------
// Game Over - Level 2
// -----------------------------
// Life indicator display
case Life
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; TimerLevel2.Enabled:=true; end;
end;
end;
Inc(CicloTimer);

No comments: