-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a21055
commit ab5811a
Showing
6 changed files
with
81 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "save.h" | ||
|
||
void save() { | ||
struct SaveGame g = (struct SaveGame){ | ||
.valid = VALID, | ||
.player = game_state.player, | ||
.inventory = game_state.inventory, | ||
.currentRoom = game_state.currentRoom, | ||
.world_id = game_state.world_id, | ||
}; | ||
|
||
diskw(&g, sizeof(struct SaveGame)); | ||
} | ||
|
||
bool load_save_game() { | ||
struct SaveGame g; | ||
diskr(&g, sizeof(struct SaveGame)); | ||
|
||
if (g.valid == VALID) { | ||
game_state.currentRoom = g.currentRoom; | ||
game_state.player = g.player; | ||
game_state.inventory = g.inventory; | ||
game_state.world_id = g.world_id; | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "game.h" | ||
#include "wasm4.h" | ||
|
||
#define VALID 0xCAFEBABE | ||
|
||
struct SaveGame { | ||
uint32_t valid; | ||
struct Player player; | ||
struct PlayerInventory inventory; | ||
struct Room currentRoom; | ||
uint16_t world_id; | ||
}; | ||
|
||
void save(); | ||
bool load_save_game(); |