-
Notifications
You must be signed in to change notification settings - Fork 1
/
Screen_HAL.c
165 lines (144 loc) · 4.55 KB
/
Screen_HAL.c
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
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
* Screen_HAL.c
*
* Created on: Mar 24, 2018
* Author: hungt
*/
#include <Display_HAL.h>
Graphics_Context g_sContext;
extern ironmanbabyPNG8BPP_UNCOMP;
extern mariowalk18BPP_UNCOMP;
extern PlayScreen2568BPP_UNCOMP;
extern Bang18BPP_UNCOMP;
extern Bang28BPP_UNCOMP;
extern ThemeIronman4BPP_UNCOMP;
extern MenuAndInstructionScreen4BPP_UNCOMP;
void ScoreSet(int * HighestScore, int * MidScore, int * LowestScore, int CurrentScore)
{
if ( CurrentScore > * HighestScore)
{
* MidScore = * HighestScore;
* HighestScore = CurrentScore;
}
else if ( CurrentScore >= * MidScore && CurrentScore < * HighestScore)
{
* LowestScore = * MidScore;
* MidScore = CurrentScore;
}
else if (CurrentScore >= * LowestScore && CurrentScore < * MidScore)
* LowestScore = CurrentScore ;
}
/*
PrintScore (* HighestScore, 10, 10);
PrintScore (* MidScore, 11, 11);
PrintScore (* LowestScore, 12, 12);
*/
void PrintScore (int Score, int x, int y)
{
char buf[8] = "SCORE XX";
buf[6] = ((Score/10) % 10) + '0';
buf[7] = ((Score ) % 10) + '0';
LCDDrawChar(x, y, buf[6]);
LCDDrawChar(x, y+1, buf[7]);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SCREEN
void DrawOpeningScreen()
{
Graphics_drawImage(&g_sContext, &ThemeIronman4BPP_UNCOMP, 0, 0);
PrintString("IRONMAN vs MARIO", 0, 0);
PrintString("By", 1, 7);
PrintString("HUNG TRAN", 2, 3);
}
void DrawMenuScreen()
{
Graphics_drawImage(&g_sContext, &MenuAndInstructionScreen4BPP_UNCOMP, 0, 0);
PrintString("GAME MENU", 0, 4);
PrintString("Play Game", 2, 2);
PrintString("How to play", 3,2);
PrintString("Score History", 4,2);
PrintString(">", 2 , 0);
}
void DrawInstructionScreen()
{
LCDClearDisplay(MY_YELLOW);
PrintString("INSTRUCTIONS", 0, 2);
PrintString("USE THE JOYSTICK", 1, 0);
PrintString("TO MOVE IRONMAN", 2, 0);
PrintString("AND DODGE THE", 3, 0);
PrintString("COMING MARIO.", 4, 0);
PrintString("BTN1-MENU", 7, 6);
}
void DrawPauseScreen()
{
LCDClearDisplay(MY_YELLOW);
PrintString("GAME PAUSE", 0, 3);
PrintString("Continue", 2, 2);
PrintString("Menu", 3,2);
PrintString(">", 2 , 0);
}
void DrawGameOverScreen(int Score)
{
int i;
for (i = 0; i < 5; i++)
{
Graphics_drawImage(&g_sContext, &Bang18BPP_UNCOMP, 0, 0);
Graphics_drawImage(&g_sContext, &Bang28BPP_UNCOMP, 0, 0);
}
//LCDClearDisplay(MY_YELLOW);
Graphics_drawImage(&g_sContext, &MenuAndInstructionScreen4BPP_UNCOMP, 0, 0);
PrintString("GAME OVER", 0, 4);
PrintString("Score", 2, 0);
PrintString("GOOD LUCK NEXT", 3,0);
PrintString("TIME!", 4 , 5);
PrintString("Wait 3 sec", 7, 3);
PrintScore (Score, 10, 110);
}
void DrawScoreScreen(int HighestScore, int MidScore, int LowestScore)
{
Graphics_drawImage(&g_sContext, &MenuAndInstructionScreen4BPP_UNCOMP, 0, 0);
PrintString("SCORE HISTORY", 0, 1);
PrintString("1st", 2, 2);
PrintString("2nd", 3, 2);
PrintString("3rd", 4, 2);
PrintScore (HighestScore, 10, 11);
PrintScore (MidScore, 11, 11);
PrintScore (LowestScore, 12,11);
PrintString("BTN1-MENU", 7, 6);
}
void DrawPlayScreen(int *HelloIronMan, int HighScore)
{
int theline;
LCDClearDisplay(MY_YELLOW);
Graphics_drawImage(&g_sContext, &PlayScreen2568BPP_UNCOMP, 0, 0);
Graphics_drawString(&g_sContext, "SCORE" , -1, 73, 2, true);
Graphics_drawString(&g_sContext, "HIGH" , -1, 73, 60, true);
Graphics_drawString(&g_sContext, "SCORE" , -1, 73, 80, true);
PrintScore (HighScore, 14, 13);
Graphics_drawImage(&g_sContext, &ironmanbabyPNG8BPP_UNCOMP, *HelloIronMan, 111);
}
void DrawIronMan(int x, int y)
{
Graphics_drawImage(&g_sContext, &ironmanbabyPNG8BPP_UNCOMP, x, y);
}
void DrawFillCircle (int x, int y, int radius)
{
Graphics_fillCircle(&g_sContext, x, y, radius);
}
void DrawALineH (int x1, int x2, int y)
{
Graphics_drawLineH(&g_sContext,x1,x2,y);
}
void DrawALineV (int x, int y1, int y2)
{
Graphics_drawLineV(&g_sContext,x,y1,y2);
}
void EraseIronMan (int x)
{
Graphics_drawLineV(&g_sContext,x,111,126);
Graphics_drawLineV(&g_sContext,x + 15 ,111,126);
}
void DrawEnemy(int x, int y)
{
Graphics_drawImage(&g_sContext, &mariowalk18BPP_UNCOMP, x, y);
}