From 0180e40326f67ef465e1d865a0aed21162e0f5c5 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 7 Jan 2026 04:21:32 -0700 Subject: At place thingy --- src/game.c | 24 ++++++++++++++++++++---- src/player.c | 16 +++++++++------- src/player.h | 1 + 3 files changed, 30 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/game.c b/src/game.c index fb5566d..fb7e01d 100644 --- a/src/game.c +++ b/src/game.c @@ -212,16 +212,31 @@ void updateGameStatus(Game* game) float width; float height; int fontSize = 20; - int lineCount = 2; - int maxColumns = 16; + int lineCount = 3; + int maxColumns = 24; float maxWidth = maxColumns * fontSize / 2.0; - bool topBarStyle = game->screen.destination.x < maxWidth; + bool topBarStyle = game->screen.destination.x < maxWidth / 2.0; const char* spacer = topBarStyle ? ", " : "\n"; + // Format text. + char placeAt[ENTITY_NAME_MAX] = "Back woods"; + WorldUID place = game->player.place; + + if (place != ENTITY_NONE) + { + strncpy(placeAt, getEntityName(game->world.entities[place].id), + ENTITY_NAME_MAX - 1); + } + const char* text = TextFormat( - "Speed %d kps%sPee level: 7", (int)roundf(game->player.speed), spacer); + "At: %s%sSpeed %d%sPee level: 7", + placeAt, + spacer, + (int)roundf(game->player.speed), + spacer); + // Handle bar style. if (topBarStyle) // Top bar style. { x = 110.0; @@ -237,6 +252,7 @@ void updateGameStatus(Game* game) height = fontSize * lineCount; } + // Draw text and background. Color backgroundColor = PINK; backgroundColor.a = game->settings.statusAndInfoAlpha; DrawRectangle(x, y, width, height, backgroundColor); diff --git a/src/player.c b/src/player.c index df59ffe..fd33524 100644 --- a/src/player.c +++ b/src/player.c @@ -26,6 +26,7 @@ Player createPlayer() .projection = CAMERA_PERSPECTIVE }, .cameraAngle = Vector2Zero(), + .place = ENTITY_NONE, .selectedEntity = ENTITY_NONE, .isInteracting = false }; @@ -59,15 +60,14 @@ void updatePlayerLookingAround(Player* player, Game* game) player->direction = (Vector3){matrix.m2, matrix.m6, matrix.m10}; } -WorldUID playerCheckCollisionWithBuildings(Player* player, Game* game) +WorldUID playerCheckCollisionWithPlace(Player* player, Game* game) { for (int index = 0; index < WORLD_PLACE_COUNT; ++index) { WorldUID uid = game->world.places[index]; Entity* place = &game->world.entities[uid]; - if (entityIsBuilding(place->id) - && CheckCollisionBoxes(place->box, player->box)) + if (CheckCollisionBoxes(place->box, player->box)) { return uid; } @@ -449,12 +449,14 @@ void updatePlayer(Player* player, Game* game) updatePlayerMovement(player, game); - // Check collision with buildings. - WorldUID buildingUID = playerCheckCollisionWithBuildings(player, game); + WorldUID placeUID = playerCheckCollisionWithPlace(player, game); + player->place = placeUID; - if (buildingUID != ENTITY_NONE) + // Collision with buildings. + if (placeUID != ENTITY_NONE && + entityIsBuilding(game->world.entities[placeUID].id)) { - playerHandleCollisionWithBuilding(player, game, buildingUID); + playerHandleCollisionWithBuilding(player, game, placeUID); } playerApplyVelocity(player); diff --git a/src/player.h b/src/player.h index 3edec59..2a0f8cc 100644 --- a/src/player.h +++ b/src/player.h @@ -28,6 +28,7 @@ typedef struct { Camera camera; Vector2 cameraAngle; + WorldUID place; WorldUID selectedEntity; bool isInteracting; } Player; -- cgit v1.2.3