diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/game.c | 5 | ||||
| -rw-r--r-- | src/game.h | 2 | ||||
| -rw-r--r-- | src/map.c | 35 | ||||
| -rw-r--r-- | src/map.h | 16 | ||||
| -rw-r--r-- | src/settings.c | 2 | ||||
| -rw-r--r-- | src/settings.h | 4 | ||||
| -rw-r--r-- | src/world.c | 1 |
7 files changed, 65 insertions, 0 deletions
@@ -82,6 +82,9 @@ void initGame(Game* game) game->player.camera.fovy = game->settings.fov; game->player.position = Vector3Scale(game->world.size, 0.5); + // Map. + initMap(&game->map, &game->settings); + disableGameCursor(game); } @@ -182,6 +185,8 @@ void updateGameScene(Game* game) drawGameScreen(game); + updateMap(&game->map, game); + // Cross hair. if (IsKeyPressed(game->settings.toggleCrossHairKey)) { @@ -4,6 +4,7 @@ #include "player.h" #include "world.h" #include "entity.h" +#include "map.h" #ifndef GAME_H #define GAME_H @@ -22,6 +23,7 @@ struct Game { Player player; World world; Model skybox; + Map map; SceneId sceneId; bool isCursorEnabled; diff --git a/src/map.c b/src/map.c new file mode 100644 index 0000000..ebcb077 --- /dev/null +++ b/src/map.c @@ -0,0 +1,35 @@ +#include "map.h" +#include "game.h" + +void repositionMap(Map* map) +{ + map->rect.x = GetRenderWidth() - map->rect.width; +} + +void initMap(Map* map, const Settings* settings) +{ + *map = (Map){ + .rect = (Rectangle){0.0, 0.0, settings->mapPreviewSize, + settings->mapPreviewSize}, + .isEnabled = settings->isMapPreviewEnabledDefault, + .isFullSize = false + }; + + repositionMap(map); +} + +void updateMap(Map* map, Game* game) +{ + // Handle window resize. + if (IsWindowResized()) + { + repositionMap(map); + } + + if (!map->isEnabled) + { + return; + } + + DrawRectangleLinesEx(map->rect, 3.0, BLUE); +} diff --git a/src/map.h b/src/map.h new file mode 100644 index 0000000..ce4e71e --- /dev/null +++ b/src/map.h @@ -0,0 +1,16 @@ +#include "utils.h" +#include "settings.h" + +#ifndef MAP_H +#define MAP_H + +typedef struct { + Rectangle rect; + bool isEnabled; + bool isFullSize; +} Map; + +void initMap(Map* map, const Settings* settings); +void updateMap(Map* map, Game* game); + +#endif diff --git a/src/settings.c b/src/settings.c index 3171811..26caa73 100644 --- a/src/settings.c +++ b/src/settings.c @@ -18,6 +18,8 @@ Settings defaultSettings() .crossHairSize = 8.0, .crossHairThickness = 3.0, .crossHairColor = BLUE, + .isMapPreviewEnabledDefault = true, + .mapPreviewSize = 300.0, .mouseSpeed = 0.1, .forwardKey = KEY_W, .backwardKey = KEY_S, diff --git a/src/settings.h b/src/settings.h index 468f402..118bf84 100644 --- a/src/settings.h +++ b/src/settings.h @@ -33,6 +33,10 @@ typedef struct { float crossHairThickness; Color crossHairColor; + // Map. + bool isMapPreviewEnabledDefault; + float mapPreviewSize; + // Controls. float mouseSpeed; KeyboardKey forwardKey; diff --git a/src/world.c b/src/world.c index 6f2e093..a6fdf24 100644 --- a/src/world.c +++ b/src/world.c @@ -516,6 +516,7 @@ void generateWorldSamanthasPlace(World* world, const Assets* assets, Entity samantha = createEntity(SAMANTHA, Vector3Add(center, SAMANTHA_OFFSET)); world->entities[*placeId] = samantha; + *placeId = *placeId + 1; // Trashcans yippee! Vector3 trashPosition = (Vector3){-SAMANTHAS_SPOT, |
