From 11e91aa01c375a0c85de44bd62d67513ae1b4a07 Mon Sep 17 00:00:00 2001 From: samstalhandske Date: Fri, 12 Dec 2025 19:14:38 +0100 Subject: [PATCH] Minor things. --- src/presentation/states/state_ingame.c | 15 +++++++++++++-- src/presentation/states/state_main_menu.c | 22 ++++++++++++---------- src/session/game_session.c | 2 +- src/shared/entity.h | 2 -- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/presentation/states/state_ingame.c b/src/presentation/states/state_ingame.c index 92fef22..2f8805f 100644 --- a/src/presentation/states/state_ingame.c +++ b/src/presentation/states/state_ingame.c @@ -94,6 +94,8 @@ uint32_t floor_texture_variant(uint32_t x, uint32_t y, uint32_t seed, uint32_t n return (wang_hash(x * 73856093u ^ y * 19349663u ^ seed)) % num_variants; } +#define SHADOW_ALPHA 64 + static void state_render(Presentation_State *state) { Presentation_State_Ingame_Context *ctx = (Presentation_State_Ingame_Context *)state->context; (void)ctx; @@ -170,7 +172,7 @@ static void state_render(Presentation_State *state) { (Vector2) { pres_x, pres_y }, 0.0f, 1.0f, - (Color) { 0, 0, 0, 32 } + (Color) { 0, 0, 0, SHADOW_ALPHA } ); float rotation = 0.0f; @@ -216,6 +218,15 @@ static void state_render(Presentation_State *state) { e = game_world_try_get_entity_by_id(world, e->child); i += 1; } + + // TODO: SS - Don't draw player-name if playing by yourself. + // TODO: SS - Don't draw your own player-name, only others. + { // Draw player-name. + const char *player_name = "mirakel"; // NOTE: SS - Hardcoded. + const uint32_t font_size = 8; + int text_width = MeasureText(player_name, font_size); + DrawText(player_name, pres_x - (float)text_width/2.0f + 4, pres_y - 16, font_size, (Color) { 255, 255, 255, 128 }); + } break; } @@ -234,7 +245,7 @@ static void state_render(Presentation_State *state) { (Vector2) { pres_x, pres_y }, 0.0f, 1.0f, - (Color) { 0, 0, 0, 32 } + (Color) { 0, 0, 0, SHADOW_ALPHA } ); DrawTexturePro( diff --git a/src/presentation/states/state_main_menu.c b/src/presentation/states/state_main_menu.c index 05ae0a3..ce78973 100644 --- a/src/presentation/states/state_main_menu.c +++ b/src/presentation/states/state_main_menu.c @@ -33,6 +33,8 @@ static void state_tick(Presentation_State *state) { } } +bool editing_width = false; + static void state_render(Presentation_State *state) { Presentation_State_Main_Menu_Context *ctx = (Presentation_State_Main_Menu_Context *)state->context; @@ -44,13 +46,13 @@ static void state_render(Presentation_State *state) { switch(ctx->mode) { case Main_Menu_Mode_Home: { - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 0), 128, BUTTON_HEIGHT }, "#191#Singleplayer")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 0), 128, BUTTON_HEIGHT }, "Singleplayer")) { ctx->mode = Main_Menu_Mode_Singleplayer; } - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 1), 128, BUTTON_HEIGHT }, "#191#Multiplayer")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 1), 128, BUTTON_HEIGHT }, "Multiplayer")) { ctx->mode = Main_Menu_Mode_Multiplayer; } - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 2), 128, BUTTON_HEIGHT }, "#191#Quit")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 2), 128, BUTTON_HEIGHT }, "Quit")) { *(ctx->should_quit_game) = true; } @@ -64,15 +66,15 @@ static void state_render(Presentation_State *state) { break; } case Main_Menu_Mode_Multiplayer: { - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 0), 128, BUTTON_HEIGHT }, "#191#Host")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 0), 128, BUTTON_HEIGHT }, "Host")) { ctx->is_singleplayer = false; ctx->mode = Main_Menu_Mode_Game_Setup; game_session_init_default_settings(ctx->is_singleplayer, &ctx->session_settings); } - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 1), 128, BUTTON_HEIGHT }, "#191#Join")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 1), 128, BUTTON_HEIGHT }, "Join")) { ctx->mode = Main_Menu_Mode_Multiplayer_Join; } - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 2), 128, BUTTON_HEIGHT }, "#191#Back to Main Menu")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 2), 128, BUTTON_HEIGHT }, "Back to Main Menu")) { ctx->mode = Main_Menu_Mode_Home; } @@ -91,7 +93,7 @@ static void state_render(Presentation_State *state) { // etc.. // Modify 'ctx->session_settings'. - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 0), 128, BUTTON_HEIGHT }, "#191#Play")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 0), 128, BUTTON_HEIGHT }, "Play")) { // Set up the ingame-context and transition to the ingame-state. // NOTE: SS - We might need to wait before transitioning when playing multiplayer. game_session_create( @@ -102,7 +104,7 @@ static void state_render(Presentation_State *state) { presentation_state_machine_go_to(&presentation_state_ingame); } - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 1), 128, BUTTON_HEIGHT }, "#191#Cancel")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 1), 128, BUTTON_HEIGHT }, "Cancel")) { ctx->mode = ctx->is_singleplayer ? Main_Menu_Mode_Home : Main_Menu_Mode_Multiplayer; } @@ -111,11 +113,11 @@ static void state_render(Presentation_State *state) { case Main_Menu_Mode_Multiplayer_Join: { // TODO: SS - Add text-input here so the player can specify what session to try connecting to. - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 1), 128, BUTTON_HEIGHT }, "#191#Connect")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 1), 128, BUTTON_HEIGHT }, "Connect")) { printf("TODO: SS - Connect to session id.\n"); } - if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 2), 128, BUTTON_HEIGHT }, "#191#Cancel")) { + if (GuiButton((Rectangle){ 64, 64 + (BUTTON_HEIGHT * 2), 128, BUTTON_HEIGHT }, "Cancel")) { ctx->mode = Main_Menu_Mode_Multiplayer; } diff --git a/src/session/game_session.c b/src/session/game_session.c index 57f706f..3ae1910 100644 --- a/src/session/game_session.c +++ b/src/session/game_session.c @@ -79,7 +79,7 @@ void game_session_destroy() { void game_session_init_default_settings(bool is_singleplayer, Game_Session_Settings *out_settings) { out_settings->seed = 1337; // TODO: SS - Randomize. out_settings->tickrate = 10.0; - out_settings->level_width = 32; + out_settings->level_width = 64; out_settings->level_height = 32; out_settings->max_players = is_singleplayer ? 1 : 8; } diff --git a/src/shared/entity.h b/src/shared/entity.h index 6cdda97..95014c5 100644 --- a/src/shared/entity.h +++ b/src/shared/entity.h @@ -38,8 +38,6 @@ typedef struct { Entity_Movement_Direction move_direction; Entity_ID child; - - // TODO: SS - Color/tint? } Entity; #endif \ No newline at end of file