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 THE_TANK;
Uses Crt;
Var
tank: Record
x: Byte;
y: Byte;
End;
bullet: Record
x: Byte;
y: Byte;
End;
enemy: Record
x: Byte;
y: Byte;
End;
i,j: Byte;
KEY: Char;
Score: Integer;
Target: Integer;
NumberOfBullet: Integer;
m: Char;
Spawm_Enemy: Byte;
//====================================================
Function CheckEnemy(x,y: Byte): Boolean;
Begin
If (bullet.x = enemy.x+1) And (bullet.y = enemy.y) Then CheckEnemy := True
Else CheckEnemy := False;
End;
Function CheckWin(Score,Target: Integer): Boolean;
Begin
If (Score=Target) Then ChecKWin := True
Else CheckWin := False;
End;
Function CheckLose(Score,Target,NumberOfBullet: Integer): Boolean;
Begin
If (Score<Target) And (NumberOfBullet=0) Then CheckLose := True
Else CheckLose := False;
End;
//====================FUNCTION OF CHECK================================
Procedure INTRODUCTION;
Begin
TextColor(White);
GotoXY(35,13); WriteLn('MADE BY ');
TextColor(LightRed);
GotoXY(40,15); WriteLn(#15,' PASCAL XE ',#15);
End;
//==============THE INTRODUCTION UHEN BEGIN THE PROGRAM===============
Procedure FITISSUE;
Begin
For i:=1 To 10 Do
Begin
TextColor(White);
GotoXY(i,2); WriteLn(#205);
GotoXY(i,28); WriteLn(#205);
End;
End;
//=================FIT THE ISSUE=================
Procedure 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); //The License
Textcolor(LightGreen);
Gotoxy(36,17); Writeln(#15#198#194#249,#32#32#32#32);
Gotoxy(36,18); Writeln(#15#179#178#216#205#205#205);
Gotoxy(36,19); Writeln(#15#198#193#249,#32#32#32#32);
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;
Repeat
GotoXY(25,14);
TextColor(White);
WriteLn('PRESS ANY KEY TO START THE GAME!');
Delay(100);
GotoXY(25,14);
WriteLn(#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32,
#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
Delay(100);
Until KeyPressed;
End;
//===============THE INTERFACE===============
Procedure DRAW_ENEMY_1(x,y: Byte);
Begin
TextColor(LightRed);
GotoXY(enemy.x,enemy.y); Write('=');
TextColor(Yellow);
GotoXY(enemy.x+2,enemy.y); Write('[]');
TextColor(White);
GotoXY(enemy.x+1,enemy.y); Write(':');
End;
//================DRAW THE ENEMY V1================
Procedure DRAW_ENEMY_2(x,y: Byte);
Begin
TextColor(LightRed);
GotoXY(enemy.x,enemy.y); Write('=');
TextColor(Yellow);
GotoXY(enemy.x+2,enemy.y); Write('( )');
TextColor(White);
GotoXY(enemy.x+1,enemy.y); Write(':');
TextColor(LightRed);
GotoXY(enemy.x+3,enemy.y); Write('#');
End;
//================DRAW THE ENEMY V2================
Procedure DRAW_ENEMY_3(x,y: Byte);
Begin
TextColor(LightRed);
GotoXY(enemy.x,enemy.y); Write('=');
TextColor(LightBlue);
GotoXY(enemy.x+1,enemy.y); Write(':');
TextColor(Yellow);
GotoXY(enemy.x+2,enemy.y); Write(' }');
TextColor(Yellow);
GotoXY(enemy.x+2,enemy.y); Write('{');
TextColor(LightRed);
GotoXY(enemy.x+3,enemy.y); Write('@');
End;
//================DRAW THE ENEMY V3================
Procedure MOVE_ENEMY(x,y: Byte);
Begin
GotoXY(enemy.x,enemy.y); Write(#32#32#32#32#32);
End;
//===============ERASE THE ENEMY BEFORE===============
Procedure MAP;
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);
TextColor(Yellow); WriteLn(#15#32,'WELOCOME TO TANK GAME',#32#15);
GotoXY(2,1); TextColor(LightGreen);
WriteLn('Esc: EXIT');
GotoXY(65,1); WriteLn('FULL ENERGY');
GotoXY(63,1); WriteLn(#3);
TextColor(White);
GotoXY(64,2); WriteLn(#207);
GotoXY(76,2); WriteLn(#207);
GotoXY(64,1); WriteLn(#179);
GotoXY(76,1); WriteLn(#179);
Randomize;
Target := Random(20);
If (Target<7) Then
Repeat
Target := Target + Random(10);
Until Target>7;
TextColor(LightGreen);
GotoXY(1,29); Write('TARGET:',#32,'0 /',Target);
NumberOfBullet := Target + Random(5);
GotoXY(25,29); TextColor(Yellow); Write(#175);
GotoXY(26,29); TextColor(LightBlue); Write(#32,':',#32,NumberOfBullet);
End;
//===============THE MAP===============
Procedure DRAW_TANK(x,y: Byte);
//Ve hình anh cua xe tâng
Begin
Textcolor(LightGreen);
Gotoxy(x,y); Writeln(#15#198#194#249,#32#32#32#32);
Gotoxy(x,y+1); Writeln(#15#179#178#216#205#205#205);
Gotoxy(x,y+2); Writeln(#15#198#193#249,#32#32#32#32);
End;
//===============DRAW THE TANK===============
Procedure MOVE_TANK(x,y: Byte);
//Xóa hoat anh cua xe tâng hiên tai
Begin
Gotoxy(x,y); Write(#32#32#32#32#32#32#32#32#32);
Gotoxy(x,y+1); Write(#32#32#32#32#32#32#32#32#32);
Gotoxy(x,y+2); Write(#32#32#32#32#32#32#32#32#32);
End;
//===============ERASE THE TANK BEFORE===============
Procedure FIRE_BULLET;
Begin
bullet.x := 9;
bullet.y := tank.y + 1;
NumberOfBullet := NumberOfBullet - 1;
TextColor(LightBlue);
GotoXY(29,29); Write(NumberOfBullet,#32);
Repeat
Gotoxy(bullet.x,bullet.y);
Textcolor(Yellow); Write(#175);
Delay(25);
Gotoxy(bullet.x,bullet.y); Write(#32#32);
bullet.x := bullet.x + 1;
GotoXY(5,29);
TextColor(Yellow);
GotoXY(55,29); Write('..LOADING THE BULLET..');
TextColor(LightRed);
GotoXY(65,1); Write(' NO ENEGRY ');
GotoXY(tank.x,tank.y); WriteLn(#15);
GotoXY(tank.x,tank.y+1); WriteLn(#15);
GotoXY(tank.x,tank.y+2); WriteLn(#15);
GotoXY(tank.x+5,tank.y+1); WriteLn(#205);
GotoXY(tank.x+6,tank.y+1); WriteLn(#205);
TextColor(Yellow);
GotoXY(tank.x+2,tank.y+1); WriteLn(#178);
TextColor(LightRed);
GotoXY(tank.x+3,tank.y); WriteLn(#249);
GotoXY(tank.x+3,tank.y+2); WriteLn(#249);
GotoXY(63,1); WriteLn(#3);
If (bullet.x=80) Or CheckEnemy(enemy.x,enemy.y)=True Then
Begin
GotoXY(55,29); WriteLn(#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(65,1); WriteLn('FULL ENERGY');
GotoXY(tank.x,tank.y); WriteLn(#15);
GotoXY(tank.x,tank.y+1); WriteLn(#15);
GotoXY(tank.x,tank.y+2); WriteLn(#15);
GotoXY(tank.x+5,tank.y+1); WriteLn(#205);
GotoXY(tank.x+6,tank.y+1); WriteLn(#205);
GotoXY(tank.x+2,tank.y+1); WriteLn(#178);
GotoXY(tank.x+3,tank.y); WriteLn(#249);
GotoXY(tank.x+3,tank.y+2); WriteLn(#249);
GotoXY(63,1); WriteLn(#3);
End;
If (bullet.x=80) Then Break;
Until CheckEnemy(enemy.x,enemy.y)=True;
If CheckEnemy(enemy.x,enemy.y)=True Then
Begin
Randomize;
MOVE_ENEMY(enemy.x,enemy.y);
Spawm_Enemy := Random(3);
enemy.x := Random(80);
enemy.y := Random(26);
If (enemy.x>75) Then
Repeat
enemy.x := enemy.x + Random(3);
Until enemy.x<75;
If (enemy.x<30) Then
Repeat
enemy.x := enemy.x + Random(20);
Until enemy.x>30;
If (enemy.y<4) Then
Repeat
enemy.y := enemy.y + Random(8);
Until enemy.y>4;
Delay(300);
Case Spawm_Enemy Of
0: DRAW_ENEMY_1(enemy.x,enemy.y);
1: DRAW_ENEMY_2(enemy.x,enemy.y);
2: DRAW_ENEMY_3(enemy.x,enemy.y);
End;
Score := Score + 1;
GotoXY(9,29);
TextColor(LightGreen); Write(Score);
End;
End;
//===============THE ANIMATION FOR THE BULLET=============
Procedure DOWN;
Begin
MOVE_TANK(tank.x,tank.y-1);
tank.y := tank.y+1;
DRAW_TANK(tank.x,tank.y);
End;
//===============MOVE UP===============
Procedure UP;
Begin
MOVE_TANK(tank.x,tank.y+1);
tank.y := tank.y-1;
DRAW_TANK(tank.x,tank.y);
End;
//===============MOVE DOWN===============
{===========|==========|==========|======FOR THE TANK=======|===========|==========|========}
Procedure 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 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;
//======================THE END OF GAME=================
Procedure PLAY;
Begin
ClrScr;
MAP;
DRAW_TANK(2,14);
tank.x := 2;
tank.y := 14;
Randomize;
enemy.x := Random(80);
enemy.y := Random(26);
Spawm_Enemy := Random(3);
If (enemy.x>75) Then
Repeat
enemy.x := enemy.x + Random(3);
Until enemy.x<75;
If (enemy.x<30) Then
Repeat
enemy.x := enemy.x + Random(20);
Until enemy.x>30;
If (enemy.y<4) Then
Repeat
enemy.y := enemy.y + Random(8);
Until enemy.y>4;
Delay(500);
TextColor(LightRed);
Case Spawm_Enemy Of
0: DRAW_ENEMY_1(enemy.x,enemy.y);
1: DRAW_ENEMY_2(enemy.x,enemy.y);
2: DRAW_ENEMY_3(enemy.x,enemy.y);
End;
Score := 0;
Repeat
If KeyPressed Then
Case ReadKey Of
#80: If (tank.y<25) Then DOWN;
#72: If (tank.y>3) Then UP;
#32: FIRE_BULLET;
#27: Exit;
End;
FITISSUE;
Until (CheckWin(Score,Target)=True) Or (CheckLose(Score,Target,NumberOfBullet)=True);
If (CheckWin(Score,Target)=True) Then
Begin
MOVE_ENEMY(enemy.x,enemy.y);
WIN;
Repeat
If KeyPressed Then
Begin
m := ReadKey;
If (m=#78) Or (m=#110) Then
PLAY
Else if m = #27 Then
Begin
While KeyPressed Do ReadKey;
Halt;
End;
End;
Until False;
End;
If (CheckLose(Score,Target,NumberOfBullet)=True) Then
Begin
LOSE;
Repeat
If KeyPressed Then
Begin
m := ReadKey;
If (m=#82) Or (m=#114) Then
PLAY
Else if m = #27 Then
Begin
While KeyPressed Do ReadKey;
Halt;
End;
End;
Until False;
End;
End;
//*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=|THE MAIN PROGRAM|=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Begin
TextBackGround(Black);
ClrScr;
INTRODUCTION;
Delay(1500);
ClrScr;
INTERFACES;
If KeyPressed Then
Delay(10);
PLAY;
End.
Uses Crt;
Var
tank: Record
x: Byte;
y: Byte;
End;
bullet: Record
x: Byte;
y: Byte;
End;
enemy: Record
x: Byte;
y: Byte;
End;
i,j: Byte;
KEY: Char;
Score: Integer;
Target: Integer;
NumberOfBullet: Integer;
m: Char;
Spawm_Enemy: Byte;
//====================================================
Function CheckEnemy(x,y: Byte): Boolean;
Begin
If (bullet.x = enemy.x+1) And (bullet.y = enemy.y) Then CheckEnemy := True
Else CheckEnemy := False;
End;
Function CheckWin(Score,Target: Integer): Boolean;
Begin
If (Score=Target) Then ChecKWin := True
Else CheckWin := False;
End;
Function CheckLose(Score,Target,NumberOfBullet: Integer): Boolean;
Begin
If (Score<Target) And (NumberOfBullet=0) Then CheckLose := True
Else CheckLose := False;
End;
//====================FUNCTION OF CHECK================================
Procedure INTRODUCTION;
Begin
TextColor(White);
GotoXY(35,13); WriteLn('MADE BY ');
TextColor(LightRed);
GotoXY(40,15); WriteLn(#15,' PASCAL XE ',#15);
End;
//==============THE INTRODUCTION UHEN BEGIN THE PROGRAM===============
Procedure FITISSUE;
Begin
For i:=1 To 10 Do
Begin
TextColor(White);
GotoXY(i,2); WriteLn(#205);
GotoXY(i,28); WriteLn(#205);
End;
End;
//=================FIT THE ISSUE=================
Procedure 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); //The License
Textcolor(LightGreen);
Gotoxy(36,17); Writeln(#15#198#194#249,#32#32#32#32);
Gotoxy(36,18); Writeln(#15#179#178#216#205#205#205);
Gotoxy(36,19); Writeln(#15#198#193#249,#32#32#32#32);
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;
Repeat
GotoXY(25,14);
TextColor(White);
WriteLn('PRESS ANY KEY TO START THE GAME!');
Delay(100);
GotoXY(25,14);
WriteLn(#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32,
#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32#32);
Delay(100);
Until KeyPressed;
End;
//===============THE INTERFACE===============
Procedure DRAW_ENEMY_1(x,y: Byte);
Begin
TextColor(LightRed);
GotoXY(enemy.x,enemy.y); Write('=');
TextColor(Yellow);
GotoXY(enemy.x+2,enemy.y); Write('[]');
TextColor(White);
GotoXY(enemy.x+1,enemy.y); Write(':');
End;
//================DRAW THE ENEMY V1================
Procedure DRAW_ENEMY_2(x,y: Byte);
Begin
TextColor(LightRed);
GotoXY(enemy.x,enemy.y); Write('=');
TextColor(Yellow);
GotoXY(enemy.x+2,enemy.y); Write('( )');
TextColor(White);
GotoXY(enemy.x+1,enemy.y); Write(':');
TextColor(LightRed);
GotoXY(enemy.x+3,enemy.y); Write('#');
End;
//================DRAW THE ENEMY V2================
Procedure DRAW_ENEMY_3(x,y: Byte);
Begin
TextColor(LightRed);
GotoXY(enemy.x,enemy.y); Write('=');
TextColor(LightBlue);
GotoXY(enemy.x+1,enemy.y); Write(':');
TextColor(Yellow);
GotoXY(enemy.x+2,enemy.y); Write(' }');
TextColor(Yellow);
GotoXY(enemy.x+2,enemy.y); Write('{');
TextColor(LightRed);
GotoXY(enemy.x+3,enemy.y); Write('@');
End;
//================DRAW THE ENEMY V3================
Procedure MOVE_ENEMY(x,y: Byte);
Begin
GotoXY(enemy.x,enemy.y); Write(#32#32#32#32#32);
End;
//===============ERASE THE ENEMY BEFORE===============
Procedure MAP;
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);
TextColor(Yellow); WriteLn(#15#32,'WELOCOME TO TANK GAME',#32#15);
GotoXY(2,1); TextColor(LightGreen);
WriteLn('Esc: EXIT');
GotoXY(65,1); WriteLn('FULL ENERGY');
GotoXY(63,1); WriteLn(#3);
TextColor(White);
GotoXY(64,2); WriteLn(#207);
GotoXY(76,2); WriteLn(#207);
GotoXY(64,1); WriteLn(#179);
GotoXY(76,1); WriteLn(#179);
Randomize;
Target := Random(20);
If (Target<7) Then
Repeat
Target := Target + Random(10);
Until Target>7;
TextColor(LightGreen);
GotoXY(1,29); Write('TARGET:',#32,'0 /',Target);
NumberOfBullet := Target + Random(5);
GotoXY(25,29); TextColor(Yellow); Write(#175);
GotoXY(26,29); TextColor(LightBlue); Write(#32,':',#32,NumberOfBullet);
End;
//===============THE MAP===============
Procedure DRAW_TANK(x,y: Byte);
//Ve hình anh cua xe tâng
Begin
Textcolor(LightGreen);
Gotoxy(x,y); Writeln(#15#198#194#249,#32#32#32#32);
Gotoxy(x,y+1); Writeln(#15#179#178#216#205#205#205);
Gotoxy(x,y+2); Writeln(#15#198#193#249,#32#32#32#32);
End;
//===============DRAW THE TANK===============
Procedure MOVE_TANK(x,y: Byte);
//Xóa hoat anh cua xe tâng hiên tai
Begin
Gotoxy(x,y); Write(#32#32#32#32#32#32#32#32#32);
Gotoxy(x,y+1); Write(#32#32#32#32#32#32#32#32#32);
Gotoxy(x,y+2); Write(#32#32#32#32#32#32#32#32#32);
End;
//===============ERASE THE TANK BEFORE===============
Procedure FIRE_BULLET;
Begin
bullet.x := 9;
bullet.y := tank.y + 1;
NumberOfBullet := NumberOfBullet - 1;
TextColor(LightBlue);
GotoXY(29,29); Write(NumberOfBullet,#32);
Repeat
Gotoxy(bullet.x,bullet.y);
Textcolor(Yellow); Write(#175);
Delay(25);
Gotoxy(bullet.x,bullet.y); Write(#32#32);
bullet.x := bullet.x + 1;
GotoXY(5,29);
TextColor(Yellow);
GotoXY(55,29); Write('..LOADING THE BULLET..');
TextColor(LightRed);
GotoXY(65,1); Write(' NO ENEGRY ');
GotoXY(tank.x,tank.y); WriteLn(#15);
GotoXY(tank.x,tank.y+1); WriteLn(#15);
GotoXY(tank.x,tank.y+2); WriteLn(#15);
GotoXY(tank.x+5,tank.y+1); WriteLn(#205);
GotoXY(tank.x+6,tank.y+1); WriteLn(#205);
TextColor(Yellow);
GotoXY(tank.x+2,tank.y+1); WriteLn(#178);
TextColor(LightRed);
GotoXY(tank.x+3,tank.y); WriteLn(#249);
GotoXY(tank.x+3,tank.y+2); WriteLn(#249);
GotoXY(63,1); WriteLn(#3);
If (bullet.x=80) Or CheckEnemy(enemy.x,enemy.y)=True Then
Begin
GotoXY(55,29); WriteLn(#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(65,1); WriteLn('FULL ENERGY');
GotoXY(tank.x,tank.y); WriteLn(#15);
GotoXY(tank.x,tank.y+1); WriteLn(#15);
GotoXY(tank.x,tank.y+2); WriteLn(#15);
GotoXY(tank.x+5,tank.y+1); WriteLn(#205);
GotoXY(tank.x+6,tank.y+1); WriteLn(#205);
GotoXY(tank.x+2,tank.y+1); WriteLn(#178);
GotoXY(tank.x+3,tank.y); WriteLn(#249);
GotoXY(tank.x+3,tank.y+2); WriteLn(#249);
GotoXY(63,1); WriteLn(#3);
End;
If (bullet.x=80) Then Break;
Until CheckEnemy(enemy.x,enemy.y)=True;
If CheckEnemy(enemy.x,enemy.y)=True Then
Begin
Randomize;
MOVE_ENEMY(enemy.x,enemy.y);
Spawm_Enemy := Random(3);
enemy.x := Random(80);
enemy.y := Random(26);
If (enemy.x>75) Then
Repeat
enemy.x := enemy.x + Random(3);
Until enemy.x<75;
If (enemy.x<30) Then
Repeat
enemy.x := enemy.x + Random(20);
Until enemy.x>30;
If (enemy.y<4) Then
Repeat
enemy.y := enemy.y + Random(8);
Until enemy.y>4;
Delay(300);
Case Spawm_Enemy Of
0: DRAW_ENEMY_1(enemy.x,enemy.y);
1: DRAW_ENEMY_2(enemy.x,enemy.y);
2: DRAW_ENEMY_3(enemy.x,enemy.y);
End;
Score := Score + 1;
GotoXY(9,29);
TextColor(LightGreen); Write(Score);
End;
End;
//===============THE ANIMATION FOR THE BULLET=============
Procedure DOWN;
Begin
MOVE_TANK(tank.x,tank.y-1);
tank.y := tank.y+1;
DRAW_TANK(tank.x,tank.y);
End;
//===============MOVE UP===============
Procedure UP;
Begin
MOVE_TANK(tank.x,tank.y+1);
tank.y := tank.y-1;
DRAW_TANK(tank.x,tank.y);
End;
//===============MOVE DOWN===============
{===========|==========|==========|======FOR THE TANK=======|===========|==========|========}
Procedure 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 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;
//======================THE END OF GAME=================
Procedure PLAY;
Begin
ClrScr;
MAP;
DRAW_TANK(2,14);
tank.x := 2;
tank.y := 14;
Randomize;
enemy.x := Random(80);
enemy.y := Random(26);
Spawm_Enemy := Random(3);
If (enemy.x>75) Then
Repeat
enemy.x := enemy.x + Random(3);
Until enemy.x<75;
If (enemy.x<30) Then
Repeat
enemy.x := enemy.x + Random(20);
Until enemy.x>30;
If (enemy.y<4) Then
Repeat
enemy.y := enemy.y + Random(8);
Until enemy.y>4;
Delay(500);
TextColor(LightRed);
Case Spawm_Enemy Of
0: DRAW_ENEMY_1(enemy.x,enemy.y);
1: DRAW_ENEMY_2(enemy.x,enemy.y);
2: DRAW_ENEMY_3(enemy.x,enemy.y);
End;
Score := 0;
Repeat
If KeyPressed Then
Case ReadKey Of
#80: If (tank.y<25) Then DOWN;
#72: If (tank.y>3) Then UP;
#32: FIRE_BULLET;
#27: Exit;
End;
FITISSUE;
Until (CheckWin(Score,Target)=True) Or (CheckLose(Score,Target,NumberOfBullet)=True);
If (CheckWin(Score,Target)=True) Then
Begin
MOVE_ENEMY(enemy.x,enemy.y);
WIN;
Repeat
If KeyPressed Then
Begin
m := ReadKey;
If (m=#78) Or (m=#110) Then
PLAY
Else if m = #27 Then
Begin
While KeyPressed Do ReadKey;
Halt;
End;
End;
Until False;
End;
If (CheckLose(Score,Target,NumberOfBullet)=True) Then
Begin
LOSE;
Repeat
If KeyPressed Then
Begin
m := ReadKey;
If (m=#82) Or (m=#114) Then
PLAY
Else if m = #27 Then
Begin
While KeyPressed Do ReadKey;
Halt;
End;
End;
Until False;
End;
End;
//*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=|THE MAIN PROGRAM|=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Begin
TextBackGround(Black);
ClrScr;
INTRODUCTION;
Delay(1500);
ClrScr;
INTERFACES;
If KeyPressed Then
Delay(10);
PLAY;
End.
Last edited: