Tin học THÀNH QUẢ SAU 1 THÁNG HỌC PASCAL Ạ!

HauBright

Học sinh mới
20 Tháng tư 2023
72
36
11
14
Bến Tre
[TẶNG BẠN] TRỌN BỘ Bí kíp học tốt 08 môn
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.
 
Last edited:

dangxuanchuon

Học sinh
Thành viên
31 Tháng bảy 2022
69
39
36
Phú Yên
game này chơi sao (không biết cách chơi)
 

HauBright

Học sinh mới
20 Tháng tư 2023
72
36
11
14
Bến Tre
Cách chơi:
- Mũi tên lên để xe tăng di chuyển lên.
- Mũi tên xuống để xe tăng di chuyển xuống.
- Bắn hạ số lương kẻ địch tương đương với nhiệm vụ ở góc dưới bên trái màn hình là thắng game.
- Bắn hết số đạn mà kẻ địch vẫn còn thì thua game.
- Nhấn R để chơi lại.
- Nhấn Esc để thoát chương trình.

Cảm ơn các bạn đã dùng thời gian của mình để vào game này của mình ạ!!! <3
 
Last edited:

colalake

Học sinh mới
Thành viên
18 Tháng mười 2022
7
5
6
16
Đồng Nai
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.
HauBrightĐỉnh vậy, cái này bỏ vô pascal là đc đúm hem
 

HauBright

Học sinh mới
20 Tháng tư 2023
72
36
11
14
Bến Tre
View previous replies…

HauBright

Học sinh mới
20 Tháng tư 2023
72
36
11
14
Bến Tre
Cho những bạn nào cần để làm một game xe tăng:
- Đầu tiên tạo chương trình con (Procedure) đơn giản cho xe tăng và kẻ địch:
+ Xe tăng: gồm chương trình "tạo hình ảnh xe tăng" và chương trình "xóa hình ảnh xe tăng".
+ Kẻ địch: gồm chương trình "tạo hình ảnh kẻ địch" và chương trình "xóa hình ảnh kẻ địch".
- Tiếp theo viết các chương trình con (Procedure) để xe tăng di chuyển (đi lên, đi xuống) {Trong chương trình con này gồm cả chương trình con "tạo hình ánh xe tăng" và "xóa hình ảnh xe tăng} => ý tưởng ở đây là khi di chuyển xe tăng một hướng nào đó, chương trình sẽ xóa hình ảnh xe tăng ở vị trí cũ và in ra ở vị trí mới.
- Sau đó nhóm các chương trình con trên vào chương trình chính và cho nó lặp lại vô hạn (sử dụng While 1=1 do . . . ).
- Tạo một chương trình con cho hoạt ảnh bay của viên đan khi bắn ra từ xe tăng và cho nó vào chương trình chính cùng với code di chuyển xe tăng lên xuống =)).
- Tiếp đến tạo 3 hàm (Function):
+ Function 1: dùng để kiểm tra xem vị trí x,y của viên đạn có bằng với vị trí x,y của kẻ địch hay không.
+ Function 2: kiểm tra điều kiện gì sẽ thắng.
+ Function 2: kiểm tra điều kiện gì sẽ thua.
- Tạo Map cho game.
- Khởi tạo vị trí của xe tăng và kẻ địch ở vị trí ngâu nhiên trên phạm vi nào đó của Map.
- Chỉnh sửa lại chương trình nếu cần thiết.
{Lưu ý: trong quá trình làm game phải cho vài dòng comment như: // ; (* ; { để dễ hình dung, không bị rối}

Mong các bạn một ngày nào đó sẽ làm được một game tuyệt đỉnh của mình !!!
 

Sói_Đơn_Độc

Học sinh mới
19 Tháng năm 2023
5
1
6
14
Bến Tre
Cho những bạn nào cần để làm một game xe tăng:
- Đầu tiên tạo chương trình con (Procedure) đơn giản cho xe tăng và kẻ địch:
+ Xe tăng: gồm chương trình "tạo hình ảnh xe tăng" và chương trình "xóa hình ảnh xe tăng".
+ Kẻ địch: gồm chương trình "tạo hình ảnh kẻ địch" và chương trình "xóa hình ảnh kẻ địch".
- Tiếp theo viết các chương trình con (Procedure) để xe tăng di chuyển (đi lên, đi xuống) {Trong chương trình con này gồm cả chương trình con "tạo hình ánh xe tăng" và "xóa hình ảnh xe tăng} => ý tưởng ở đây là khi di chuyển xe tăng một hướng nào đó, chương trình sẽ xóa hình ảnh xe tăng ở vị trí cũ và in ra ở vị trí mới.
- Sau đó nhóm các chương trình con trên vào chương trình chính và cho nó lặp lại vô hạn (sử dụng While 1=1 do . . . ).
- Tạo một chương trình con cho hoạt ảnh bay của viên đan khi bắn ra từ xe tăng và cho nó vào chương trình chính cùng với code di chuyển xe tăng lên xuống =)).
- Tiếp đến tạo 3 hàm (Function):
+ Function 1: dùng để kiểm tra xem vị trí x,y của viên đạn có bằng với vị trí x,y của kẻ địch hay không.
+ Function 2: kiểm tra điều kiện gì sẽ thắng.
+ Function 2: kiểm tra điều kiện gì sẽ thua.
- Tạo Map cho game.
- Khởi tạo vị trí của xe tăng và kẻ địch ở vị trí ngâu nhiên trên phạm vi nào đó của Map.
- Chỉnh sửa lại chương trình nếu cần thiết.
{Lưu ý: trong quá trình làm game phải cho vài dòng comment như: // ; (* ; { để dễ hình dung, không bị rối}

Mong các bạn một ngày nào đó sẽ làm được một game tuyệt đỉnh của mình !!!
HauBrightkkk Cảm ơn cậu :>
 
Top Bottom