File tree Expand file tree Collapse file tree 3 files changed +48
-2
lines changed
Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "configurations" : [
3+ {
4+ "name" : " x64-Debug (default)" ,
5+ "generator" : " Ninja" ,
6+ "configurationType" : " Debug" ,
7+ "inheritEnvironments" : [ " msvc_x64_x64" ],
8+ "buildRoot" : " ${projectDir}\\ out\\ build\\ ${name}" ,
9+ "installRoot" : " ${projectDir}\\ out\\ install\\ ${name}" ,
10+ "cmakeCommandArgs" : " " ,
11+ "buildCommandArgs" : " " ,
12+ "ctestCommandArgs" : " " ,
13+ "variables" : []
14+ },
15+ {
16+ "name" : " x64-Release" ,
17+ "generator" : " Ninja" ,
18+ "configurationType" : " RelWithDebInfo" ,
19+ "buildRoot" : " ${projectDir}\\ out\\ build\\ ${name}" ,
20+ "installRoot" : " ${projectDir}\\ out\\ install\\ ${name}" ,
21+ "cmakeCommandArgs" : " " ,
22+ "buildCommandArgs" : " " ,
23+ "ctestCommandArgs" : " " ,
24+ "inheritEnvironments" : [ " msvc_x64_x64" ],
25+ "variables" : []
26+ }
27+ ]
28+ }
Original file line number Diff line number Diff line change 3232
3333using namespace blit ;
3434
35+ struct SaveData {
36+ int score;
37+ };
38+
3539struct Squirrel {
3640 float yPosition;
3741 float yVelocity;
@@ -61,6 +65,8 @@ uint32_t lastTime = 0;
6165
6266int localHighscore = 0 ;
6367
68+ SaveData saveData;
69+
6470float offset = 0 ;
6571
6672int treeNumber = 0 ;
@@ -196,7 +202,17 @@ void start_game() {
196202//
197203void init () {
198204 set_screen_mode (ScreenMode::lores);
199- screen.sprites = SpriteSheet::load (asset_sprites);
205+ screen.sprites = Surface::load (asset_sprites);
206+
207+ // Attempt to load the first save slot.
208+ if (read_save (saveData)) {
209+ // Loaded sucessfully!
210+ localHighscore = saveData.score ;
211+ }
212+ else {
213+ // No save file or it failed to load, set up some defaults.
214+ saveData.score = 0 ;
215+ }
200216}
201217
202218// /////////////////////////////////////////////////////////////////////////
@@ -337,6 +353,8 @@ void update(uint32_t time) {
337353 if (player.deadTimer >= DEAD_TIME) {
338354 state = 2 ;
339355 localHighscore = max (localHighscore, player.score );
356+ saveData.score = localHighscore;
357+ write_save (saveData); // write highscore
340358 }
341359 }
342360 }
Original file line number Diff line number Diff line change 55 file : assets/image.png
66icon :
77 file : assets/icon.png
8- version : v1.1 .0
8+ version : v1.2 .0
99
You can’t perform that action at this time.
0 commit comments