Pages

Monday, October 02, 2006

Terrorist throwing Bombs

Then let's code the vehicles movements routine and a random event routine when those vehicles happen to appear.

Here is the code for the terrorist and bombs' movements:

// Movement - bomb A
case BombAPos
of 6: begin BombAPos:=0; ImageBombA4.Visible:=false; end;
5: begin BombAPos:=6; ImageBombA3.Visible:=false; PlaySound(pfEvent); ImageBombA4.Visible:=true; end;
4: begin BombAPos:=5; ImageBombA2.Visible:=false; ImageBombA3.Visible:=true; end;
3: begin BombAPos:=4; ImageBombA1.Visible:=false; ImageBombA2.Visible:=true; end;
2: begin BombAPos:=3; ImageBomberA.Visible:=false; ImageBombA1.Visible:=true; end;
1: begin BombAPos:=2; ImageBomberA.Visible:=true; end;
end;
// Movement - bomb B
case BombBPos
of 6: begin BombBPos:=0; ImageBombB4.Visible:=false; end;
5: begin BombBPos:=6; ImageBombB3.Visible:=false; PlaySound(pfEvent); ImageBombB4.Visible:=true; end;
4: begin BombBPos:=5; ImageBombB2.Visible:=false; ImageBombB3.Visible:=true; end;
3: begin BombBPos:=4; ImageBombB1.Visible:=false; ImageBombB2.Visible:=true; end;
2: begin BombBPos:=3; ImageBomberB.Visible:=false; ImageBombB1.Visible:=true; end;
1: begin BombBPos:=2; ImageBomberB.Visible:=true; end;
end;
// Movement - bomb C
case BombCPos
of 6: begin BombCPos:=0; ImageBombC4.Visible:=false; end;
5: begin BombCPos:=6; ImageBombC3.Visible:=false; PlaySound(pfEvent); ImageBombC4.Visible:=true; end;
4: begin BombCPos:=5; ImageBombC2.Visible:=false; ImageBombC3.Visible:=true; end;
3: begin BombCPos:=4; ImageBombC1.Visible:=false; ImageBombC2.Visible:=true; end;
2: begin BombCPos:=3; ImageBomberC.Visible:=false; ImageBombC1.Visible:=true; end;
1: begin BombCPos:=2; ImageBomberC.Visible:=true; end;
end;


And here is the random events:
// Event - Bombs appear
if RdmEvent=3 then begin // Event - Bomb A
if BombAPos=0 then begin BombAPos:=1; end;
end;
if RdmEvent=4 then begin // Event - Bomb B
if BombBPos=0 then begin BombBPos:=1; end;
end;
if RdmEvent=5 then begin // Event- Bomb C
if BombCPos=0 then begin BombCPos:=1; end;
end;


No comments:

Post a Comment