-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMainMenu.jack
More file actions
109 lines (97 loc) · 3.06 KB
/
Copy pathMainMenu.jack
File metadata and controls
109 lines (97 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
class MainMenu
{
static int gameCount;
static boolean random;
function void run()
{
var boolean run;
var boolean waitCommand;
var char key;
let run = true;
while (run)
{
do Screen.clearScreen();
do MainMenu.printHello();
let waitCommand = true;
while (waitCommand)
{
let random = ~random;
let key = Keyboard.keyPressed();
if (key = 140) { let waitCommand = false; let run = false; } // ecs pressed
if (key = 128) { let waitCommand = false; do MainMenu.gmaeStart(); } // enter pressed
if (key = 72) { let waitCommand = false; do MainMenu.help(); } // h pressed
}
}
return;
}
function void printHello()
{
do Output.moveCursor(0, 0);
do Output.printString(Message.gameNameMessage());
do Output.moveCursor(3, 0);
do Output.printString(Message.helloEnterMessage());
do Output.println();
do Output.println();
do Output.printString(Message.helloHMessage());
do Output.println();
do Output.println();
do Output.printString(Message.helloEscMessage());
return;
}
function void gmaeStart()
{
var MatrixGame game;
var String firstPlayerName;
var String secondPlayerName;
var String tempName;
var boolean isGameCountEven;
let gameCount = gameCount + 1;
do Screen.clearScreen();
do Output.moveCursor(0, 0);
do Sys.wait(1000);
let firstPlayerName = Keyboard.readLine(Message.enterFirstNameMessage());
do Output.moveCursor(5, 0);
do Sys.wait(1000);
let secondPlayerName = Keyboard.readLine(Message.enterSecondNameMessage());
/* Random who begin */
/*
let isGameCountEven = true;
if (((gameCount / 2) * 2) - gameCount = 0)
{
let isGameCountEven = false;
}
if ((firstPlayerName[0] > secondPlayerName[0]) & gameCount)
{
let tempName = firstPlayerName;
let firstPlayerName = secondPlayerName;
let secondPlayerName = tempName;
}
*/
if (random)
{
let tempName = firstPlayerName;
let firstPlayerName = secondPlayerName;
let secondPlayerName = tempName;
}
do Screen.clearScreen();
let game = MatrixGame.new(3, firstPlayerName, secondPlayerName);
do game.start();
do game.dispose();
return;
}
function void help()
{
var boolean waitKey;
do Screen.clearScreen();
do Output.moveCursor(0, 0);
do Output.printString(Message.helpMessage());
do Output.moveCursor(22, 0);
do Output.printString(Message.helloBackspaceMessage());
let waitKey = true;
while (waitKey)
{
if (Keyboard.keyPressed() = 129) { let waitKey = false; } // backspase pressed
}
return;
}
}