Wednesday, October 04, 2006

Killing a hostage

Here is the code for when the main character's bullet hits a hostage:

// Kill hostage - Loose 30 points
if ((BulletAHeroPos=3) and (ImageHostage1.visible=true)) or
((BulletBHeroPos=2) and (ImageHostage2.visible=true)) or
((BulletCHeroPos=1) and (ImageHostage3.visible=true)) or
((BulletDHeroPos=2) and (ImageHostage4.visible=true)) then begin
Cntrls:=false;
Blocked:=true;
StopAllTimers;
if ((BulletAHeroPos=3) and (ImageHostage1.visible=true)) then begin HostageRow:=1; end;
if ((BulletBHeroPos=2) and (ImageHostage2.visible=true)) then begin HostageRow:=2; end;
if ((BulletCHeroPos=1) and (ImageHostage3.visible=true)) then begin HostageRow:=3; end;
if ((BulletDHeroPos=2) and (ImageHostage4.visible=true)) then begin HostageRow:=4; end;
CicloTimer:=1;
TimerHostageMiss.interval:=500;
TimerHostageMiss.Enabled:=true;
Score:=Score-30;
PlaySound(pfEvent);
end;


And the animated sequence associated:

case CicloTimer
of 1: begin ArrayHostage[HostageRow].visible:=(not ArrayHostage[HostageRow].visible); Blocked:=false; end;
2: begin case HostageRow
of 1: begin ImageBulletA3.visible:=false; end;
2: begin ImageBulletB2.visible:=false; end;
3: begin ImageBulletC1.visible:=false; end;
4: begin ImageBulletD2.visible:=false; end;
end;
SetupHero;
TimerHostageMiss.Enabled:=false;
TimerLevel2.Enabled:=true;
end;
end;
Inc(CicloTimer);

No comments: