Body-part now follows it's parent. You can also eat food. Shortcut in the main-menu to play default singleplayer, press P.

This commit is contained in:
2025-12-12 13:21:05 +01:00
parent 0045d2788c
commit 2a0e5779cb
7 changed files with 177 additions and 10 deletions

View File

@@ -10,6 +10,8 @@
#include "session/game_session.h"
#include "shared/wang_hash.h"
#define GRID_CELL_SIZE 8
#define ENTITY_PRESENTATION_Y_OFFSET -2
@@ -84,6 +86,10 @@ static void state_tick(Presentation_State *state) {
}
}
uint32_t floor_texture_variant(uint32_t x, uint32_t y, uint32_t seed, uint32_t num_variants) {
return (wang_hash(x * 73856093u ^ y * 19349663u ^ seed)) % num_variants;
}
static void state_render(Presentation_State *state) {
Presentation_State_Ingame_Context *ctx = (Presentation_State_Ingame_Context *)state->context;
(void)ctx;
@@ -108,7 +114,7 @@ static void state_render(Presentation_State *state) {
uint32_t pres_x = x * GRID_CELL_SIZE;
uint32_t pres_y = y * GRID_CELL_SIZE;
uint32_t random_floor_index = i; // TODO: SS - Get a deterministic random value based on seed.
uint32_t random_floor_index = floor_texture_variant(x, y, world->seed, 4);
DrawTextureRec(
ctx->texture_grass,
@@ -116,7 +122,7 @@ static void state_render(Presentation_State *state) {
(Vector2) { pres_x, pres_y },
WHITE
);
DrawRectangleLines(pres_x, pres_y, GRID_CELL_SIZE, GRID_CELL_SIZE, (Color) { 0, 0, 0, 8 });
DrawRectangleLines(pres_x, pres_y, GRID_CELL_SIZE, GRID_CELL_SIZE, (Color) { 0, 0, 0, 2 }); // TODO: SS - Let the user customize the alpha locally.
}
for(uint32_t i = 0; i < grid_total_size; i++) {
@@ -159,6 +165,30 @@ static void state_render(Presentation_State *state) {
(Color) { 0, 0, 0, 32 }
);
float rotation = 0.0f;
switch(entity->move_direction){
case Entity_Movement_Direction_None: {
rotation = 0.0f;
break;
}
case Entity_Movement_Direction_Up: {
rotation = -90.0f;
break;
}
case Entity_Movement_Direction_Down: {
rotation = 90.0f;
break;
}
case Entity_Movement_Direction_Right: {
rotation = 0.0f;
break;
}
case Entity_Movement_Direction_Left: {
rotation = 180.0f;
break;
}
}
DrawTexturePro(
*texture,
(Rectangle) { // Source.
@@ -171,7 +201,7 @@ static void state_render(Presentation_State *state) {
GRID_CELL_SIZE
},
origin, // Origin.
0, // Rotation.
rotation, // Rotation.
tint // Tint.
);