This repository has been archived by the owner on Apr 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGUIStep.m
64 lines (62 loc) · 2.43 KB
/
GUIStep.m
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
%GUI Step. This routine will be executed everytime after a movement is
%done, namely to update the GUI (font(smaller font for larger numbers), face colour(gradual from yellow to red, as per original game design), number and text displayed) with new information due to
%movement on the board.
global StepCounter;
global Score;
for row = 1:4
for col = 1:4
Square = RectangleGroup(row,col); % Access the corresponding square
Text = TextGroup(row,col);
Text.FontName = 'Arial';
if board(row,col) == 0
Square.FaceColor = 'w';
Text.String =' ';
else
if board(row,col) == 2
Square.FaceColor = [1 1 0];
Text.Color = 'k';
Text.FontSize = 40;
elseif board(row,col) == 4
Square.FaceColor = [1 0.9 0];
Text.Color = 'k';
Text.FontSize = 40;
else
Text.Color = 'w';
if board(row,col) == 8
Square.FaceColor = [1 0.8 0];
Text.FontSize = 40;
elseif board(row,col) == 16 || board(row,col) == 32
Square.FaceColor = [1 0.7 0];
Text.FontSize = 30;
elseif board(row,col) == 32
Square.FaceColor = [1 0.6 0];
Text.FontSize = 30;
elseif board(row,col) == 64
Square.FaceColor = [1 0.5 0];
Text.FontSize = 30;
elseif board(row,col) == 128
Square.FaceColor = [1 0.4 0];
Text.FontSize = 25;
elseif board(row,col) == 256
Square.FaceColor = [1 0.3 0];
Text.FontSize = 25;
elseif board(row,col) == 512
Square.FaceColor = [1 0.2 0];
Text.FontSize = 25;
elseif board(row,col) == 1024
Square.FaceColor = [1 0.1 0];
Text.FontSize = 20;
else
Square.FaceColor = [1 0 0];
Text.FontSize = 20;
end
end
%Colour code
Text.String = num2str(board(row,col));
end
end
end
StepDisplay.String = sprintf ('Steps Taken = %d', StepCounter);
ScoreDisplay.String = sprintf ('Score = %d', Score);
drawnow;
% Copyright (C) 2016 Xingchen Wan - All Rights Reserved