Minor things.

This commit is contained in:
2025-12-12 19:14:38 +01:00
parent a6d8d7d0c2
commit 11e91aa01c
4 changed files with 26 additions and 15 deletions

View File

@@ -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;
@@ -217,6 +219,15 @@ static void state_render(Presentation_State *state) {
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;
}
case Entity_Type_Snake_Body: {
@@ -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(

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -38,8 +38,6 @@ typedef struct {
Entity_Movement_Direction move_direction;
Entity_ID child;
// TODO: SS - Color/tint?
} Entity;
#endif