Skip to content

Commit 46ebd11

Browse files
committed
Added highscores.
Tried creating a title image which I don't like.
1 parent c6b9983 commit 46ebd11

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

assets/spritesheet.png

848 Bytes
Loading

game.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ int state = 0;
5959
float dt;
6060
uint32_t lastTime = 0;
6161

62+
int localHighscore = 0;
63+
6264
float offset = 0;
6365

6466
int treeNumber = 0;
@@ -158,6 +160,11 @@ void render_tiles() {
158160
}
159161
}
160162

163+
void render_title() {
164+
screen.blit(screen.sprites, Rect(0, 96, 65, 16), Point(0, 0));
165+
screen.blit(screen.sprites, Rect(0, 112, 76, 16), Point(0, 16));
166+
}
167+
161168
void fade_background() {
162169
screen.pen = Pen(0, 0, 0, 150);
163170
screen.clear();
@@ -212,7 +219,9 @@ void render(uint32_t time) {
212219

213220
fade_background();
214221

215-
screen.text("Jumpy Squirrel", minimal_font, Point(SCREEN_WIDTH / 2, SCREEN_HEIGHT * 1 / 4), true, TextAlign::center_center);
222+
//render_title();
223+
224+
screen.text("Jumpy Squirrel", minimal_font, Point(SCREEN_WIDTH / 2, SCREEN_HEIGHT * 1 / 3), true, TextAlign::center_center); // change to custom icon
216225

217226
screen.text("Press A to Start", minimal_font, Point(SCREEN_WIDTH / 2, SCREEN_HEIGHT * 2 / 3), true, TextAlign::center_center);
218227
}
@@ -238,9 +247,9 @@ void render(uint32_t time) {
238247

239248
fade_background();
240249

241-
screen.text("You scored "+std::to_string(player.score), minimal_font, Point(SCREEN_WIDTH / 2, SCREEN_HEIGHT * 1 / 3), true, TextAlign::center_center);
250+
screen.text("Score: "+std::to_string(player.score), minimal_font, Point(SCREEN_WIDTH / 2, SCREEN_HEIGHT * 1 / 3), true, TextAlign::center_center);
242251

243-
screen.text("You died", minimal_font, Point(SCREEN_WIDTH / 2, SCREEN_HEIGHT * 1 / 4), true, TextAlign::center_center);
252+
screen.text("Highscore: " + std::to_string(localHighscore), minimal_font, Point(SCREEN_WIDTH / 2, SCREEN_HEIGHT * 1 / 2), true, TextAlign::center_center);
244253

245254
screen.text("Press A to Retry", minimal_font, Point(SCREEN_WIDTH / 2, SCREEN_HEIGHT * 2 / 3), true, TextAlign::center_center);
246255
}
@@ -324,6 +333,7 @@ void update(uint32_t time) {
324333

325334
if (player.deadTimer >= DEAD_TIME) {
326335
state = 2;
336+
localHighscore = max(localHighscore, player.score);
327337
}
328338
}
329339
}

metadata.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ splash:
55
file: assets/image.png
66
icon:
77
file: assets/icon.png
8-
version: v1.0.0
8+
version: v1.0.1
99

0 commit comments

Comments
 (0)