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 EXPERIMENT;
Uses Crt;
Var
a,b,c,x,y,delays,i,j: Integer;
m,speed: Char;
Procedure MAP;
Begin
For i:=1 to 80 do Write('=');
End;
//===============================================
Function checkxy(x,y:Integer):Boolean;
Begin
If (x<1) or (x>79) or (y<2) or (y>29) Then checkxy:=False
Else checkxy:=True;
End;
//===============================================
Procedure RIGHT;
Begin
Repeat
Clrscr;
Gotoxy(x+1,y);
Write('O');
x := x+1;
Delay(delays);
Until Keypressed;
If checkxy(x,y)=False then
Begin
ClrScr;
Writeln('YOU LOSE!'); Delay(500);
Halt;
End;
End;
//===============================================
Procedure LEFT;
Begin
Repeat
Clrscr;
Gotoxy(x-1,y);
Write('O');
x := x-1;
Delay(delays);
Until Keypressed;
If checkxy(x,y)=False then
Begin
ClrScr;
Writeln('YOU LOSE!'); Delay(500);
Halt;
End;
End;
//===============================================
Procedure DOWN;
Begin
Repeat
Clrscr;
Gotoxy(x,y+1);
Write('O');
y := y+1;
Delay(delays+20);
Until Keypressed;
If checkxy(x,y)=False then
Begin
ClrScr;
Writeln('YOU LOSE!'); Delay(500);
Halt;
End;
End;
//===============================================
Procedure UP;
Begin
Repeat
Clrscr;
Gotoxy(x,y-1);
Write('O');
y := y-1;
Delay(delays+20);
Until Keypressed;
If checkxy(x,y)=False then
Begin
ClrScr;
Writeln('YOU LOSE!'); Delay(500);
Halt;
End;
End;
//===============================================
Begin
Clrscr;
WriteLn('CHOOSE THE DIFFICULTY LEVEL!');
Writeln('a.EASY':1,'b.MEDIUM':17,'c.HARD':15,'d.IMPOSSIBLE!':21);
speed:=ReadKey;
Case speed Of
'a': delays:=230;
'b': delays:=180;
'c': delays:=100;
'd': delays:=45;
End;
ClrScr;
Delay(100);
x := 2;
y := 2;
GotoXY(2,2);
Write('O');
While 1=1 Do
Begin
m := Readkey;
Case m Of
'd': RIGHT;
'a': LEFT;
's': DOWN;
'w': UP;
End;
End;
End.
Uses Crt;
Var
a,b,c,x,y,delays,i,j: Integer;
m,speed: Char;
Procedure MAP;
Begin
For i:=1 to 80 do Write('=');
End;
//===============================================
Function checkxy(x,y:Integer):Boolean;
Begin
If (x<1) or (x>79) or (y<2) or (y>29) Then checkxy:=False
Else checkxy:=True;
End;
//===============================================
Procedure RIGHT;
Begin
Repeat
Clrscr;
Gotoxy(x+1,y);
Write('O');
x := x+1;
Delay(delays);
Until Keypressed;
If checkxy(x,y)=False then
Begin
ClrScr;
Writeln('YOU LOSE!'); Delay(500);
Halt;
End;
End;
//===============================================
Procedure LEFT;
Begin
Repeat
Clrscr;
Gotoxy(x-1,y);
Write('O');
x := x-1;
Delay(delays);
Until Keypressed;
If checkxy(x,y)=False then
Begin
ClrScr;
Writeln('YOU LOSE!'); Delay(500);
Halt;
End;
End;
//===============================================
Procedure DOWN;
Begin
Repeat
Clrscr;
Gotoxy(x,y+1);
Write('O');
y := y+1;
Delay(delays+20);
Until Keypressed;
If checkxy(x,y)=False then
Begin
ClrScr;
Writeln('YOU LOSE!'); Delay(500);
Halt;
End;
End;
//===============================================
Procedure UP;
Begin
Repeat
Clrscr;
Gotoxy(x,y-1);
Write('O');
y := y-1;
Delay(delays+20);
Until Keypressed;
If checkxy(x,y)=False then
Begin
ClrScr;
Writeln('YOU LOSE!'); Delay(500);
Halt;
End;
End;
//===============================================
Begin
Clrscr;
WriteLn('CHOOSE THE DIFFICULTY LEVEL!');
Writeln('a.EASY':1,'b.MEDIUM':17,'c.HARD':15,'d.IMPOSSIBLE!':21);
speed:=ReadKey;
Case speed Of
'a': delays:=230;
'b': delays:=180;
'c': delays:=100;
'd': delays:=45;
End;
ClrScr;
Delay(100);
x := 2;
y := 2;
GotoXY(2,2);
Write('O');
While 1=1 Do
Begin
m := Readkey;
Case m Of
'd': RIGHT;
'a': LEFT;
's': DOWN;
'w': UP;
End;
End;
End.