-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameWindowTutorial.t
152 lines (103 loc) · 3.46 KB
/
GameWindowTutorial.t
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
% MAIN PROGRAM STEPS %
procedure displayGameWindowTutorial
var anykey : string (1) := ""
% flag that intro screen is open - global var isIntroWindowOpen
isGameWindowOpen := true
% Open the window
var winID : int
winID := Window.Open ("position:top;center,graphics:1250;700,title:Othello")
Window.Hide (wininID)
fork click
fork backgroundMusic
%The Game
%Othello
% Othello Game. Put pieces into starting position
setBoardStartingPosition
countScores (GameBoardArray)
%displayIntroWindow
% display board with starting black and white chips
DrawBoard (GameBoardArray)
put "Welcome to Othello,", PlayerOneName, "."
put "You are black playing against the white computer. Any key to continue."
getch (anykey)
% Player 1's turn.
loop
if Player mod 2 not= 0 then
if Player = 1 then
%draw all legal moves
possibleMoves (Player)
put "Legal Moves are highlighted in blue"
getch (anykey)
% Player pick a cell using a mouse click.
put "Pick a square by clicking on it"
loop
getMove (Player, row, col)
if isOccupied (row, col) = false then
exit when isLegal (Player, row, col, GameBoardArray) = true
end if
% Check if legal click/selection - if not legal go to a.
end loop
PlayerTurn += 1
% Flip white chips to black.
executeMove (Player, row, col, GameBoardArray)
resetDirections
countScores (GameBoardArray)
DrawBoard (GameBoardArray)
put "Good job! Now, the computer will go. Good bye and good luck. May the odds be ever in your favour"
getch (anykey)
% Change Player
Player += 1
% Check for winning condition
if isFullyOccupied (GameBoardArray) = true or endgame (Player) = false then
% if it is full, end Game. displayEngGame will determine a winner by calling ResultWinnerorDraw
Time.Delay (2000)
Window.Close (winID)
displayOutroWindow
end if
else
%draw all legal moves
possibleMoves (Player)
% Player pick a cell using a mouse click.
loop
getMove (Player, row, col)
if isOccupied (row, col) = false then
exit when isLegal (Player, row, col, GameBoardArray) = true
end if
% Check if legal click/selection - if not legal go to a.
end loop
PlayerTurn += 1
% Flip white chips to black.
executeMove (Player, row, col, GameBoardArray)
resetDirections
countScores (GameBoardArray)
DrawBoard (GameBoardArray)
% Change Player
Player += 1
% Check for winning condition
if isFullyOccupied (GameBoardArray) = true or endgame (Player) = false then
% if it is full, end Game. displayEngGame will determine a winner by calling ResultWinnerorDraw
Time.Delay (2000)
Window.Close (winID)
displayOutroWindow
end if
end if
else
playerMoved := false
EasyAIMove
PlayerTurn += 1
resetDirections
countScores (GameBoardArray)
playerMoved := true
DrawBoard (GameBoardArray)
% Change Player
Player += 1
% Check for winning condition
if isFullyOccupied (GameBoardArray) = true or endgame (Player) = false then
% if it is full, end Game. displayEngGame will determine a winner by calling ResultWinnerorDraw
Time.Delay (2000)
Window.Close (winID)
displayOutroWindow
end if
end if
end loop
end displayGameWindowTutorial