Tin học Game siêu chán mik vừa mới làm =)))

HauBright

Học sinh mới
20 Tháng tư 2023
72
36
11
15
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 NO_NAME;
Uses Crt;

Const
WallRight = 80;
WallLeft = 1;
Type
Position = Record
x,y: Integer;
End;
TBullet = Record
x,y: Byte;
ShootingStatus: Boolean;
End;
Var
Tank: Position;
Bullet: TBullet;
CheckDirection: Boolean;

Procedure MapForGame;
Var
i,j : Byte;
Begin
For j := 21 To 29 Do
For i := 1 To 80 Do
Begin
TextColor(White);
GotoXY(i,1);
Write(Chr(178));
Gotoxy(i,j);
Write(Chr(178));
End;
End;

Procedure DrawRightDirectionTank(x,y: Integer);
Begin
CheckDirection := True;
Textcolor(LightGreen);
Gotoxy(Tank.x,Tank.y);
Write(#15#15#15#15#15);
Gotoxy(Tank.x,Tank.y-1);
Write(#95#218#209#198#205#205#205);
Gotoxy(Tank.x,Tank.y-2);
End;

Procedure DrawLeftDirectionTank(x,y: Integer);
Begin
CheckDirection := False;
Textcolor(LightGreen);
Gotoxy(Tank.x,Tank.y);
Write(#15#15#15#15#15);
Gotoxy(Tank.x-2,Tank.y-1);
Write(#205#205#205#198#209#191#95);
Gotoxy(Tank.x-2,Tank.y-2);
End;

Procedure ClearLeftDirectionTank(x,y: Integer);
Begin
Gotoxy(Tank.x,Tank.y);
Write(#32#32#32#32#32);
Gotoxy(Tank.x,Tank.y-1);
Write(#32#32#32#32#32#32#32);
End;
Procedure ClearRightDirectionTank(x,y: Integer);
Begin
Gotoxy(Tank.x,Tank.y);
Write(#32#32#32#32#32);
Gotoxy(Tank.x-2,Tank.y-1);
Write(#32#32#32#32#32#32);
End;

Procedure MoveRight;
Begin
ClearRightDirectionTank(Tank.x,Tank.y);
Tank.x := Tank.x + 1;
DrawRightDirectionTank(Tank.x,Tank.y);
Delay(40);
End;

Procedure MoveLeft;
Begin
ClearLeftDirectionTank(Tank.x,Tank.y);
Tank.x := Tank.x - 1;
DrawLeftDirectionTank(Tank.x,Tank.y);
Delay(40);
End;
Procedure Shooting;
Begin
If (CheckDirection = True) Then
Begin
Bullet.ShootingStatus := True;
Bullet.x := Tank.x + 7;
Bullet.y := Tank.y - 1;
Repeat
TextColor(Yellow);
GotoXY(Bullet.x,Bullet.y);
Write(Chr(175)); Delay(35);
GotoXY(Bullet.x,Bullet.y);
Write(Chr(32));
Bullet.x := Bullet.x + 1;
Until (Bullet.x = WallRight);
Bullet.ShootingStatus := False;
End;
If (CheckDirection = False) Then
Begin
Bullet.ShootingStatus := True;
Bullet.x := Tank.x - 3;
Bullet.y := Tank.y - 1;
Repeat
TextColor(Yellow);
GotoXY(Bullet.x,Bullet.y);
Write(Chr(174)); Delay(35);
GotoXY(Bullet.x,Bullet.y);
Write(Chr(32));
Bullet.x := Bullet.x - 1;
Until (Bullet.x = WallLeft);
Bullet.ShootingStatus := False;
End;
End;
//====================The Main Program===================
Begin
TextBackGround(Black);
Clrscr;
MapForGame;
{Enemy.x := 2;
Enemy.y := 20;
DrawEnemy(Enemy.x,Enemy.y);}
Tank.x := 40;
Tank.y := 20;
DrawRightDirectionTank(Tank.x,Tank.y);
Bullet.ShootingStatus := False;
While True Do
Begin
If (Not Bullet.ShootingStatus) Then
Begin
If Keypressed Then
Case Readkey Of
Chr(77): If (Tank.x + 6 < 80) Then MoveRight;
// If right arrow key pressed
Chr(75): If (Tank.x - 2 > 1) Then MoveLeft;
// If left arrow key pressed
Chr(32): Shooting;
// If space key pressed
End;
End;
End;
End.
 
  • Wow
Reactions: Trần Minh Ngọc

Trần Minh Ngọc

Học sinh chăm học
Thành viên
1 Tháng bảy 2019
431
253
101
Ninh Bình
THPT NHO QUAN B
Program NO_NAME;
Uses Crt;

Const
WallRight = 80;
WallLeft = 1;
Type
Position = Record
x,y: Integer;
End;
TBullet = Record
x,y: Byte;
ShootingStatus: Boolean;
End;
Var
Tank: Position;
Bullet: TBullet;
CheckDirection: Boolean;

Procedure MapForGame;
Var
i,j : Byte;
Begin
For j := 21 To 29 Do
For i := 1 To 80 Do
Begin
TextColor(White);
GotoXY(i,1);
Write(Chr(178));
Gotoxy(i,j);
Write(Chr(178));
End;
End;

Procedure DrawRightDirectionTank(x,y: Integer);
Begin
CheckDirection := True;
Textcolor(LightGreen);
Gotoxy(Tank.x,Tank.y);
Write(#15#15#15#15#15);
Gotoxy(Tank.x,Tank.y-1);
Write(#95#218#209#198#205#205#205);
Gotoxy(Tank.x,Tank.y-2);
End;

Procedure DrawLeftDirectionTank(x,y: Integer);
Begin
CheckDirection := False;
Textcolor(LightGreen);
Gotoxy(Tank.x,Tank.y);
Write(#15#15#15#15#15);
Gotoxy(Tank.x-2,Tank.y-1);
Write(#205#205#205#198#209#191#95);
Gotoxy(Tank.x-2,Tank.y-2);
End;

Procedure ClearLeftDirectionTank(x,y: Integer);
Begin
Gotoxy(Tank.x,Tank.y);
Write(#32#32#32#32#32);
Gotoxy(Tank.x,Tank.y-1);
Write(#32#32#32#32#32#32#32);
End;
Procedure ClearRightDirectionTank(x,y: Integer);
Begin
Gotoxy(Tank.x,Tank.y);
Write(#32#32#32#32#32);
Gotoxy(Tank.x-2,Tank.y-1);
Write(#32#32#32#32#32#32);
End;

Procedure MoveRight;
Begin
ClearRightDirectionTank(Tank.x,Tank.y);
Tank.x := Tank.x + 1;
DrawRightDirectionTank(Tank.x,Tank.y);
Delay(40);
End;

Procedure MoveLeft;
Begin
ClearLeftDirectionTank(Tank.x,Tank.y);
Tank.x := Tank.x - 1;
DrawLeftDirectionTank(Tank.x,Tank.y);
Delay(40);
End;
Procedure Shooting;
Begin
If (CheckDirection = True) Then
Begin
Bullet.ShootingStatus := True;
Bullet.x := Tank.x + 7;
Bullet.y := Tank.y - 1;
Repeat
TextColor(Yellow);
GotoXY(Bullet.x,Bullet.y);
Write(Chr(175)); Delay(35);
GotoXY(Bullet.x,Bullet.y);
Write(Chr(32));
Bullet.x := Bullet.x + 1;
Until (Bullet.x = WallRight);
Bullet.ShootingStatus := False;
End;
If (CheckDirection = False) Then
Begin
Bullet.ShootingStatus := True;
Bullet.x := Tank.x - 3;
Bullet.y := Tank.y - 1;
Repeat
TextColor(Yellow);
GotoXY(Bullet.x,Bullet.y);
Write(Chr(174)); Delay(35);
GotoXY(Bullet.x,Bullet.y);
Write(Chr(32));
Bullet.x := Bullet.x - 1;
Until (Bullet.x = WallLeft);
Bullet.ShootingStatus := False;
End;
End;
//====================The Main Program===================
Begin
TextBackGround(Black);
Clrscr;
MapForGame;
{Enemy.x := 2;
Enemy.y := 20;
DrawEnemy(Enemy.x,Enemy.y);}
Tank.x := 40;
Tank.y := 20;
DrawRightDirectionTank(Tank.x,Tank.y);
Bullet.ShootingStatus := False;
While True Do
Begin
If (Not Bullet.ShootingStatus) Then
Begin
If Keypressed Then
Case Readkey Of
Chr(77): If (Tank.x + 6 < 80) Then MoveRight;
// If right arrow key pressed
Chr(75): If (Tank.x - 2 > 1) Then MoveLeft;
// If left arrow key pressed
Chr(32): Shooting;
// If space key pressed
End;
End;
End;
End.
HauBrightngôn ngữ gì vậy bạn
 

skyler_grey

Học sinh mới
18 Tháng bảy 2023
1
0
1
15
Nam Định
Có chắc là chạy được không vậy bạn
 

HauBright

Học sinh mới
20 Tháng tư 2023
72
36
11
15
Bến Tre
Do game này mik làm gấp nên chưa có add vào kẻ địch làm thú vui cho xe tăng :))
 
Top Bottom