REDESIGN: LoadStorageValue()/SaveStorageValue()

Using new file I/O ABI
This commit is contained in:
Ray 2020-02-27 13:18:15 +01:00
parent 2294947660
commit 23bde477e5
4 changed files with 68 additions and 50 deletions

View file

@ -12,7 +12,10 @@
#include "raylib.h"
// NOTE: Storage positions must start with 0, directly related to file memory layout
typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData;
typedef enum {
STORAGE_POSITION_SCORE = 0,
STORAGE_POSITION_HISCORE = 1
} StorageData;
int main(void)
{
@ -43,14 +46,14 @@ int main(void)
if (IsKeyPressed(KEY_ENTER))
{
SaveStorageValue(STORAGE_SCORE, score);
SaveStorageValue(STORAGE_HISCORE, hiscore);
SaveStorageValue(STORAGE_POSITION_SCORE, score);
SaveStorageValue(STORAGE_POSITION_HISCORE, hiscore);
}
else if (IsKeyPressed(KEY_SPACE))
{
// NOTE: If requested position could not be found, value 0 is returned
score = LoadStorageValue(STORAGE_SCORE);
hiscore = LoadStorageValue(STORAGE_HISCORE);
score = LoadStorageValue(STORAGE_POSITION_SCORE);
hiscore = LoadStorageValue(STORAGE_POSITION_HISCORE);
}
framesCounter++;