game.txt
来自「H++编译器: 一个仿Pascal语言的编译器」· 文本 代码 · 共 71 行
TXT
71 行
Program(Guess,Dos.MZ);
Var(Answer,Byte);
Var(Num,Byte,4);
Var(X,Byte);
Var(Lives,Byte,4);
Var(Life,Byte,3);
Const(Line,'哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪');
Function WriteLives():Byte;
Screen.Clear;
X = 0;
Cursor.Set(1,2);
Color.Set(Color.Red);
WriteLife:
Write(Life);
X =+ 1;
if X < Lives goto WriteLife;
Write(Line+Line,Color.White,2,0);
Return;
Begin
if Lives = 0 goto GameOver;
WriteLives;
Write('Guess a number between 0 and 9: ',Color.Yellow,12,18);
Answer = Read() - $30;
Lives =- 1;
IfNot Answer in [0..9] Goto Error;
If Answer < Num Goto HigherNum;
If Answer > Num Goto LowerNum;
If Answer = Num Goto Correct;
HigherNum:
WriteLives;
Write('That was a nice guess,',Color.Yellow,12,18);
Write('but the number is too low!',Color.Red,13,18);
Wait;
Jump(Start);
LowerNum:
WriteLives;
Write('That was a nice guess,',Color.Yellow,12,18);
Write('but the number is too high!',Color.Red,13,18);
Wait;
Jump(Start);
Error:
WriteLives;
Write('You didn'+Quote.Single+'t write a number!!',Color.Red,12,18);
Wait;
Jump(Start);
GameOver:
WriteLives;
Cursor.Set(1,2);
Color.Set(Color.Red,12);
Write('Game Over!!!');
Wait;
End;
Correct:
WriteLives;
Cursor.Set(12,18);
Color.Set(Color.Lime,40);
Num =+ $30;
Write('Correct answer!!! '+Num+' is the right number!');
Cursor.Set(13,18);
Color.Set(Color.Lime,40);
Lives =+ $30;
Write('Lives left: '+Lives);
Wait;
End;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?