Skip to content

Commit

Permalink
feat: add rough saveslot pick
Browse files Browse the repository at this point in the history
  • Loading branch information
jgabaut committed Jun 20, 2024
1 parent d05ea90 commit d8f84a5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 24 deletions.
63 changes: 43 additions & 20 deletions src/build-rl/game_rl.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void setChestSprite(Chest *c)

}

void update_GameScreen(float* scale, float gameScreenWidth, float gameScreenHeight, GameScreen* currentScreen, int* framesCounter, Floor** current_floor, int* current_x, int* current_y, int logo_sleep, bool* pause_animation, Koliseo_Temp** floor_kls, KLS_Conf temporary_kls_conf, int* current_anim_frame, Vector2* mouse, Vector2* virtualMouse, loadInfo* load_info)
void update_GameScreen(float* scale, float gameScreenWidth, float gameScreenHeight, GameScreen* currentScreen, int* framesCounter, Floor** current_floor, int* current_x, int* current_y, int logo_sleep, bool* pause_animation, Koliseo_Temp** floor_kls, KLS_Conf temporary_kls_conf, int* current_anim_frame, Vector2* mouse, Vector2* virtualMouse, loadInfo* load_info, int* saveslot_index)
{
int center_x = FLOOR_MAX_COLS / 2;
int center_y = FLOOR_MAX_ROWS / 2;
Expand Down Expand Up @@ -317,24 +317,40 @@ void update_GameScreen(float* scale, float gameScreenWidth, float gameScreenHeig

switch(load_info->is_new_game) {
case -1: { // User has to pick new (1) or load (0)
*saveslot_index = -1; // Reset it in case we got here after a whole game
if (IsKeyPressed(KEY_N)) {
load_info->is_new_game = 1;
} else if (IsKeyPressed(KEY_L)) {
load_info->is_new_game = 0;
}
}
break;
//TODO: Pick saveslot
case 0: {
// Load game, Press enter to change to FLOOR_VIEW screen
if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) {
// Load game, Press 1-3 to change to set the index, and then change to FLOOR_VIEW screen
if (*saveslot_index == -1) { // Pick saveslot
if (IsKeyPressed(KEY_ONE)) {
*saveslot_index = 1;
} else if (IsKeyPressed(KEY_TWO)) {
*saveslot_index = 2;
} else if (IsKeyPressed(KEY_THREE)) {
*saveslot_index = 3;
}
} else {
*currentScreen = FLOOR_VIEW;
}
}
break;
case 1: {
// New game, Press enter to change to FLOOR_VIEW screen
if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) {
// New game, Press 1-3 to change to set the index, and then change to FLOOR_VIEW screen
if (*saveslot_index == -1) { // Pick saveslot
if (IsKeyPressed(KEY_ONE)) {
*saveslot_index = 1;
} else if (IsKeyPressed(KEY_TWO)) {
*saveslot_index = 2;
} else if (IsKeyPressed(KEY_THREE)) {
*saveslot_index = 3;
}
} else {
*currentScreen = FLOOR_VIEW;
}
}
Expand Down Expand Up @@ -506,7 +522,7 @@ void update_GameScreen(float* scale, float gameScreenWidth, float gameScreenHeig
}
}

void draw_GameScreen_Texture(RenderTexture2D target_txtr, GameScreen currentScreen, float gameScreenWidth, float gameScreenHeight, Vector2 mouse, Vector2 virtualMouse, int framesCounter, int fps_target, int current_anim_frame, Floor* current_floor, int current_x, int current_y, float scale, loadInfo* load_info)
void draw_GameScreen_Texture(RenderTexture2D target_txtr, GameScreen currentScreen, float gameScreenWidth, float gameScreenHeight, Vector2 mouse, Vector2 virtualMouse, int framesCounter, int fps_target, int current_anim_frame, Floor* current_floor, int current_x, int current_y, float scale, loadInfo* load_info, int saveslot_index)
{
BeginTextureMode(target_txtr);
ClearBackground(RAYWHITE);
Expand Down Expand Up @@ -563,23 +579,30 @@ void draw_GameScreen_Texture(RenderTexture2D target_txtr, GameScreen currentScre
DrawText("PRESS N for new game, L to load a game.", 110, 220, 20, DARKGREEN);
}
break;
//TODO: Pick saveslot
case 0: {
DrawRectangle(0, 0, gameScreenWidth, gameScreenHeight, WHITE);
DrawText(TextFormat("Default Mouse: [%i, %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, WHITE);
DrawText(TextFormat("Virtual Mouse: [%i, %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW);
DrawText("LOADED GAME SCREEN", 20, 20, 40, DARKGREEN);
DrawText("WIP", 20, gameScreenHeight*0.5f, 40, ColorFromS4CPalette(palette, S4C_SALMON));
DrawText("PRESS ENTER or TAP to JUMP to FLOOR_VIEW SCREEN", 110, 220, 20, DARKGREEN);
if (saveslot_index == -1) { // Pick saveslot
DrawRectangle(0, 0, gameScreenWidth, gameScreenHeight, WHITE);
DrawText(TextFormat("Default Mouse: [%i, %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, WHITE);
DrawText(TextFormat("Virtual Mouse: [%i, %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW);
DrawText("LOADED GAME SCREEN", 20, 20, 40, DARKGREEN);
DrawText("WIP", 20, gameScreenHeight*0.5f, 40, ColorFromS4CPalette(palette, S4C_SALMON));
DrawText("PRESS 1-3 to pick a saveslot", 110, 220, 20, DARKGREEN);
} else {
DrawRectangle(0, 0, gameScreenWidth, gameScreenHeight, RED);
}
}
break;
case 1: {
DrawRectangle(0, 0, gameScreenWidth, gameScreenHeight, PINK);
DrawText(TextFormat("Default Mouse: [%i, %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, WHITE);
DrawText(TextFormat("Virtual Mouse: [%i, %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW);
DrawText("NEW GAME SCREEN", 20, 20, 40, DARKGREEN);
DrawText("WIP", 20, gameScreenHeight*0.5f, 40, ColorFromS4CPalette(palette, S4C_SALMON));
DrawText("PRESS ENTER or TAP to JUMP to FLOOR_VIEW SCREEN", 110, 220, 20, DARKGREEN);
if (saveslot_index == -1) { // Pick saveslot
DrawRectangle(0, 0, gameScreenWidth, gameScreenHeight, WHITE);
DrawText(TextFormat("Default Mouse: [%i, %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, WHITE);
DrawText(TextFormat("Virtual Mouse: [%i, %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW);
DrawText("NEW GAME SCREEN", 20, 20, 40, DARKGREEN);
DrawText("WIP", 20, gameScreenHeight*0.5f, 40, ColorFromS4CPalette(palette, S4C_SALMON));
DrawText("PRESS 1-3 to pick a saveslot", 110, 220, 20, DARKGREEN);
} else {
DrawRectangle(0, 0, gameScreenWidth, gameScreenHeight, RED);
}
}
break;
default: {
Expand Down
4 changes: 2 additions & 2 deletions src/build-rl/game_rl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ void setBossSprite(Boss * b);
void setFighterSprite(Fighter * f);
void setChestSprite(Chest * c);
void ToggleFullScreenWindow(int w_W, int w_H);
void update_GameScreen(float* scale, float gameScreenWidth, float gameScreenHeight, GameScreen* currentScreen, int* framesCounter, Floor** current_floor, int* current_x, int* current_y, int logo_sleep, bool* pause_animation, Koliseo_Temp** floor_kls, KLS_Conf temporary_kls_conf, int* current_anim_frame, Vector2* mouse, Vector2* virtualMouse, loadInfo* load_info);
void draw_GameScreen_Texture(RenderTexture2D target_txtr, GameScreen currentScreen, float gameScreenWidth, float gameScreenHeight, Vector2 mouse, Vector2 virtualMouse, int framesCounter, int fps_target, int current_anim_frame, Floor* current_floor, int current_x, int current_y, float scale, loadInfo* load_info);
void update_GameScreen(float* scale, float gameScreenWidth, float gameScreenHeight, GameScreen* currentScreen, int* framesCounter, Floor** current_floor, int* current_x, int* current_y, int logo_sleep, bool* pause_animation, Koliseo_Temp** floor_kls, KLS_Conf temporary_kls_conf, int* current_anim_frame, Vector2* mouse, Vector2* virtualMouse, loadInfo* load_info, int* saveslot_index);
void draw_GameScreen_Texture(RenderTexture2D target_txtr, GameScreen currentScreen, float gameScreenWidth, float gameScreenHeight, Vector2 mouse, Vector2 virtualMouse, int framesCounter, int fps_target, int current_anim_frame, Floor* current_floor, int current_x, int current_y, float scale, loadInfo* load_info, int saveslot_index);
#endif // GAMECURSES_RL_H
5 changes: 3 additions & 2 deletions src/build-rl/helapordo_raylib.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ void gameloop_rl(int argc, char** argv)
load_info->ptr_to_roomtotalenemies = &loaded_roomtotalenemies;
load_info->ptr_to_roomindex = &loaded_roomindex;

int saveslot_index = -1; // This is used as state to prompt the user to pick a saveslot

if (G_DEBUG_ENEMYTYPE_ON == 1) {
log_tag("debug_log.txt", "[DEBUG]", "G_DEBUG_ENEMYTYPE_ON == (%i)",
Expand Down Expand Up @@ -403,12 +404,12 @@ void gameloop_rl(int argc, char** argv)
//----------------------------------------------------------------------------------
//

update_GameScreen(&scale, gameScreenWidth, gameScreenHeight, &currentScreen, &framesCounter, &current_floor, &current_x, &current_y, logo_sleep, &pause_animation, &floor_kls, temporary_kls_conf, &current_anim_frame, &mouse, &virtualMouse, load_info);
update_GameScreen(&scale, gameScreenWidth, gameScreenHeight, &currentScreen, &framesCounter, &current_floor, &current_x, &current_y, logo_sleep, &pause_animation, &floor_kls, temporary_kls_conf, &current_anim_frame, &mouse, &virtualMouse, load_info, &saveslot_index);
//----------------------------------------------------------------------------------

// Draw render texture, will not go on screen yet
//----------------------------------------------------------------------------------
draw_GameScreen_Texture(target_txtr, currentScreen, gameScreenWidth, gameScreenHeight, mouse, virtualMouse, framesCounter, fps_target, current_anim_frame, current_floor, current_x, current_y, scale, load_info);
draw_GameScreen_Texture(target_txtr, currentScreen, gameScreenWidth, gameScreenHeight, mouse, virtualMouse, framesCounter, fps_target, current_anim_frame, current_floor, current_x, current_y, scale, load_info, saveslot_index);
//----------------------------------------------------------------------------------

// Draw
Expand Down

0 comments on commit d8f84a5

Please sign in to comment.