Chắc suất Đại học top - Giữ chỗ ngay!! ĐĂNG BÀI NGAY để cùng trao đổi với các thành viên siêu nhiệt tình & dễ thương trên diễn đàn.
Program CarGame;
Uses Crt;
Const
U = #72;
D = #80;
R = #77;
L = #75;
Space = #32;
Type
rCar = Record
Army: Record
x,y: Byte;
End;
Enemy: Record
x,y: Byte;
End;
End;
TCar = Object
Procedure DrawArmyCar(x,y: Byte);
Procedure RemoveArmyCar(x,y: Byte);
Procedure MainController;
Procedure SecondaryController;
Procedure ArmyCarMoveRight;
Procedure ArmyCarMoveLeft;
Procedure ArmyCarMoveUp;
Procedure ArmyCarMoveDown;
Procedure ArmyCarShootingTheBullet;
Procedure DrawEnemyBossCar(x,y: Byte);
Procedure RemoveEnemyBossCar(x,y: Byte);
Procedure EnemyBossCarMoving;
Procedure EnemyBossCarShooting;
Procedure Case1Shooting;
Procedure Case2Shooting;
Procedure Case3Shooting;
Procedure BossDestroyed;
Procedure BossScanning;
End;
TGame = Object
Procedure TheMapOfGame;
Function CheckLose1: Boolean;
Function CheckLose2: Boolean;
Function CheckHitTheBoss: Boolean;
Function CheckWin: Boolean;
Procedure BulletAvailable;
Procedure BulletUnavailable;
Procedure Interfaces;
Procedure TheArrowMovingDown;
Procedure TheArrowMovingUp;
Procedure Instruction;
Procedure ScenceOfGame;
Procedure ScenceOfArmyTank;
Procedure PlayingTheGame;
Procedure Lose;
Procedure Win;
Procedure Start;
End;
TBullet = Record
Army: Record
x,y: Byte;
End;
Enemy: Array[1..3] Of Record
x,y: Byte;
End;
End;
Var
PCar: rCar;
Car: TCar;
Bullet: TBullet;
i,Moving,RandomBullet,TypeBullet,ShootingBullet,delays,
Heart,m,n,Func,Time,j,Messages1,Messages2,TimeMessages1,
TimeMessages2,TimeMessage3,k,TimeScence: Integer;
SavedKey,Key,GetInput: Char;
Game: TGame;
Boss: Boolean;
Arrow: Record
x,y: Byte;
End;
Function TGame.CheckLose1: Boolean;
Begin
If (((Bullet.Enemy[1].x <= PCar.Army.x+4) And (Bullet.Enemy[1].x >= PCar.Army.x)) And (Bullet.Enemy[1].y = PCar.Army.y)) Or
(((Bullet.Enemy[1].x <= PCar.Army.x+3) And (Bullet.Enemy[1].x >= PCar.Army.x+1)) And (Bullet.Enemy[1].y = PCar.Army.y-1)) Or
(((Bullet.Enemy[1].x <= PCar.Army.x+3) And (Bullet.Enemy[1].x >= PCar.Army.x+1)) And (Bullet.Enemy[1].y = PCar.Army.y+1)) Or
(((Bullet.Enemy[2].x <= PCar.Army.x+4) And (Bullet.Enemy[2].x >= PCar.Army.x)) And (Bullet.Enemy[2].y = PCar.Army.y)) Or
(((Bullet.Enemy[2].x <= PCar.Army.x+3) And (Bullet.Enemy[2].x >= PCar.Army.x+1)) And (Bullet.Enemy[2].y = PCar.Army.y-1)) Or
(((Bullet.Enemy[2].x <= PCar.Army.x+3) And (Bullet.Enemy[2].x >= PCar.Army.x+1)) And (Bullet.Enemy[2].y = PCar.Army.y+1)) Or
(((Bullet.Enemy[3].x <= PCar.Army.x+4) And (Bullet.Enemy[3].x >= PCar.Army.x)) And (Bullet.Enemy[3].y = PCar.Army.y)) Or
(((Bullet.Enemy[3].x <= PCar.Army.x+3) And (Bullet.Enemy[3].x >= PCar.Army.x+1)) And (Bullet.Enemy[3].y = PCar.Army.y-1)) Or
(((Bullet.Enemy[3].x <= PCar.Army.x+3) And (Bullet.Enemy[3].x >= PCar.Army.x+1)) And (Bullet.Enemy[3].y = PCar.Army.y+1)) Then
CheckLose1 := True
Else CheckLose1 := False;
End;
Function TGame.CheckLose2: Boolean;
Begin
If (((PCar.Enemy.x-4 <= PCar.Army.x+4) And (PCar.Enemy.x-4 >= PCar.Army.x)) And ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = PCar.Army.y-1) Or (PCar.Enemy.y = PCar.Army.y+1))) Or
(((PCar.Enemy.x-2 <= PCar.Army.x+4) And (PCar.Enemy.x-2 >= PCar.Army.x)) And ((PCar.Enemy.y+1 = PCar.Army.y) Or (PCar.Enemy.y+1 = PCar.Army.y-1) Or (PCar.Enemy.y+1 = PCar.Army.y+1))) Or
(((PCar.Enemy.x-2 <= PCar.Army.x+4) And (PCar.Enemy.x-2 >= PCar.Army.x)) And ((PCar.Enemy.y-1 = PCar.Army.y) Or (PCar.Enemy.y-1 = PCar.Army.y-1) Or (PCar.Enemy.y-1 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+1 <= PCar.Army.x+4) And (PCar.Enemy.x+1 >= PCar.Army.x)) And ((PCar.Enemy.y+2 = PCar.Army.y) Or (PCar.Enemy.y+2 = PCar.Army.y-1) Or (PCar.Enemy.y+2 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+1 <= PCar.Army.x+4) And (PCar.Enemy.x+1 >= PCar.Army.x)) And ((PCar.Enemy.y-2 = PCar.Army.y) Or (PCar.Enemy.y-2 = PCar.Army.y-1) Or (PCar.Enemy.y-2 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+5 <= PCar.Army.x+4) And (PCar.Enemy.x+5 >= PCar.Army.x)) And ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = PCar.Army.y-1) Or (PCar.Enemy.y = PCar.Army.y+1))) Or
(((PCar.Enemy.x+5 <= PCar.Army.x+4) And (PCar.Enemy.x+5 >= PCar.Army.x)) And ((PCar.Enemy.y+1 = PCar.Army.y) Or (PCar.Enemy.y+1 = PCar.Army.y-1) Or (PCar.Enemy.y+1 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+5 <= PCar.Army.x+4) And (PCar.Enemy.x+5 >= PCar.Army.x)) And ((PCar.Enemy.y-2 = PCar.Army.y) Or (PCar.Enemy.y-2 = PCar.Army.y-1) Or (PCar.Enemy.y-2 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+6 <= PCar.Army.x+4) And (PCar.Enemy.x+6 >= PCar.Army.x)) And ((PCar.Enemy.y+2 = PCar.Army.y) Or (PCar.Enemy.y+2 = PCar.Army.y-1) Or (PCar.Enemy.y+2 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+6 <= PCar.Army.x+4) And (PCar.Enemy.x+6 >= PCar.Army.x)) And ((PCar.Enemy.y-2 = PCar.Army.y) Or (PCar.Enemy.y-2 = PCar.Army.y-1) Or (PCar.Enemy.y-2 = PCar.Army.y+1))) Then
CheckLose2 := True
Else CheckLose2 := False;
End;
Function TGame.CheckHitTheBoss: Boolean;
Begin
If (((Bullet.Army.x >= PCar.Enemy.x-4) And (Bullet.Army.x <= PCar.Enemy.x+5)) And (Bullet.Army.y = PCar.Enemy.y)) Or
(((Bullet.Army.x >= PCar.Enemy.x-2) And (Bullet.Army.x <= PCar.Enemy.x+5)) And (Bullet.Army.y = PCar.Enemy.y-1)) Or
(((Bullet.Army.x >= PCar.Enemy.x+1) And (Bullet.Army.x <= PCar.Enemy.x+6)) And (Bullet.Army.y = PCar.Enemy.y-2)) Or
(((Bullet.Army.x >= PCar.Enemy.x-2) And (Bullet.Army.x <= PCar.Enemy.x+5)) And (Bullet.Army.y = PCar.Enemy.y+1)) Or
(((Bullet.Army.x >= PCar.Enemy.x+1) And (Bullet.Army.x <= PCar.Enemy.x+6)) And (Bullet.Army.y = PCar.Enemy.y+2)) Then
CheckHitTheBoss := True
Else CheckHitTheBoss := False;
End;
Function TGame.CheckWin: Boolean;
Begin
If (Heart = 0) Then CheckWin := True
Else CheckWin := False;
End;
Procedure TGame.TheArrowMovingDown;
Begin
Gotoxy(51,13);
Write(#32#32#32#32#32#32#32#32#32#32,
#32#32#32#32#32#32#32#32#32#32#32#32#32);
TextColor(LightGreen);
Gotoxy(Arrow.x,Arrow.y);
Writeln(#32);
Arrow.y := Arrow.y + 2;
Gotoxy(Arrow.x,Arrow.y);
Writeln(#16);
TextColor(LightBlue);
Gotoxy(48,15);
Write('(Double ENTER Pressing)');
End;
Procedure TGame.TheArrowMovingUp;
Begin
Gotoxy(48,15);
Write(#32#32#32#32#32#32#32#32#32#32,
#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
TextColor(LightGreen);
Gotoxy(Arrow.x,Arrow.y);
Writeln(#32);
Arrow.y := Arrow.y - 2;
Gotoxy(Arrow.x,Arrow.y);
Writeln(#16);
TextColor(LightBlue);
Gotoxy(51,13);
Write('(Double ENTER Pressing)');
End;
Procedure TGame.ScenceOfArmyTank;
Begin
If (PCar.Army.y < 15) Then
Repeat
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.y <> 15) Then
PCar.Army.y := PCar.Army.y + 1;
If (PCar.Army.x < 35) Then
PCar.Army.x := PCar.Army.x + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
Delay(60);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until (PCar.Army.y = 15) And (PCar.Army.x = 35)
Else If (PCar.Army.y > 15) Then
Repeat
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.y <> 15) Then
PCar.Army.y := PCar.Army.y - 1;
If (PCar.Army.x < 35) Then
PCar.Army.x := PCar.Army.x + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
Delay(60);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until (PCar.Army.y = 15) And (PCar.Army.x = 35);
Delay(500);
Repeat
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
PCar.Army.x := PCar.Army.x - 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
Delay(60);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until (PCar.Army.x = 23);
Repeat
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
PCar.Army.x := PCar.Army.x + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
Delay(20);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until (PCar.Army.x = 76);
End;
Procedure TGame.ScenceOfGame;
Begin
For i := 0 To 39 Do
Begin
For j := 1 To 28 Do
Begin
TextColor(Cyan);
TextBackGround(Black);
GotoXY(i+1,j); WriteLn(#178);
GotoXY(80-i,j); WriteLn(#178);
End;
Delay(10);
If KeyPressed Then
While KeyPressed Do ReadKey;
End;
For i := 42 To 80 Do
Begin
GotoXY(i,29); Write(#178);
End;
GotoXY(1,29); WriteLn(#178);
Delay(10);
For j := 14 To 16 Do
For i := 32 To 48 Do
Begin
GotoXY(i,j);
TextColor(Cyan); Write(#219);
End;
GotoXY(34,15);
TextColor(LightGreen);
TextBackGround(Black);
Write('THE TANK GAME');
TextColor(Black);
TextBackGround(Cyan);
GotoXY(32,14); WriteLn(#15);
GotoXY(32,16); WriteLn(#15);
GotoXY(48,14); WriteLn(#15);
GotoXY(48,16); WriteLn(#15);
For i := 2 To 79 Do
Begin
GotoXY(i,29);
TextColor(Cyan); WriteLn(#178);
End;
Repeat
TimeScence := TimeScence + 1;
Delay(20);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until TimeScence = 50;
TimeScence := 0;
For i := 0 To 39 Do
Begin
For j := 1 To 29 Do
Begin
TextColor(Black);
TextBackGround(Black);
GotoXY(40-i,j); WriteLn(#32);
GotoXY(41+i,j); WriteLn(#32);
End;
Delay(10);
If KeyPressed Then
While KeyPressed Do ReadKey;
End;
End;
Procedure TGame.Interfaces;
Begin
Clrscr;
TextColor(LightBlue);
For j := 1 To 2 Do
For i := 1 To 13 Do
Begin
Gotoxy(i+32,9+(j-1)*2);
Writeln(#205);
End;
Gotoxy(32,10); Writeln(#186);
Gotoxy(46,10);Writeln(#186);
Gotoxy(32,9); Writeln(#201);
Gotoxy(32,11); Writeln(#200);
Gotoxy(46,9); Writeln(#187);
Gotoxy(46,11); Writeln(#188);
Gotoxy(33,10);
TextColor(Yellow);
Writeln('THE TANK GAME');
TextColor(LightGreen);
Gotoxy(56,28);
Writeln(#15#32#76#105#99#101#110#115#101,':',
#32#36#36#72#97#117#95#67#114#117#115#104#36#36);
TextColor(LightCyan);
GotoXY(2,28); Write('MADE BY PASCAL XE v3.2.2');
//License
TextColor(White);
For i := 1 To 78 Do
Begin
Gotoxy(2+(i-1)*1,1);
Write(#196);
Gotoxy(2+(i-1)*1,29);
Write(#196);
End;
Gotoxy(1,1); Write(#218);
Gotoxy(80,1); Write(#191);
Gotoxy(1,29); Write(#192);
Gotoxy(80,29); Write(#217);
For i := 1 To 27 Do
Begin
Gotoxy(1,2+(i-1)*1);
Write(#179);
Gotoxy(80,2+(i-1)*1);
Write(#179);
End;
TextColor(White);
Gotoxy(33,13); Writeln('Start the game');
Gotoxy(33,15); Writeln('Instruction');
TextColor(LightBlue);
Gotoxy(51,13); Writeln('(Double ENTER Pressing)');
TextColor(Green);
Arrow.x := 30;
Arrow.y := 13;
Gotoxy(Arrow.x,Arrow.y); Write(#16);
Repeat
If Keypressed Then
Case Readkey Of
#72: If (Arrow.y <> 13) Then Game.TheArrowMovingUp;
#80: If (Arrow.y <> 15) Then Game.TheArrowMovingDown;
End;
Until Readkey = #13;
End;
Procedure TGame.Win;
Begin
Clrscr;
TextColor(LightGreen);
Gotoxy(24,13) ;
Write('YOU HAVE COMPLETED THE ASSIGNMENT!!');
TextColor(White);
Gotoxy(36,15);
Write('N: Next Assignment');
Gotoxy(36,16);
Write('Esc: Exit');
End;
Procedure TGame.Lose;
Begin
Clrscr;
TextColor(LightRed);
Gotoxy(22,13);
Write('YOU HAVE NOT COMPLETED THE ASSIGNMENT!!');
TextColor(White);
Gotoxy(36,15);
Write('R: Restar');
Gotoxy(36,16);
Write('Esc: Exit');
End;
Procedure TGame.BulletAvailable;
Begin
GotoXY(19,29);
TextColor(Black);
Write(#32#32#32#32#32#32#32#32#32#32#32#32);
GotoXY(19,29);
TextColor(LightGreen);
Write('Available');
End;
Procedure TGame.BulletUnavailable;
Begin
GotoXY(19,29);
TextColor(Black);
Write(#32#32#32#32#32#32#32#32#32#32#32#32);
GotoXY(19,29);
TextColor(LightRed);
Write('Unavailable');
End;
Procedure TGame.TheMapOfGame;
Begin
Gotoxy(1,2);
TextColor(White);
For i:=1 To 80 Do
Write(#205);
Delay(100);
Gotoxy(1,28);
For i:=1 To 80 Do
Write(#205);
Gotoxy(29,1);
Gotoxy(2,1);
TextColor(LightGreen);
Writeln('Esc: EXIT');
TextColor(White);
Gotoxy(64,2); Writeln(#207);
Gotoxy(76,2); Writeln(#207);
Gotoxy(64,1); Writeln(#179);
Gotoxy(76,1); Writeln(#179);
TextColor(LightCyan);
GotoXY(65,1); Write('BOSS: ');
TextColor(White);
GotoXY(72,1); Write(Heart);
TextColor(LightRed);
GotoXY(75,1); Write(#3);
TextColor(Cyan);
GotoXY(1,29); Write('Status of Bullet: ');
TextColor(LightGreen);
GotoXY(19,29); Write('Available');
End;
Procedure TGame.Instruction;
Begin
For i := 1 To 80 Do
Begin
TextColor(White);
Gotoxy(i,2);
Write(#196);
End;
GotoXY(1,1);
TextColor(LightGreen); Write('B: Back');
GotoXY(34,1);
TextColor(Yellow); Write('INSTRUCTION');
//Instruction
TextColor(White);
GotoXY(3,3); Write(#4#32,'Your assignment is to destroy the');
TextColor(LightCyan);
GotoXY(3,5); Writeln(#4#32,'Using the up arrow key',#32#24#32,'to control the tank going up');
GotoXY(3,7); Writeln(#4#32,'Using the up arrow key',#32#25#32,'to control the tank going down');
GotoXY(3,9); Writeln(#4#32,'Using the up arrow key',#32#26#32,'to control the tank going right');
GotoXY(3,11); Writeln(#4#32,'Using the up arrow key',#32#27#32,'to control the tank going left');
GotoXY(3,13); Writeln(#4#32,'Using SPACE key to shoot');
TextColor(LightBlue);
GotoXY(1,15); WriteLn(#15#32'NOTE: ');
TextColor(LightRed);
GotoXY(3,17); WriteLn(#4#32'Your tank can`t use its gun the cases: ');
GotoXY(5,18); WriteLn(#43#32'In the time bullets of'#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32'flying');
GotoXY(5,19); WriteLn(#43#32'In the time'#32#32#32#32#32#32#32#32#32#32#32#32#32#32' scanning your tank');
TextColor(Yellow);
GotoXY(3,21); WriteLn(#4#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32'can`t use its guns in these cases, either');
GotoXY(3,23); WriteLn(#4#32'Try your best to avoid the bullets of'#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
GotoXY(3,25); WriteLn(#4#32'Try your best to avoid the horrible scan of'#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
GotoXY(3,27); WriteLn(#4#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32'can avoid the bullets, so try your best to shoot accurately');
TextColor(LightGreen);
GotoXY(3,29); Write('['#32#32#32#32#32#32#32#32#32#32#32#32#32#32'always follow you, utilize this to shoot him accurately]');
TextColor(LightRed);
GotoXY(39,3); Write('THE BOSS TANK');
GotoXY(30,13); Write('THE BOSS TANK');
GotoXY(30,18); Write('THE BOSS TANK');
GotoXY(19,19); Write('THE BOSS TANK');
GotoXY(5,21); Write('THE BOSS TANK');
GotoXY(43,23); Write('THE BOSS TANK');
GotoXY(49,25); Write('THE BOSS TANK');
GotoXY(5,27); Write('THE TANK BOSS');
GotoXY(4,29); Write('THE BOSS TANK');
Repeat
Savedkey := Readkey;
If (SavedKey <> 'b') Or (SavedKey <> 'B') Then
While Keypressed Do
Readkey;
Until (SavedKey = 'b') Or (SavedKey = 'B');
If (SavedKey = 'b') Or (SavedKey = 'B') Then
Begin
Game.ScenceOfGame;
TextBackGround(Black);
Clrscr;
Game.Interfaces;
End;
End;
Procedure TCar.BossScanning;
Begin
Boss := True;
If (Boss = True) Then
Game.BulletUnavailable;
n := PCar.Enemy.y;
m := PCar.Enemy.x;
//Boss moves towards
If (PCar.Enemy.y < PCar.Army.y) And (Game.CheckLose2 = False) Then
Repeat
If (PCar.Enemy.y = 25) And (Game.CheckLose2 = False) Then Break;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.y := PCar.Enemy.y + 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Delay(35);
Until ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 25));
If (((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 25)) And (Game.CheckLose2 = False)) Then
Begin
Repeat
delays := 1;
GotoXY(35,1);
TextColor(LightRed); Write(#30'WARNING'#30);
Repeat
delays := delays + 1;
Delay(5);
Car.SecondaryController;
Until delays = 4;
delays := 1;
GotoXY(35,1);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32);
Car.SecondaryController;
TimeMessage3 := TimeMessage3 + 1;
Repeat
delays := delays + 1;
Delay(5);
Car.SecondaryController;
Until delays = 4;
Until (TimeMessage3 = 40);
If (TimeMessage3 = 40) Then
Begin
GotoXY(65,29);
TextColor(LightRed); Write('YOU MUST DIE!!!');
TimeMessage3 := 1;
Repeat
If (PCar.Enemy.y = 25) Then;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.x := PCar.Enemy.x - 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(10);
Until (PCar.Enemy.x = 6) Or (Game.CheckLose2 = True);
Delay(50);
GotoXY(35,1);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32);
If (Game.CheckLose2 = False) then
Begin
GotoXY(65,29);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
Repeat
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.x := PCar.Enemy.x + 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(35);
Until (PCar.Enemy.x = m) Or (Game.CheckLose2 = True);
End;
End;
End;
//Boss Moves BackWards
If (PCar.Enemy.y > PCar.Army.y) And (Game.CheckLose2 = False) Then
Repeat
If (PCar.Enemy.y = 5) Then Break;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.y := PCar.Enemy.y - 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Delay(40);
Until ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 5));
If (((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 25)) And (Game.CheckLose2 = False)) Then
Begin
Repeat
delays := 1;
GotoXY(35,1);
TextColor(LightRed); Write(#30'WARNING'#30);
Repeat
delays := delays + 1;
Delay(5);
Car.SecondaryController;
Until delays = 4;
delays := 1;
GotoXY(35,1);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32);
Car.SecondaryController;
TimeMessage3 := TimeMessage3 + 1;
Repeat
delays := delays + 1;
Delay(5);
Car.SecondaryController;
Until delays = 4;
Until (TimeMessage3 = 40);
If (TimeMessage3 = 40) Then
Begin
TimeMessage3 := 0;
GotoXY(65,29);
TextColor(LightRed); Write('YOU MUST DIE!!!');
Repeat
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.x := PCar.Enemy.x - 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Delay(10);
Car.SecondaryController;
Until (PCar.Enemy.x = 6) Or (Game.CheckLose2 = True);
Delay(50);
If (Game.CheckLose2 = False) Then
Begin
GotoXY(65,29);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
Repeat
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.x := PCar.Enemy.x + 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(35);
Until (PCar.Enemy.x = m) Or (Game.CheckLose2 = True);
End;
End;
End;
Boss := False;
If (Boss = False) Then
Game.BulletAvailable;
End;
Procedure TCar.BossDestroyed;
Begin
GotoXY(PCar.Enemy.x+Random(8),PCar.Enemy.y-2+Random(5));
TextColor(Black);
Write(#32);
End;
Procedure TCar.DrawEnemyBossCar(x,y: Byte);
Begin
//The Middle Of Boss(x,y)
GotoXY(PCar.Enemy.x-4,PCar.Enemy.y);
TextColor(LightRed); Write(#205#205#216);
GotoXY(PCar.Enemy.x-1,PCar.Enemy.y);
TextColor(LightBlue); Write(#219#219#219#219);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y);
TextColor(White); Write(#254#254);
GotoXY(PCar.Enemy.x+5,PCar.Enemy.y);
TextColor(LightBlue); Write(#219);
//The side of boss(x,y-1)
GotoXY(PCar.Enemy.x,PCar.Enemy.y-1);
TextColor(LightBlue); Write(#219#219);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y-1);
TextColor(White); Write(#254);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y-1);
TextColor(LightBlue); Write(#219#219#185);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y-2);
TextColor(Cyan); Write(#219#219#219#219#219);
GotoXY(PCar.Enemy.x+1,PCar.Enemy.y-2);
TextColor(LightBlue); Write(#201);
//The side of boss(x,y+!)
GotoXY(PCar.Enemy.x,PCar.Enemy.y+1);
TextColor(LightBlue); Write(#219#219);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y+1);
TextColor(White); Write(#254);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y+1);
TextColor(LightBlue); Write(#219#219#185);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y+2);
TextColor(Cyan); Write(#219#219#219#219#219);
GotoXY(PCar.Enemy.x+1,PCar.Enemy.y+2);
TextColor(LightBlue); Write(#200);
//The two short gun(x,y+1), (x,y-1);
GotoXY(PCar.Enemy.x-2,PCar.Enemy.y-1);
TextColor(Yellow); Write(#205#205);
GotoXY(PCar.Enemy.x-2,PCar.Enemy.y+1);
Write(#205#205);
//The Main Object Of Boss
GotoXY(PCar.Enemy.x,PCar.Enemy.y);
TextColor(LightRed+Blink); Write(#219);
End;
Procedure TCar.RemoveEnemyBossCar(x,y: Byte);
Begin
//The Middle Of Boss(x,y)
GotoXY(PCar.Enemy.x-4,PCar.Enemy.y); Write(#32#32#32);
GotoXY(PCar.Enemy.x-1,PCar.Enemy.y); Write(#32#32#32#32);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y); Write(#32#32);
GotoXY(PCar.Enemy.x+5,PCar.Enemy.y); Write(#32);
//The side of boss(x,y-1)
GotoXY(PCar.Enemy.x,PCar.Enemy.y-1); Write(#32#32);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y-1); Write(#32);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y-1); Write(#32#32#32);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y-2); Write(#32#32#32#32#32);
GotoXY(PCar.Enemy.x+1,PCar.Enemy.y-2); Write(#32);
//The side of boss(x,y+!)
GotoXY(PCar.Enemy.x,PCar.Enemy.y+1); Write(#32#32);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y+1); Write(#32);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y+1); Write(#32#32#32);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y+2); Write(#32#32#32#32#32);
GotoXY(PCar.Enemy.x+1,PCar.Enemy.y+2); Write(#32);
//The two short gun(x,y+1), (x,y-1);
GotoXY(PCar.Enemy.x-2,PCar.Enemy.y-1); Write(#32#32);
GotoXY(PCar.Enemy.x-2,PCar.Enemy.y+1); Write(#32#32);
End;
Procedure TCar.Case1Shooting;
Begin
Boss := True;
If (Boss = True) Then
Game.BulletUnavailable;
Bullet.Enemy[3].x := PCar.Enemy.x - 5;
Bullet.Enemy[3].y := PCar.Enemy.y;
Repeat
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#32#32);
Bullet.Enemy[3].x := Bullet.Enemy[3].x - 1;
TextColor(LightGreen);
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#17#205);
Car.SecondaryController;
Delay(20);
Moving := Random(20);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Until ((Bullet.Enemy[3].x = 2) Or Game.CheckLose1 = True);
If (Bullet.Enemy[3].x = 2) Then
Begin
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#32);
GotoXY(Bullet.Enemy[3].x+1,Bullet.Enemy[3].y); Write(#32);
End;
Boss := False;
If (Boss = False) Then
Game.BulletAvailable;
End;
Procedure TCar.Case2Shooting;
Begin
Boss := True;
If (Boss = True) Then
Game.BulletUnavailable;
Bullet.Enemy[1].x := PCar.Enemy.x - 3;
Bullet.Enemy[1].y := PCar.Enemy.y - 1;
Bullet.Enemy[2].x := PCar.Enemy.x - 3;
Bullet.Enemy[2].y := PCar.Enemy.y + 1;
Repeat
Randomize;
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#32);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#32);
Bullet.Enemy[1].x := Bullet.Enemy[1].x - 1;
Bullet.Enemy[2].x := Bullet.Enemy[2].x - 1;
TextColor(Yellow);
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#174);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#174);
Car.SecondaryController;
Delay(30);
Moving := Random(20);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Until (((Bullet.Enemy[1].x = 2) And (Bullet.Enemy[2].x = 2)) Or Game.CheckLose1 = True);
If ((Bullet.Enemy[1].x = 2) And (Bullet.Enemy[2].x = 2)) Then
Begin
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#32);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#32);
End;
Boss := False;
If (Boss = False) Then
Game.BulletAvailable;
End;
Procedure TCar.Case3Shooting;
Begin
Boss := True;
If (Boss = True) Then
Game.BulletUnavailable;
Bullet.Enemy[1].x := PCar.Enemy.x - 3;
Bullet.Enemy[1].y := PCar.Enemy.y - 1;
Bullet.Enemy[2].x := PCar.Enemy.x - 3;
Bullet.Enemy[2].y := PCar.Enemy.y + 1;
Bullet.Enemy[3].x := PCar.Enemy.x - 5;
Bullet.Enemy[3].y := PCar.Enemy.y;
Repeat
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#32);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#32);
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#32#32);
Bullet.Enemy[1].x := Bullet.Enemy[1].x - 1;
Bullet.Enemy[2].x := Bullet.Enemy[2].x - 1;
Bullet.Enemy[3].x := Bullet.Enemy[3].x - 1;
TextColor(Yellow);
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#174);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#174);
TextColor(LightGreen);
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#17#205);
Car.SecondaryController;
Delay(30);
Moving := Random(20);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Until ((((Bullet.Enemy[1].x = 2) And (Bullet.Enemy[2].x = 2)) Or (Bullet.Enemy[3].x = 2)) Or Game.CheckLose1 = True);
If (((Bullet.Enemy[1].x = 2) And (Bullet.Enemy[2].x = 2)) Or (Bullet.Enemy[3].x = 2)) Then
Begin
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#32);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#32);
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#32);
GotoXY(Bullet.Enemy[3].x+1,Bullet.Enemy[3].y); Write(#32);
End;
Boss := False;
If (Boss = False) Then
Game.BulletAvailable;
End;
Procedure TCar.EnemyBossCarShooting;
Begin
Randomize;
TypeBullet := Random(3);
Case TypeBullet Of
0: Car.Case1Shooting;
1: Car.Case2Shooting;
2: Car.Case3Shooting;
End;
End;
Procedure TCar.EnemyBossCarMoving;
Begin
//Boss Moves Down
If (PCar.Enemy.y < PCar.Army.y) Then
Repeat
If (PCar.Enemy.y = 25) Then Break;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.y := PCar.Enemy.y + 1;
If (PCar.Enemy.x > 50) Then
PCar.Enemy.x := PCar.Enemy.x - Random(2);
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(30);
Until ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 25));
//Boss Moves Up
If (PCar.Enemy.y > PCar.Army.y) Then
Repeat
If (PCar.Enemy.y = 5) Then Break;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.y := PCar.Enemy.y - 1;
If (PCar.Enemy.x+7 < 80) Then
PCar.Enemy.x := PCar.Enemy.x + Random(2);
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(30);
Until ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 5));
End;
Procedure TCar.DrawArmyCar(x,y: Byte);
Begin
TextColor(Cyan);
GotoXY(PCar.Army.x+1,PCar.Army.y-1); Write(#111#32#111);
TextColor(LightGreen);
GotoXY(PCar.Army.x,PCar.Army.y); Write(#195#219#219#219);
TextColor(LightRed);
GotoXY(PCar.Army.x+4,PCar.Army.y); Write(#205);
TextColor(Cyan);
GotoXY(PCar.Army.x+1,PCar.Army.y+1); Write(#111#32#111);
End;
Procedure TCar.RemoveArmyCar(x,y: Byte);
Begin
TextColor(Black);
GotoXY(PCar.Army.x+1,PCar.Army.y-1); Write(#32#32#32);
GotoXY(PCar.Army.x,PCar.Army.y); Write(#32#32#32#32#32);
GotoXY(PCar.Army.x+4,PCar.Army.y); Write(#32);
GotoXY(PCar.Army.x+1,PCar.Army.y+1); Write(#32#32#32);
End;
Procedure TCar.ArmyCarMoveRight;
Begin
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.x < 35) Then
PCar.Army.x := PCar.Army.x + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
End;
Procedure TCar.ArmyCarMoveLeft;
Begin
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.x > 4) Then
PCar.Army.x := PCar.Army.x - 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
End;
Procedure TCar.ArmyCarMoveUp;
Begin
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.y > 4) Then
PCar.Army.y := PCar.Army.y - 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
End;
Procedure TCar.ArmyCarMoveDown;
Begin
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.x < 26) Then
PCar.Army.y := PCar.Army.y + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
End;
Procedure TCar.ArmyCarShootingTheBullet;
Begin
Randomize;
Time := 0;
If (Time = 0) Then
Game.BulletUnavailable;
Bullet.Army.x := PCar.Army.x + 5;
Bullet.Army.y := PCar.Army.y;
Repeat
Randomize;
GotoXY(Bullet.Army.x,Bullet.Army.y); Write(#32);
Bullet.Army.x := Bullet.Army.x + 1;
TextColor(Yellow);
GotoXY(Bullet.Army.x,Bullet.Army.y); Write(#175);
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(35);
Until ((Bullet.Army.x = 80) Or (Game.CheckHitTheBoss = True));
If (Bullet.Army.x = 80) Then
Begin
GotoXY(Bullet.Army.x,Bullet.Army.y);
Write(#32);
End;
If (Game.CheckHitTheBoss = True) Then
Begin
Heart := Heart - 1;
GotoXY(72,1); Write(#32#32);
TextColor(White);
GotoXY(72,1); Write(Heart);
GotoXY(Bullet.Army.x,Bullet.Army.y);
TextBackGround(Yellow); Write(#32);
Messages1 := Random(3);
TextBackGround(Black);
If ((Messages1 = 0) And (Heart > 1)) Then
Repeat
GotoXY(65,29);
TextColor(White); Write('GOOD! Haha!');
TimeMessages1 := TimeMessages1 + 1;
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(25);
Until (TimeMessages1 = 25)
Else If ((Messages1 = 1) And (Heart > 1)) Then
Repeat
GotoXY(65,29);
TextColor(Yellow); Write('Ahhh...!!');
TimeMessages1 := TimeMessages1 + 1;
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(25);
Until (TimeMessages1 = 25)
Else If ((Messages1 = 2) And (Heart > 1)) Then
Repeat
GotoXY(65,29);
TextColor(LightRed); Write('Kill me..!?');
TimeMessages1 := TimeMessages1 + 1;
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(25);
Until (TimeMessages1 = 25);
Delay(50);
TextBackGround(Black);
GotoXY(Bullet.Army.x,Bullet.Army.y); Write(#32);
TextBackGround(Black);
If (TimeMessages1 = 25) Then
Repeat
TimeMessages1 := TimeMessages1 - 1;
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(25);
Until (TimeMessages1 = 0);
If (TimeMessages1 = 0) Then
GotoXY(65,29); Write(#32#32#32#32#32#32#32#32#32#32#32);
End;
End;
Procedure TCar.MainController;
Begin
If KeyPressed And (Game.CheckLose2 = False) Then
Case ReadKey Of
R: If (PCar.Army.x < 35) Then Car.ArmyCarMoveRight;
L: If (PCar.Army.x > 4) Then Car.ArmyCarMoveLeft;
U: If (PCar.Army.y > 4) Then Car.ArmyCarMoveUp;
D: If (PCar.Army.y < 26) Then Car.ArmyCarMoveDown;
Space: If (Boss = False) And (Time = 10) Then Car.ArmyCarShootingTheBullet;
#27: Halt;
End;
End;
Procedure TCar.SecondaryController;
Begin
If KeyPressed And (Game.CheckLose2 = False) Then
Case ReadKey Of
R: If (PCar.Army.x < 35) Then Car.ArmyCarMoveRight;
L: If (PCar.Army.x > 4) Then Car.ArmyCarMoveLeft;
U: If (PCar.Army.y > 4) Then Car.ArmyCarMoveUp;
D: If (PCar.Army.y < 26) Then Car.ArmyCarMoveDown;
#27: Halt;
End;
End;
Procedure TGame.Start;
Begin
Randomize;
TextBackGround(Black);
ClrScr;
Heart := 10 + Random(11);
TimeMessages1 := 1;
TimeMessage3 := 1;
TimeScence := 0;
Game.TheMapOfGame;
PCar.Army.x := 15;
PCar.Army.y := 15;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
PCar.Enemy.x := 55;
PCar.Enemy.y := 15;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
For i := 1 To 3 Do
Begin
Bullet.Enemy.x := 0;
Bullet.Enemy.y := 0;
End;
ShootingBullet := 0;
Boss := False;
Time := 10;
delays := 1;
End;
Procedure TGame.PlayingTheGame;
Begin
Randomize;
Game.Start;
While ((Game.CheckLose1 = False) And (Game.CheckWin = False) And (Game.CheckLose2 = False)) Do
Begin
Randomize;
TextColor(Black);
Car.MainController;
Delay(30);
Moving := Random(30);
Func := Random(2);
If (Moving = 3) Then
Begin
Case Func Of
0: Car.EnemyBossCarMoving;
1: Car.BossScanning;
End;
End;
If (ShootingBullet = 10) Then
Begin
Car.EnemyBossCarShooting;
ShootingBullet := 0;
End;
ShootingBullet := ShootingBullet + 1;
If (Time < 10) Then
Time := Time + 1;
End;
If ((Game.CheckLose1 = True) Or (Game.CheckLose2 = True)) Then
Begin
GotoXY(60,29);
TextColor(LightRed); Write('HAHA..!You idiot!!');
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
Delay(750);
Game.ScenceOfGame;
TextBackGround(Black);
ClrScr;
Game.Lose;
Repeat
If Keypressed Then
Begin
GetInput := Readkey;
If (GetInput=#82) Or (GetInput=#114) Then
Begin
Game.ScenceOfGame;
ClrScr;
Game.PlayingTheGame;
End
Else If (GetInput=#27) Then
Begin
While Keypressed Do
Readkey;
Halt;
End;
End;
Until False;
End
Else If (Game.CheckWin = True) Then
Begin
GotoXY(65,29);
TextColor(LightCyan); Write('NO WAY!! Ahh...!');
Delay(750);
For i := 1 To 20 Do
Begin
Randomize;
Car.BossDestroyed;
Car.BossDestroyed;
Car.BossDestroyed;
Delay(100);
End;
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
Delay(1200);
Game.ScenceOfArmyTank;
Game.ScenceOfGame;
TextBackGround(Black);
ClrScr;
Game.Win;
Repeat
If Keypressed Then
Begin
GetInput := Readkey;
If (GetInput=#78) Or (GetInput=#110) Then
Begin
Game.ScenceOfGame;
ClrScr;
Game.PlayingTheGame
End
Else If (GetInput=#27) Then
Begin
While Keypressed Do
Readkey;
Halt;
End;
End;
Until False;
End;
End;
//==================================THE MAIN PROGRAMME========================================
Begin
TextBackGround(Black);
ClrScr;
Game.Interfaces;
Repeat
Key := Readkey;
If (Key = #13) And (Arrow.x = 30) And (Arrow.y = 15) Then
Begin
Game.ScenceOfGame;
Clrscr;
Game.Instruction;
End;
Until (Key = #13) And (Arrow.x = 30) And (Arrow.y = 13);
If (Key = #13) And (Arrow.x = 30) And (Arrow.y = 13) Then
Begin
Game.ScenceOfGame;
Clrscr;
Game.TheMapOfGame;
Game.PlayingTheGame;
End;
Readln;
End.
Uses Crt;
Const
U = #72;
D = #80;
R = #77;
L = #75;
Space = #32;
Type
rCar = Record
Army: Record
x,y: Byte;
End;
Enemy: Record
x,y: Byte;
End;
End;
TCar = Object
Procedure DrawArmyCar(x,y: Byte);
Procedure RemoveArmyCar(x,y: Byte);
Procedure MainController;
Procedure SecondaryController;
Procedure ArmyCarMoveRight;
Procedure ArmyCarMoveLeft;
Procedure ArmyCarMoveUp;
Procedure ArmyCarMoveDown;
Procedure ArmyCarShootingTheBullet;
Procedure DrawEnemyBossCar(x,y: Byte);
Procedure RemoveEnemyBossCar(x,y: Byte);
Procedure EnemyBossCarMoving;
Procedure EnemyBossCarShooting;
Procedure Case1Shooting;
Procedure Case2Shooting;
Procedure Case3Shooting;
Procedure BossDestroyed;
Procedure BossScanning;
End;
TGame = Object
Procedure TheMapOfGame;
Function CheckLose1: Boolean;
Function CheckLose2: Boolean;
Function CheckHitTheBoss: Boolean;
Function CheckWin: Boolean;
Procedure BulletAvailable;
Procedure BulletUnavailable;
Procedure Interfaces;
Procedure TheArrowMovingDown;
Procedure TheArrowMovingUp;
Procedure Instruction;
Procedure ScenceOfGame;
Procedure ScenceOfArmyTank;
Procedure PlayingTheGame;
Procedure Lose;
Procedure Win;
Procedure Start;
End;
TBullet = Record
Army: Record
x,y: Byte;
End;
Enemy: Array[1..3] Of Record
x,y: Byte;
End;
End;
Var
PCar: rCar;
Car: TCar;
Bullet: TBullet;
i,Moving,RandomBullet,TypeBullet,ShootingBullet,delays,
Heart,m,n,Func,Time,j,Messages1,Messages2,TimeMessages1,
TimeMessages2,TimeMessage3,k,TimeScence: Integer;
SavedKey,Key,GetInput: Char;
Game: TGame;
Boss: Boolean;
Arrow: Record
x,y: Byte;
End;
Function TGame.CheckLose1: Boolean;
Begin
If (((Bullet.Enemy[1].x <= PCar.Army.x+4) And (Bullet.Enemy[1].x >= PCar.Army.x)) And (Bullet.Enemy[1].y = PCar.Army.y)) Or
(((Bullet.Enemy[1].x <= PCar.Army.x+3) And (Bullet.Enemy[1].x >= PCar.Army.x+1)) And (Bullet.Enemy[1].y = PCar.Army.y-1)) Or
(((Bullet.Enemy[1].x <= PCar.Army.x+3) And (Bullet.Enemy[1].x >= PCar.Army.x+1)) And (Bullet.Enemy[1].y = PCar.Army.y+1)) Or
(((Bullet.Enemy[2].x <= PCar.Army.x+4) And (Bullet.Enemy[2].x >= PCar.Army.x)) And (Bullet.Enemy[2].y = PCar.Army.y)) Or
(((Bullet.Enemy[2].x <= PCar.Army.x+3) And (Bullet.Enemy[2].x >= PCar.Army.x+1)) And (Bullet.Enemy[2].y = PCar.Army.y-1)) Or
(((Bullet.Enemy[2].x <= PCar.Army.x+3) And (Bullet.Enemy[2].x >= PCar.Army.x+1)) And (Bullet.Enemy[2].y = PCar.Army.y+1)) Or
(((Bullet.Enemy[3].x <= PCar.Army.x+4) And (Bullet.Enemy[3].x >= PCar.Army.x)) And (Bullet.Enemy[3].y = PCar.Army.y)) Or
(((Bullet.Enemy[3].x <= PCar.Army.x+3) And (Bullet.Enemy[3].x >= PCar.Army.x+1)) And (Bullet.Enemy[3].y = PCar.Army.y-1)) Or
(((Bullet.Enemy[3].x <= PCar.Army.x+3) And (Bullet.Enemy[3].x >= PCar.Army.x+1)) And (Bullet.Enemy[3].y = PCar.Army.y+1)) Then
CheckLose1 := True
Else CheckLose1 := False;
End;
Function TGame.CheckLose2: Boolean;
Begin
If (((PCar.Enemy.x-4 <= PCar.Army.x+4) And (PCar.Enemy.x-4 >= PCar.Army.x)) And ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = PCar.Army.y-1) Or (PCar.Enemy.y = PCar.Army.y+1))) Or
(((PCar.Enemy.x-2 <= PCar.Army.x+4) And (PCar.Enemy.x-2 >= PCar.Army.x)) And ((PCar.Enemy.y+1 = PCar.Army.y) Or (PCar.Enemy.y+1 = PCar.Army.y-1) Or (PCar.Enemy.y+1 = PCar.Army.y+1))) Or
(((PCar.Enemy.x-2 <= PCar.Army.x+4) And (PCar.Enemy.x-2 >= PCar.Army.x)) And ((PCar.Enemy.y-1 = PCar.Army.y) Or (PCar.Enemy.y-1 = PCar.Army.y-1) Or (PCar.Enemy.y-1 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+1 <= PCar.Army.x+4) And (PCar.Enemy.x+1 >= PCar.Army.x)) And ((PCar.Enemy.y+2 = PCar.Army.y) Or (PCar.Enemy.y+2 = PCar.Army.y-1) Or (PCar.Enemy.y+2 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+1 <= PCar.Army.x+4) And (PCar.Enemy.x+1 >= PCar.Army.x)) And ((PCar.Enemy.y-2 = PCar.Army.y) Or (PCar.Enemy.y-2 = PCar.Army.y-1) Or (PCar.Enemy.y-2 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+5 <= PCar.Army.x+4) And (PCar.Enemy.x+5 >= PCar.Army.x)) And ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = PCar.Army.y-1) Or (PCar.Enemy.y = PCar.Army.y+1))) Or
(((PCar.Enemy.x+5 <= PCar.Army.x+4) And (PCar.Enemy.x+5 >= PCar.Army.x)) And ((PCar.Enemy.y+1 = PCar.Army.y) Or (PCar.Enemy.y+1 = PCar.Army.y-1) Or (PCar.Enemy.y+1 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+5 <= PCar.Army.x+4) And (PCar.Enemy.x+5 >= PCar.Army.x)) And ((PCar.Enemy.y-2 = PCar.Army.y) Or (PCar.Enemy.y-2 = PCar.Army.y-1) Or (PCar.Enemy.y-2 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+6 <= PCar.Army.x+4) And (PCar.Enemy.x+6 >= PCar.Army.x)) And ((PCar.Enemy.y+2 = PCar.Army.y) Or (PCar.Enemy.y+2 = PCar.Army.y-1) Or (PCar.Enemy.y+2 = PCar.Army.y+1))) Or
(((PCar.Enemy.x+6 <= PCar.Army.x+4) And (PCar.Enemy.x+6 >= PCar.Army.x)) And ((PCar.Enemy.y-2 = PCar.Army.y) Or (PCar.Enemy.y-2 = PCar.Army.y-1) Or (PCar.Enemy.y-2 = PCar.Army.y+1))) Then
CheckLose2 := True
Else CheckLose2 := False;
End;
Function TGame.CheckHitTheBoss: Boolean;
Begin
If (((Bullet.Army.x >= PCar.Enemy.x-4) And (Bullet.Army.x <= PCar.Enemy.x+5)) And (Bullet.Army.y = PCar.Enemy.y)) Or
(((Bullet.Army.x >= PCar.Enemy.x-2) And (Bullet.Army.x <= PCar.Enemy.x+5)) And (Bullet.Army.y = PCar.Enemy.y-1)) Or
(((Bullet.Army.x >= PCar.Enemy.x+1) And (Bullet.Army.x <= PCar.Enemy.x+6)) And (Bullet.Army.y = PCar.Enemy.y-2)) Or
(((Bullet.Army.x >= PCar.Enemy.x-2) And (Bullet.Army.x <= PCar.Enemy.x+5)) And (Bullet.Army.y = PCar.Enemy.y+1)) Or
(((Bullet.Army.x >= PCar.Enemy.x+1) And (Bullet.Army.x <= PCar.Enemy.x+6)) And (Bullet.Army.y = PCar.Enemy.y+2)) Then
CheckHitTheBoss := True
Else CheckHitTheBoss := False;
End;
Function TGame.CheckWin: Boolean;
Begin
If (Heart = 0) Then CheckWin := True
Else CheckWin := False;
End;
Procedure TGame.TheArrowMovingDown;
Begin
Gotoxy(51,13);
Write(#32#32#32#32#32#32#32#32#32#32,
#32#32#32#32#32#32#32#32#32#32#32#32#32);
TextColor(LightGreen);
Gotoxy(Arrow.x,Arrow.y);
Writeln(#32);
Arrow.y := Arrow.y + 2;
Gotoxy(Arrow.x,Arrow.y);
Writeln(#16);
TextColor(LightBlue);
Gotoxy(48,15);
Write('(Double ENTER Pressing)');
End;
Procedure TGame.TheArrowMovingUp;
Begin
Gotoxy(48,15);
Write(#32#32#32#32#32#32#32#32#32#32,
#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
TextColor(LightGreen);
Gotoxy(Arrow.x,Arrow.y);
Writeln(#32);
Arrow.y := Arrow.y - 2;
Gotoxy(Arrow.x,Arrow.y);
Writeln(#16);
TextColor(LightBlue);
Gotoxy(51,13);
Write('(Double ENTER Pressing)');
End;
Procedure TGame.ScenceOfArmyTank;
Begin
If (PCar.Army.y < 15) Then
Repeat
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.y <> 15) Then
PCar.Army.y := PCar.Army.y + 1;
If (PCar.Army.x < 35) Then
PCar.Army.x := PCar.Army.x + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
Delay(60);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until (PCar.Army.y = 15) And (PCar.Army.x = 35)
Else If (PCar.Army.y > 15) Then
Repeat
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.y <> 15) Then
PCar.Army.y := PCar.Army.y - 1;
If (PCar.Army.x < 35) Then
PCar.Army.x := PCar.Army.x + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
Delay(60);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until (PCar.Army.y = 15) And (PCar.Army.x = 35);
Delay(500);
Repeat
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
PCar.Army.x := PCar.Army.x - 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
Delay(60);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until (PCar.Army.x = 23);
Repeat
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
PCar.Army.x := PCar.Army.x + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
Delay(20);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until (PCar.Army.x = 76);
End;
Procedure TGame.ScenceOfGame;
Begin
For i := 0 To 39 Do
Begin
For j := 1 To 28 Do
Begin
TextColor(Cyan);
TextBackGround(Black);
GotoXY(i+1,j); WriteLn(#178);
GotoXY(80-i,j); WriteLn(#178);
End;
Delay(10);
If KeyPressed Then
While KeyPressed Do ReadKey;
End;
For i := 42 To 80 Do
Begin
GotoXY(i,29); Write(#178);
End;
GotoXY(1,29); WriteLn(#178);
Delay(10);
For j := 14 To 16 Do
For i := 32 To 48 Do
Begin
GotoXY(i,j);
TextColor(Cyan); Write(#219);
End;
GotoXY(34,15);
TextColor(LightGreen);
TextBackGround(Black);
Write('THE TANK GAME');
TextColor(Black);
TextBackGround(Cyan);
GotoXY(32,14); WriteLn(#15);
GotoXY(32,16); WriteLn(#15);
GotoXY(48,14); WriteLn(#15);
GotoXY(48,16); WriteLn(#15);
For i := 2 To 79 Do
Begin
GotoXY(i,29);
TextColor(Cyan); WriteLn(#178);
End;
Repeat
TimeScence := TimeScence + 1;
Delay(20);
If KeyPressed Then
While KeyPressed Do ReadKey;
Until TimeScence = 50;
TimeScence := 0;
For i := 0 To 39 Do
Begin
For j := 1 To 29 Do
Begin
TextColor(Black);
TextBackGround(Black);
GotoXY(40-i,j); WriteLn(#32);
GotoXY(41+i,j); WriteLn(#32);
End;
Delay(10);
If KeyPressed Then
While KeyPressed Do ReadKey;
End;
End;
Procedure TGame.Interfaces;
Begin
Clrscr;
TextColor(LightBlue);
For j := 1 To 2 Do
For i := 1 To 13 Do
Begin
Gotoxy(i+32,9+(j-1)*2);
Writeln(#205);
End;
Gotoxy(32,10); Writeln(#186);
Gotoxy(46,10);Writeln(#186);
Gotoxy(32,9); Writeln(#201);
Gotoxy(32,11); Writeln(#200);
Gotoxy(46,9); Writeln(#187);
Gotoxy(46,11); Writeln(#188);
Gotoxy(33,10);
TextColor(Yellow);
Writeln('THE TANK GAME');
TextColor(LightGreen);
Gotoxy(56,28);
Writeln(#15#32#76#105#99#101#110#115#101,':',
#32#36#36#72#97#117#95#67#114#117#115#104#36#36);
TextColor(LightCyan);
GotoXY(2,28); Write('MADE BY PASCAL XE v3.2.2');
//License
TextColor(White);
For i := 1 To 78 Do
Begin
Gotoxy(2+(i-1)*1,1);
Write(#196);
Gotoxy(2+(i-1)*1,29);
Write(#196);
End;
Gotoxy(1,1); Write(#218);
Gotoxy(80,1); Write(#191);
Gotoxy(1,29); Write(#192);
Gotoxy(80,29); Write(#217);
For i := 1 To 27 Do
Begin
Gotoxy(1,2+(i-1)*1);
Write(#179);
Gotoxy(80,2+(i-1)*1);
Write(#179);
End;
TextColor(White);
Gotoxy(33,13); Writeln('Start the game');
Gotoxy(33,15); Writeln('Instruction');
TextColor(LightBlue);
Gotoxy(51,13); Writeln('(Double ENTER Pressing)');
TextColor(Green);
Arrow.x := 30;
Arrow.y := 13;
Gotoxy(Arrow.x,Arrow.y); Write(#16);
Repeat
If Keypressed Then
Case Readkey Of
#72: If (Arrow.y <> 13) Then Game.TheArrowMovingUp;
#80: If (Arrow.y <> 15) Then Game.TheArrowMovingDown;
End;
Until Readkey = #13;
End;
Procedure TGame.Win;
Begin
Clrscr;
TextColor(LightGreen);
Gotoxy(24,13) ;
Write('YOU HAVE COMPLETED THE ASSIGNMENT!!');
TextColor(White);
Gotoxy(36,15);
Write('N: Next Assignment');
Gotoxy(36,16);
Write('Esc: Exit');
End;
Procedure TGame.Lose;
Begin
Clrscr;
TextColor(LightRed);
Gotoxy(22,13);
Write('YOU HAVE NOT COMPLETED THE ASSIGNMENT!!');
TextColor(White);
Gotoxy(36,15);
Write('R: Restar');
Gotoxy(36,16);
Write('Esc: Exit');
End;
Procedure TGame.BulletAvailable;
Begin
GotoXY(19,29);
TextColor(Black);
Write(#32#32#32#32#32#32#32#32#32#32#32#32);
GotoXY(19,29);
TextColor(LightGreen);
Write('Available');
End;
Procedure TGame.BulletUnavailable;
Begin
GotoXY(19,29);
TextColor(Black);
Write(#32#32#32#32#32#32#32#32#32#32#32#32);
GotoXY(19,29);
TextColor(LightRed);
Write('Unavailable');
End;
Procedure TGame.TheMapOfGame;
Begin
Gotoxy(1,2);
TextColor(White);
For i:=1 To 80 Do
Write(#205);
Delay(100);
Gotoxy(1,28);
For i:=1 To 80 Do
Write(#205);
Gotoxy(29,1);
Gotoxy(2,1);
TextColor(LightGreen);
Writeln('Esc: EXIT');
TextColor(White);
Gotoxy(64,2); Writeln(#207);
Gotoxy(76,2); Writeln(#207);
Gotoxy(64,1); Writeln(#179);
Gotoxy(76,1); Writeln(#179);
TextColor(LightCyan);
GotoXY(65,1); Write('BOSS: ');
TextColor(White);
GotoXY(72,1); Write(Heart);
TextColor(LightRed);
GotoXY(75,1); Write(#3);
TextColor(Cyan);
GotoXY(1,29); Write('Status of Bullet: ');
TextColor(LightGreen);
GotoXY(19,29); Write('Available');
End;
Procedure TGame.Instruction;
Begin
For i := 1 To 80 Do
Begin
TextColor(White);
Gotoxy(i,2);
Write(#196);
End;
GotoXY(1,1);
TextColor(LightGreen); Write('B: Back');
GotoXY(34,1);
TextColor(Yellow); Write('INSTRUCTION');
//Instruction
TextColor(White);
GotoXY(3,3); Write(#4#32,'Your assignment is to destroy the');
TextColor(LightCyan);
GotoXY(3,5); Writeln(#4#32,'Using the up arrow key',#32#24#32,'to control the tank going up');
GotoXY(3,7); Writeln(#4#32,'Using the up arrow key',#32#25#32,'to control the tank going down');
GotoXY(3,9); Writeln(#4#32,'Using the up arrow key',#32#26#32,'to control the tank going right');
GotoXY(3,11); Writeln(#4#32,'Using the up arrow key',#32#27#32,'to control the tank going left');
GotoXY(3,13); Writeln(#4#32,'Using SPACE key to shoot');
TextColor(LightBlue);
GotoXY(1,15); WriteLn(#15#32'NOTE: ');
TextColor(LightRed);
GotoXY(3,17); WriteLn(#4#32'Your tank can`t use its gun the cases: ');
GotoXY(5,18); WriteLn(#43#32'In the time bullets of'#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32'flying');
GotoXY(5,19); WriteLn(#43#32'In the time'#32#32#32#32#32#32#32#32#32#32#32#32#32#32' scanning your tank');
TextColor(Yellow);
GotoXY(3,21); WriteLn(#4#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32'can`t use its guns in these cases, either');
GotoXY(3,23); WriteLn(#4#32'Try your best to avoid the bullets of'#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
GotoXY(3,25); WriteLn(#4#32'Try your best to avoid the horrible scan of'#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
GotoXY(3,27); WriteLn(#4#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32'can avoid the bullets, so try your best to shoot accurately');
TextColor(LightGreen);
GotoXY(3,29); Write('['#32#32#32#32#32#32#32#32#32#32#32#32#32#32'always follow you, utilize this to shoot him accurately]');
TextColor(LightRed);
GotoXY(39,3); Write('THE BOSS TANK');
GotoXY(30,13); Write('THE BOSS TANK');
GotoXY(30,18); Write('THE BOSS TANK');
GotoXY(19,19); Write('THE BOSS TANK');
GotoXY(5,21); Write('THE BOSS TANK');
GotoXY(43,23); Write('THE BOSS TANK');
GotoXY(49,25); Write('THE BOSS TANK');
GotoXY(5,27); Write('THE TANK BOSS');
GotoXY(4,29); Write('THE BOSS TANK');
Repeat
Savedkey := Readkey;
If (SavedKey <> 'b') Or (SavedKey <> 'B') Then
While Keypressed Do
Readkey;
Until (SavedKey = 'b') Or (SavedKey = 'B');
If (SavedKey = 'b') Or (SavedKey = 'B') Then
Begin
Game.ScenceOfGame;
TextBackGround(Black);
Clrscr;
Game.Interfaces;
End;
End;
Procedure TCar.BossScanning;
Begin
Boss := True;
If (Boss = True) Then
Game.BulletUnavailable;
n := PCar.Enemy.y;
m := PCar.Enemy.x;
//Boss moves towards
If (PCar.Enemy.y < PCar.Army.y) And (Game.CheckLose2 = False) Then
Repeat
If (PCar.Enemy.y = 25) And (Game.CheckLose2 = False) Then Break;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.y := PCar.Enemy.y + 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Delay(35);
Until ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 25));
If (((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 25)) And (Game.CheckLose2 = False)) Then
Begin
Repeat
delays := 1;
GotoXY(35,1);
TextColor(LightRed); Write(#30'WARNING'#30);
Repeat
delays := delays + 1;
Delay(5);
Car.SecondaryController;
Until delays = 4;
delays := 1;
GotoXY(35,1);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32);
Car.SecondaryController;
TimeMessage3 := TimeMessage3 + 1;
Repeat
delays := delays + 1;
Delay(5);
Car.SecondaryController;
Until delays = 4;
Until (TimeMessage3 = 40);
If (TimeMessage3 = 40) Then
Begin
GotoXY(65,29);
TextColor(LightRed); Write('YOU MUST DIE!!!');
TimeMessage3 := 1;
Repeat
If (PCar.Enemy.y = 25) Then;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.x := PCar.Enemy.x - 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(10);
Until (PCar.Enemy.x = 6) Or (Game.CheckLose2 = True);
Delay(50);
GotoXY(35,1);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32);
If (Game.CheckLose2 = False) then
Begin
GotoXY(65,29);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
Repeat
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.x := PCar.Enemy.x + 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(35);
Until (PCar.Enemy.x = m) Or (Game.CheckLose2 = True);
End;
End;
End;
//Boss Moves BackWards
If (PCar.Enemy.y > PCar.Army.y) And (Game.CheckLose2 = False) Then
Repeat
If (PCar.Enemy.y = 5) Then Break;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.y := PCar.Enemy.y - 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Delay(40);
Until ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 5));
If (((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 25)) And (Game.CheckLose2 = False)) Then
Begin
Repeat
delays := 1;
GotoXY(35,1);
TextColor(LightRed); Write(#30'WARNING'#30);
Repeat
delays := delays + 1;
Delay(5);
Car.SecondaryController;
Until delays = 4;
delays := 1;
GotoXY(35,1);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32);
Car.SecondaryController;
TimeMessage3 := TimeMessage3 + 1;
Repeat
delays := delays + 1;
Delay(5);
Car.SecondaryController;
Until delays = 4;
Until (TimeMessage3 = 40);
If (TimeMessage3 = 40) Then
Begin
TimeMessage3 := 0;
GotoXY(65,29);
TextColor(LightRed); Write('YOU MUST DIE!!!');
Repeat
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.x := PCar.Enemy.x - 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Delay(10);
Car.SecondaryController;
Until (PCar.Enemy.x = 6) Or (Game.CheckLose2 = True);
Delay(50);
If (Game.CheckLose2 = False) Then
Begin
GotoXY(65,29);
TextColor(Black); Write(#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
Repeat
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.x := PCar.Enemy.x + 1;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(35);
Until (PCar.Enemy.x = m) Or (Game.CheckLose2 = True);
End;
End;
End;
Boss := False;
If (Boss = False) Then
Game.BulletAvailable;
End;
Procedure TCar.BossDestroyed;
Begin
GotoXY(PCar.Enemy.x+Random(8),PCar.Enemy.y-2+Random(5));
TextColor(Black);
Write(#32);
End;
Procedure TCar.DrawEnemyBossCar(x,y: Byte);
Begin
//The Middle Of Boss(x,y)
GotoXY(PCar.Enemy.x-4,PCar.Enemy.y);
TextColor(LightRed); Write(#205#205#216);
GotoXY(PCar.Enemy.x-1,PCar.Enemy.y);
TextColor(LightBlue); Write(#219#219#219#219);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y);
TextColor(White); Write(#254#254);
GotoXY(PCar.Enemy.x+5,PCar.Enemy.y);
TextColor(LightBlue); Write(#219);
//The side of boss(x,y-1)
GotoXY(PCar.Enemy.x,PCar.Enemy.y-1);
TextColor(LightBlue); Write(#219#219);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y-1);
TextColor(White); Write(#254);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y-1);
TextColor(LightBlue); Write(#219#219#185);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y-2);
TextColor(Cyan); Write(#219#219#219#219#219);
GotoXY(PCar.Enemy.x+1,PCar.Enemy.y-2);
TextColor(LightBlue); Write(#201);
//The side of boss(x,y+!)
GotoXY(PCar.Enemy.x,PCar.Enemy.y+1);
TextColor(LightBlue); Write(#219#219);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y+1);
TextColor(White); Write(#254);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y+1);
TextColor(LightBlue); Write(#219#219#185);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y+2);
TextColor(Cyan); Write(#219#219#219#219#219);
GotoXY(PCar.Enemy.x+1,PCar.Enemy.y+2);
TextColor(LightBlue); Write(#200);
//The two short gun(x,y+1), (x,y-1);
GotoXY(PCar.Enemy.x-2,PCar.Enemy.y-1);
TextColor(Yellow); Write(#205#205);
GotoXY(PCar.Enemy.x-2,PCar.Enemy.y+1);
Write(#205#205);
//The Main Object Of Boss
GotoXY(PCar.Enemy.x,PCar.Enemy.y);
TextColor(LightRed+Blink); Write(#219);
End;
Procedure TCar.RemoveEnemyBossCar(x,y: Byte);
Begin
//The Middle Of Boss(x,y)
GotoXY(PCar.Enemy.x-4,PCar.Enemy.y); Write(#32#32#32);
GotoXY(PCar.Enemy.x-1,PCar.Enemy.y); Write(#32#32#32#32);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y); Write(#32#32);
GotoXY(PCar.Enemy.x+5,PCar.Enemy.y); Write(#32);
//The side of boss(x,y-1)
GotoXY(PCar.Enemy.x,PCar.Enemy.y-1); Write(#32#32);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y-1); Write(#32);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y-1); Write(#32#32#32);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y-2); Write(#32#32#32#32#32);
GotoXY(PCar.Enemy.x+1,PCar.Enemy.y-2); Write(#32);
//The side of boss(x,y+!)
GotoXY(PCar.Enemy.x,PCar.Enemy.y+1); Write(#32#32);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y+1); Write(#32);
GotoXY(PCar.Enemy.x+3,PCar.Enemy.y+1); Write(#32#32#32);
GotoXY(PCar.Enemy.x+2,PCar.Enemy.y+2); Write(#32#32#32#32#32);
GotoXY(PCar.Enemy.x+1,PCar.Enemy.y+2); Write(#32);
//The two short gun(x,y+1), (x,y-1);
GotoXY(PCar.Enemy.x-2,PCar.Enemy.y-1); Write(#32#32);
GotoXY(PCar.Enemy.x-2,PCar.Enemy.y+1); Write(#32#32);
End;
Procedure TCar.Case1Shooting;
Begin
Boss := True;
If (Boss = True) Then
Game.BulletUnavailable;
Bullet.Enemy[3].x := PCar.Enemy.x - 5;
Bullet.Enemy[3].y := PCar.Enemy.y;
Repeat
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#32#32);
Bullet.Enemy[3].x := Bullet.Enemy[3].x - 1;
TextColor(LightGreen);
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#17#205);
Car.SecondaryController;
Delay(20);
Moving := Random(20);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Until ((Bullet.Enemy[3].x = 2) Or Game.CheckLose1 = True);
If (Bullet.Enemy[3].x = 2) Then
Begin
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#32);
GotoXY(Bullet.Enemy[3].x+1,Bullet.Enemy[3].y); Write(#32);
End;
Boss := False;
If (Boss = False) Then
Game.BulletAvailable;
End;
Procedure TCar.Case2Shooting;
Begin
Boss := True;
If (Boss = True) Then
Game.BulletUnavailable;
Bullet.Enemy[1].x := PCar.Enemy.x - 3;
Bullet.Enemy[1].y := PCar.Enemy.y - 1;
Bullet.Enemy[2].x := PCar.Enemy.x - 3;
Bullet.Enemy[2].y := PCar.Enemy.y + 1;
Repeat
Randomize;
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#32);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#32);
Bullet.Enemy[1].x := Bullet.Enemy[1].x - 1;
Bullet.Enemy[2].x := Bullet.Enemy[2].x - 1;
TextColor(Yellow);
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#174);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#174);
Car.SecondaryController;
Delay(30);
Moving := Random(20);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Until (((Bullet.Enemy[1].x = 2) And (Bullet.Enemy[2].x = 2)) Or Game.CheckLose1 = True);
If ((Bullet.Enemy[1].x = 2) And (Bullet.Enemy[2].x = 2)) Then
Begin
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#32);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#32);
End;
Boss := False;
If (Boss = False) Then
Game.BulletAvailable;
End;
Procedure TCar.Case3Shooting;
Begin
Boss := True;
If (Boss = True) Then
Game.BulletUnavailable;
Bullet.Enemy[1].x := PCar.Enemy.x - 3;
Bullet.Enemy[1].y := PCar.Enemy.y - 1;
Bullet.Enemy[2].x := PCar.Enemy.x - 3;
Bullet.Enemy[2].y := PCar.Enemy.y + 1;
Bullet.Enemy[3].x := PCar.Enemy.x - 5;
Bullet.Enemy[3].y := PCar.Enemy.y;
Repeat
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#32);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#32);
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#32#32);
Bullet.Enemy[1].x := Bullet.Enemy[1].x - 1;
Bullet.Enemy[2].x := Bullet.Enemy[2].x - 1;
Bullet.Enemy[3].x := Bullet.Enemy[3].x - 1;
TextColor(Yellow);
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#174);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#174);
TextColor(LightGreen);
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#17#205);
Car.SecondaryController;
Delay(30);
Moving := Random(20);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Until ((((Bullet.Enemy[1].x = 2) And (Bullet.Enemy[2].x = 2)) Or (Bullet.Enemy[3].x = 2)) Or Game.CheckLose1 = True);
If (((Bullet.Enemy[1].x = 2) And (Bullet.Enemy[2].x = 2)) Or (Bullet.Enemy[3].x = 2)) Then
Begin
GotoXY(Bullet.Enemy[1].x,Bullet.Enemy[1].y); Write(#32);
GotoXY(Bullet.Enemy[2].x,Bullet.Enemy[2].y); Write(#32);
GotoXY(Bullet.Enemy[3].x,Bullet.Enemy[3].y); Write(#32);
GotoXY(Bullet.Enemy[3].x+1,Bullet.Enemy[3].y); Write(#32);
End;
Boss := False;
If (Boss = False) Then
Game.BulletAvailable;
End;
Procedure TCar.EnemyBossCarShooting;
Begin
Randomize;
TypeBullet := Random(3);
Case TypeBullet Of
0: Car.Case1Shooting;
1: Car.Case2Shooting;
2: Car.Case3Shooting;
End;
End;
Procedure TCar.EnemyBossCarMoving;
Begin
//Boss Moves Down
If (PCar.Enemy.y < PCar.Army.y) Then
Repeat
If (PCar.Enemy.y = 25) Then Break;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.y := PCar.Enemy.y + 1;
If (PCar.Enemy.x > 50) Then
PCar.Enemy.x := PCar.Enemy.x - Random(2);
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(30);
Until ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 25));
//Boss Moves Up
If (PCar.Enemy.y > PCar.Army.y) Then
Repeat
If (PCar.Enemy.y = 5) Then Break;
TextColor(Black);
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
PCar.Enemy.y := PCar.Enemy.y - 1;
If (PCar.Enemy.x+7 < 80) Then
PCar.Enemy.x := PCar.Enemy.x + Random(2);
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
TextColor(Black);
Car.SecondaryController;
Delay(30);
Until ((PCar.Enemy.y = PCar.Army.y) Or (PCar.Enemy.y = 5));
End;
Procedure TCar.DrawArmyCar(x,y: Byte);
Begin
TextColor(Cyan);
GotoXY(PCar.Army.x+1,PCar.Army.y-1); Write(#111#32#111);
TextColor(LightGreen);
GotoXY(PCar.Army.x,PCar.Army.y); Write(#195#219#219#219);
TextColor(LightRed);
GotoXY(PCar.Army.x+4,PCar.Army.y); Write(#205);
TextColor(Cyan);
GotoXY(PCar.Army.x+1,PCar.Army.y+1); Write(#111#32#111);
End;
Procedure TCar.RemoveArmyCar(x,y: Byte);
Begin
TextColor(Black);
GotoXY(PCar.Army.x+1,PCar.Army.y-1); Write(#32#32#32);
GotoXY(PCar.Army.x,PCar.Army.y); Write(#32#32#32#32#32);
GotoXY(PCar.Army.x+4,PCar.Army.y); Write(#32);
GotoXY(PCar.Army.x+1,PCar.Army.y+1); Write(#32#32#32);
End;
Procedure TCar.ArmyCarMoveRight;
Begin
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.x < 35) Then
PCar.Army.x := PCar.Army.x + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
End;
Procedure TCar.ArmyCarMoveLeft;
Begin
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.x > 4) Then
PCar.Army.x := PCar.Army.x - 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
End;
Procedure TCar.ArmyCarMoveUp;
Begin
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.y > 4) Then
PCar.Army.y := PCar.Army.y - 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
End;
Procedure TCar.ArmyCarMoveDown;
Begin
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
If (PCar.Army.x < 26) Then
PCar.Army.y := PCar.Army.y + 1;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
End;
Procedure TCar.ArmyCarShootingTheBullet;
Begin
Randomize;
Time := 0;
If (Time = 0) Then
Game.BulletUnavailable;
Bullet.Army.x := PCar.Army.x + 5;
Bullet.Army.y := PCar.Army.y;
Repeat
Randomize;
GotoXY(Bullet.Army.x,Bullet.Army.y); Write(#32);
Bullet.Army.x := Bullet.Army.x + 1;
TextColor(Yellow);
GotoXY(Bullet.Army.x,Bullet.Army.y); Write(#175);
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(35);
Until ((Bullet.Army.x = 80) Or (Game.CheckHitTheBoss = True));
If (Bullet.Army.x = 80) Then
Begin
GotoXY(Bullet.Army.x,Bullet.Army.y);
Write(#32);
End;
If (Game.CheckHitTheBoss = True) Then
Begin
Heart := Heart - 1;
GotoXY(72,1); Write(#32#32);
TextColor(White);
GotoXY(72,1); Write(Heart);
GotoXY(Bullet.Army.x,Bullet.Army.y);
TextBackGround(Yellow); Write(#32);
Messages1 := Random(3);
TextBackGround(Black);
If ((Messages1 = 0) And (Heart > 1)) Then
Repeat
GotoXY(65,29);
TextColor(White); Write('GOOD! Haha!');
TimeMessages1 := TimeMessages1 + 1;
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(25);
Until (TimeMessages1 = 25)
Else If ((Messages1 = 1) And (Heart > 1)) Then
Repeat
GotoXY(65,29);
TextColor(Yellow); Write('Ahhh...!!');
TimeMessages1 := TimeMessages1 + 1;
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(25);
Until (TimeMessages1 = 25)
Else If ((Messages1 = 2) And (Heart > 1)) Then
Repeat
GotoXY(65,29);
TextColor(LightRed); Write('Kill me..!?');
TimeMessages1 := TimeMessages1 + 1;
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(25);
Until (TimeMessages1 = 25);
Delay(50);
TextBackGround(Black);
GotoXY(Bullet.Army.x,Bullet.Army.y); Write(#32);
TextBackGround(Black);
If (TimeMessages1 = 25) Then
Repeat
TimeMessages1 := TimeMessages1 - 1;
Car.SecondaryController;
Moving := Random(30);
If (Moving = 1) Then
Car.EnemyBossCarMoving;
Delay(25);
Until (TimeMessages1 = 0);
If (TimeMessages1 = 0) Then
GotoXY(65,29); Write(#32#32#32#32#32#32#32#32#32#32#32);
End;
End;
Procedure TCar.MainController;
Begin
If KeyPressed And (Game.CheckLose2 = False) Then
Case ReadKey Of
R: If (PCar.Army.x < 35) Then Car.ArmyCarMoveRight;
L: If (PCar.Army.x > 4) Then Car.ArmyCarMoveLeft;
U: If (PCar.Army.y > 4) Then Car.ArmyCarMoveUp;
D: If (PCar.Army.y < 26) Then Car.ArmyCarMoveDown;
Space: If (Boss = False) And (Time = 10) Then Car.ArmyCarShootingTheBullet;
#27: Halt;
End;
End;
Procedure TCar.SecondaryController;
Begin
If KeyPressed And (Game.CheckLose2 = False) Then
Case ReadKey Of
R: If (PCar.Army.x < 35) Then Car.ArmyCarMoveRight;
L: If (PCar.Army.x > 4) Then Car.ArmyCarMoveLeft;
U: If (PCar.Army.y > 4) Then Car.ArmyCarMoveUp;
D: If (PCar.Army.y < 26) Then Car.ArmyCarMoveDown;
#27: Halt;
End;
End;
Procedure TGame.Start;
Begin
Randomize;
TextBackGround(Black);
ClrScr;
Heart := 10 + Random(11);
TimeMessages1 := 1;
TimeMessage3 := 1;
TimeScence := 0;
Game.TheMapOfGame;
PCar.Army.x := 15;
PCar.Army.y := 15;
Car.DrawArmyCar(PCar.Army.x,PCar.Army.y);
PCar.Enemy.x := 55;
PCar.Enemy.y := 15;
Car.DrawEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
For i := 1 To 3 Do
Begin
Bullet.Enemy.x := 0;
Bullet.Enemy.y := 0;
End;
ShootingBullet := 0;
Boss := False;
Time := 10;
delays := 1;
End;
Procedure TGame.PlayingTheGame;
Begin
Randomize;
Game.Start;
While ((Game.CheckLose1 = False) And (Game.CheckWin = False) And (Game.CheckLose2 = False)) Do
Begin
Randomize;
TextColor(Black);
Car.MainController;
Delay(30);
Moving := Random(30);
Func := Random(2);
If (Moving = 3) Then
Begin
Case Func Of
0: Car.EnemyBossCarMoving;
1: Car.BossScanning;
End;
End;
If (ShootingBullet = 10) Then
Begin
Car.EnemyBossCarShooting;
ShootingBullet := 0;
End;
ShootingBullet := ShootingBullet + 1;
If (Time < 10) Then
Time := Time + 1;
End;
If ((Game.CheckLose1 = True) Or (Game.CheckLose2 = True)) Then
Begin
GotoXY(60,29);
TextColor(LightRed); Write('HAHA..!You idiot!!');
Car.RemoveArmyCar(PCar.Army.x,PCar.Army.y);
Delay(750);
Game.ScenceOfGame;
TextBackGround(Black);
ClrScr;
Game.Lose;
Repeat
If Keypressed Then
Begin
GetInput := Readkey;
If (GetInput=#82) Or (GetInput=#114) Then
Begin
Game.ScenceOfGame;
ClrScr;
Game.PlayingTheGame;
End
Else If (GetInput=#27) Then
Begin
While Keypressed Do
Readkey;
Halt;
End;
End;
Until False;
End
Else If (Game.CheckWin = True) Then
Begin
GotoXY(65,29);
TextColor(LightCyan); Write('NO WAY!! Ahh...!');
Delay(750);
For i := 1 To 20 Do
Begin
Randomize;
Car.BossDestroyed;
Car.BossDestroyed;
Car.BossDestroyed;
Delay(100);
End;
Car.RemoveEnemyBossCar(PCar.Enemy.x,PCar.Enemy.y);
Delay(1200);
Game.ScenceOfArmyTank;
Game.ScenceOfGame;
TextBackGround(Black);
ClrScr;
Game.Win;
Repeat
If Keypressed Then
Begin
GetInput := Readkey;
If (GetInput=#78) Or (GetInput=#110) Then
Begin
Game.ScenceOfGame;
ClrScr;
Game.PlayingTheGame
End
Else If (GetInput=#27) Then
Begin
While Keypressed Do
Readkey;
Halt;
End;
End;
Until False;
End;
End;
//==================================THE MAIN PROGRAMME========================================
Begin
TextBackGround(Black);
ClrScr;
Game.Interfaces;
Repeat
Key := Readkey;
If (Key = #13) And (Arrow.x = 30) And (Arrow.y = 15) Then
Begin
Game.ScenceOfGame;
Clrscr;
Game.Instruction;
End;
Until (Key = #13) And (Arrow.x = 30) And (Arrow.y = 13);
If (Key = #13) And (Arrow.x = 30) And (Arrow.y = 13) Then
Begin
Game.ScenceOfGame;
Clrscr;
Game.TheMapOfGame;
Game.PlayingTheGame;
End;
Readln;
End.
Last edited: