diff --git a/include/app.h b/include/app.h index b9f0429..80a68b5 100644 --- a/include/app.h +++ b/include/app.h @@ -42,7 +42,8 @@ typedef enum View { LOGO = 0, MENU = 1, GAMEPLAY = 2 } View; typedef enum { STORAGE_POSITION_GOLD = 0, STORAGE_POSITION_POSX = 1, - STORAGE_POSITION_POSY = 2 + STORAGE_POSITION_POSY = 2, + STORAGE_POSITION_ROTATION = 3 } StorageData; // STRUCTS// diff --git a/src/appGame.c b/src/appGame.c index 8b2d934..fedd700 100644 --- a/src/appGame.c +++ b/src/appGame.c @@ -99,7 +99,7 @@ void RenderGame(App *app) { (Vector2){g->mouse.screenPosition.x, g->mouse.screenPosition.y}, WHITE); Player *player = GetPlayer(); - DrawText(TextFormat("Gold: %d", player->gold), 0.0f, 0.0f, 12.0f, YELLOW); + DrawText(TextFormat("Gold: %u", player->gold), 0.0f, 0.0f, 12.0f, YELLOW); EndTextureMode(); BeginDrawing(); diff --git a/src/appGamePlayer.c b/src/appGamePlayer.c index 96ca894..c4361df 100644 --- a/src/appGamePlayer.c +++ b/src/appGamePlayer.c @@ -40,9 +40,8 @@ void CreatePlayer(void) Texture2D texture = LoadTexture(startShipAsset.path); float frameWidth = startShipAsset.frameWidth; - float rotation = startShipAsset.rotation; + float rotation = (float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION); - Sprite playerSprite = { .texture = texture, .frameSize = {frameWidth, frameWidth}, @@ -62,9 +61,8 @@ void CreatePlayer(void) .animTimer = 0.0f }; - Physics playerPhysics = { - .position = (Vector2){0.0f,0.0f}, + .position = (Vector2){(float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX), (float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY)}, .direction = (Vector2){0.0f, 0.0f}, .speed = playerSpeeds[ANCHOR] }; @@ -127,12 +125,12 @@ void UpdatePlayer(void) } player->sprite.rotation = player->rotation; - Vector2 dir = RotationToVector2(player->rotation - 90.0f); - - - UpdatePhysics(&player->physics, dir); - UpdateSpriteDestRec(&player->sprite, &player->physics.position); + UpdatePhysics(&player->physics, dir); + UpdateSpriteDestRec(&player->sprite, &player->physics.position); + SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX, (int)player->physics.position.x); + SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY, (int)player->physics.position.y); + SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION, (int)player->rotation); } void RenderPlayer(void){