Implements environment chunks that form game maps and rooms. More...
Go to the source code of this file.
Classes | |
| struct | EnvironmentChunk |
| Represents a chunk of the environment. More... | |
Macros | |
| #define | HALLWAY_SIZE_TILE 6 |
| Width/height of hallway in tiles. | |
| #define | CHUNK_SIZE_TILE 60 |
| Size of a chunk in tiles. | |
| #define | CHUNK_SIZE_PIXEL (CHUNK_SIZE_TILE * TILE_SIZE_PIXELS) |
| Size of a chunk in pixels. | |
| #define | HALLWAY_START (CHUNK_SIZE_TILE - HALLWAY_SIZE_TILE) / 2 |
| Starting position of hallway within a chunk. | |
| #define | HALLWAY_END HALLWAY_START + HALLWAY_SIZE_TILE |
| Ending position of hallway within a chunk. | |
| #define | ROOM_STARTX(roomsize) (CHUNK_SIZE_TILE - (roomsize).x) / 2 |
| Starting X position of a room based on its size. | |
| #define | ROOM_STARTY(roomsize) (CHUNK_SIZE_TILE - (roomsize).y) / 2 |
| Starting Y position of a room based on its size. | |
| #define | ROOM_ENDX(roomsize) ROOM_STARTX(roomsize) + (roomsize).x |
| Ending X position of a room based on its size. | |
| #define | ROOM_ENDY(roomsize) ROOM_STARTY(roomsize) + (roomsize).y |
| Ending Y position of a room based on its size. | |
Enumerations | |
| enum | RoomHallways { HALLWAY_NONE = 0 , HALLWAY_UP = 1 << 0 , HALLWAY_DOWN = 1 << 1 , HALLWAY_LEFT = 1 << 2 , HALLWAY_RIGHT = 1 << 3 } |
| Possible hallways directions in a room. More... | |
| enum | RoomFloorPattern { ROOM_FLOOR_PATTERN_1 , ROOM_FLOOR_PATTERN_RANDOM } |
| Possible floor patterns in a room. More... | |
| enum | RoomType { ROOM_TYPE_START , ROOM_TYPE_NORMAL , ROOM_TYPE_BOSS , ROOM_TYPE_END , ROOM_TYPE_CRATE } |
| Possible types of rooms. More... | |
Functions | |
| EnvironmentChunk | Chunk_GenerateTiles (Vec2 position, RoomType roomType, Vec2 roomSize, RoomFloorPattern floorPattern, RoomHallways hallways) |
| Generates tiles for a chunk. | |
| void | Chunk_GenerateTilesButVoid (EnvironmentChunk *chunk) |
| Generates void tiles for a chunk. | |
| void | Chunk_GenerateFloorTiles (EnvironmentChunk *chunk) |
| Generates floor tiles for a chunk. | |
| void | Chunk_GenerateWallTiles (EnvironmentChunk *chunk) |
| Generates wall tiles for a chunk. | |
| void | Chunk_GenerateHallways (EnvironmentChunk *chunk) |
| Generates hallways for a chunk. | |
| void | Chunk_GenerateHallwayWallTiles (EnvironmentChunk *chunk) |
| Generates hallway wall tiles for a chunk. | |
| void | Chunk_GenerateColliders (EnvironmentChunk *chunk) |
| Generates colliders for a chunk. | |
| void | Chunk_AddWallCollider (Vec2 startTile, Vec2 endtile, EnvironmentChunk *chunk) |
| Adds a wall collider to a chunk. | |
| void | Chunk_AddRoomTrigger (Vec2 startTile, Vec2 endtile, EnvironmentChunk *chunk) |
| Adds a room trigger to a chunk. | |
| void | Chunk_AddHallwayTrigger (Vec2 startTile, Vec2 endtile, EnvironmentChunk *chunk) |
| Adds a hallway trigger to a chunk. | |
| void | Chunk_AddEndTrigger (Vec2 startTile, Vec2 endtile, EnvironmentChunk *chunk) |
| Adds an end trigger to a chunk. | |
| void | Chunk_HandlePlayerInsideRoom () |
| Handles player inside a room. | |
| void | Chunk_HandlePlayerInsideHallway () |
| Handles player inside a hallway. | |
| void | Chunk_HandlePlayerInsideEnd () |
| Handles player inside the end. | |
| void | Chunk_Start () |
| Starts the chunk. | |
| void | Chunk_Render (const EnvironmentChunk *chunk) |
| Renders the chunk. | |
| EnvironmentChunk * | Chunk_GetCurrentChunk (Vec2 position) |
| Gets the current chunk based on position. | |
| Vec2 | Chunk_GetChunkCenter (EnvironmentChunk *chunk) |
| Gets the center of the chunk. | |
| Vec2 | Chunk_GetRandomTileInRoom (EnvironmentChunk *chunk) |
| Gets a random tile in the room. | |
| Vec2 | Chunk_GetRandomTileCenterInRoom (EnvironmentChunk *chunk) |
| Gets a random tile center in the room. | |
| bool | Chunk_IsValid (Vec2 chunkIndex) |
| Checks if a chunk index is valid. | |
| bool | Chunk_IsOnMainPath (EnvironmentChunk *chunk) |
| Vec2 | Chunk_GetRoomTopLeft (EnvironmentChunk *chunk) |
| Gets the top-left corner of the current room in the current chunk. | |
| Vec2 | Chunk_GetRoomBottomRight (EnvironmentChunk *chunk) |
| Gets the bottom-right corner of the current room in the current chunk. | |
Implements environment chunks that form game maps and rooms.
| #define CHUNK_SIZE_PIXEL (CHUNK_SIZE_TILE * TILE_SIZE_PIXELS) |
Size of a chunk in pixels.
| #define CHUNK_SIZE_TILE 60 |
Size of a chunk in tiles.
| #define HALLWAY_END HALLWAY_START + HALLWAY_SIZE_TILE |
Ending position of hallway within a chunk.
| #define HALLWAY_SIZE_TILE 6 |
Width/height of hallway in tiles.
| #define HALLWAY_START (CHUNK_SIZE_TILE - HALLWAY_SIZE_TILE) / 2 |
Starting position of hallway within a chunk.
| #define ROOM_ENDX | ( | roomsize | ) | ROOM_STARTX(roomsize) + (roomsize).x |
Ending X position of a room based on its size.
| #define ROOM_ENDY | ( | roomsize | ) | ROOM_STARTY(roomsize) + (roomsize).y |
Ending Y position of a room based on its size.
| #define ROOM_STARTX | ( | roomsize | ) | (CHUNK_SIZE_TILE - (roomsize).x) / 2 |
Starting X position of a room based on its size.
| #define ROOM_STARTY | ( | roomsize | ) | (CHUNK_SIZE_TILE - (roomsize).y) / 2 |
Starting Y position of a room based on its size.
| enum RoomFloorPattern |
| enum RoomHallways |
| enum RoomType |
| void Chunk_AddEndTrigger | ( | Vec2 | startTile, |
| Vec2 | endTile, | ||
| EnvironmentChunk * | chunk | ||
| ) |
Adds an end trigger to a chunk.
| startTile | Starting tile of the end |
| endtile | Ending tile of the end |
| chunk | Pointer to the chunk |
Adds an end trigger to a chunk.
Creates a trigger zone in the center of the end room that detects when the player has reached the level exit.
| startTile | Starting tile position |
| endTile | Ending tile position |
| chunk | Pointer to the chunk |
| void Chunk_AddHallwayTrigger | ( | Vec2 | startTile, |
| Vec2 | endTile, | ||
| EnvironmentChunk * | chunk | ||
| ) |
Adds a hallway trigger to a chunk.
| startTile | Starting tile of the hallway |
| endtile | Ending tile of the hallway |
| chunk | Pointer to the chunk |
Adds a hallway trigger to a chunk.
Creates a trigger zone that detects when the player is inside a hallway.
| startTile | Starting tile position |
| endTile | Ending tile position |
| chunk | Pointer to the chunk |
| void Chunk_AddRoomTrigger | ( | Vec2 | startTile, |
| Vec2 | endTile, | ||
| EnvironmentChunk * | chunk | ||
| ) |
Adds a room trigger to a chunk.
| startTile | Starting tile of the room |
| endtile | Ending tile of the room |
| chunk | Pointer to the chunk |
Adds a room trigger to a chunk.
Creates a trigger zone that detects when the player is inside a room.
| startTile | Starting tile position |
| endTile | Ending tile position |
| chunk | Pointer to the chunk |
| void Chunk_AddWallCollider | ( | Vec2 | startTile, |
| Vec2 | endTile, | ||
| EnvironmentChunk * | chunk | ||
| ) |
Adds a wall collider to a chunk.
| startTile | Starting tile of the wall |
| endtile | Ending tile of the wall |
| chunk | Pointer to the chunk |
Adds a wall collider to a chunk.
Creates a physical collision box for walls at the specified location.
| startTile | Starting tile position of the wall |
| endTile | Ending tile position of the wall |
| chunk | Pointer to the chunk |
| void Chunk_GenerateColliders | ( | EnvironmentChunk * | chunk | ) |
Generates colliders for a chunk.
| chunk | Pointer to the chunk |
Generates colliders for a chunk.
Creates colliders for walls and hallways, as well as trigger zones for room and hallway detection.
| chunk | Pointer to the chunk |
| void Chunk_GenerateFloorTiles | ( | EnvironmentChunk * | chunk | ) |
Generates floor tiles for a chunk.
| chunk | Pointer to the chunk |
Generates floor tiles for a chunk.
Creates the base floor tiles for a room based on its size and floor pattern.
| chunk | Pointer to the chunk |
| void Chunk_GenerateHallways | ( | EnvironmentChunk * | chunk | ) |
Generates hallways for a chunk.
| chunk | Pointer to the chunk |
Generates hallways for a chunk.
Creates floor tiles for hallways based on the room's hallway configuration.
| chunk | Pointer to the chunk |
| void Chunk_GenerateHallwayWallTiles | ( | EnvironmentChunk * | chunk | ) |
Generates hallway wall tiles for a chunk.
| chunk | Pointer to the chunk |
Generates hallway wall tiles for a chunk.
Creates wall tiles along the sides of hallways with appropriate corner pieces at junctions.
| chunk | Pointer to the chunk |
| EnvironmentChunk Chunk_GenerateTiles | ( | Vec2 | position, |
| RoomType | roomType, | ||
| Vec2 | roomSize, | ||
| RoomFloorPattern | floorPattern, | ||
| RoomHallways | hallways | ||
| ) |
Generates tiles for a chunk.
| position | Position of the chunk |
| roomType | Type of the room |
| roomSize | Size of the room |
| floorPattern | Floor pattern of the room |
| hallways | Hallways in the room |
Generates tiles for a chunk.
Creates a fully-formed environment chunk with all necessary components including floor tiles, walls, hallways, and collision boxes.
| position | World position of the chunk |
| roomType | Type of room to generate (start, normal, boss, end) |
| roomSize | Size of the room in tiles |
| floorPattern | Pattern to use for floor tiles |
| hallways | Configuration of hallways connected to this room |
| void Chunk_GenerateTilesButVoid | ( | EnvironmentChunk * | chunk | ) |
Generates void tiles for a chunk.
| chunk | Pointer to the chunk |
Generates void tiles for a chunk.
Clears all existing tiles and colliders from a chunk and regenerates them, useful when hallway configurations change or room state changes.
| chunk | Pointer to the chunk to regenerate |
| void Chunk_GenerateWallTiles | ( | EnvironmentChunk * | chunk | ) |
Generates wall tiles for a chunk.
| chunk | Pointer to the chunk |
Generates wall tiles for a chunk.
Creates wall tiles around the room perimeter using appropriate wall sprites with correct rotations.
| chunk | Pointer to the chunk |
| Vec2 Chunk_GetChunkCenter | ( | EnvironmentChunk * | chunk | ) |
| EnvironmentChunk * Chunk_GetCurrentChunk | ( | Vec2 | position | ) |
Gets the current chunk based on position.
| position | Position to get the chunk |
Gets the current chunk based on position.
| position | World position to check |
| Vec2 Chunk_GetRandomTileCenterInRoom | ( | EnvironmentChunk * | chunk | ) |
| Vec2 Chunk_GetRandomTileInRoom | ( | EnvironmentChunk * | chunk | ) |
| Vec2 Chunk_GetRoomBottomRight | ( | EnvironmentChunk * | chunk | ) |
Gets the bottom-right corner of the current room in the current chunk.
| chunk | Pointer to the chunk containing the room |
Gets the bottom-right corner of the current room in the current chunk.
| chunk | Pointer to the chunk containing the room |
| Vec2 Chunk_GetRoomTopLeft | ( | EnvironmentChunk * | chunk | ) |
Gets the top-left corner of the current room in the current chunk.
| chunk | Pointer to the chunk containing the room |
Gets the top-left corner of the current room in the current chunk.
| chunk | Pointer to the chunk containing the room |
| void Chunk_HandlePlayerInsideEnd | ( | ) |
Handles player inside the end.
Handles player inside the end.
Updates player state to indicate they have reached the end of the level, enabling level completion functionality.
| void Chunk_HandlePlayerInsideHallway | ( | ) |
Handles player inside a hallway.
Handles player inside a hallway.
Updates player state to indicate they are inside a hallway, which affects combat and movement.
| void Chunk_HandlePlayerInsideRoom | ( | ) |
Handles player inside a room.
Handles player inside a room.
Updates player state to indicate they are inside a room, which affects combat and other game systems.
| bool Chunk_IsOnMainPath | ( | EnvironmentChunk * | chunk | ) |
| bool Chunk_IsValid | ( | Vec2 | chunkIndex | ) |
Checks if a chunk index is valid.
| chunkIndex | Chunk index to check |
Checks if a chunk index is valid.
| chunkIndex | Index of the chunk to check |
| void Chunk_Render | ( | const EnvironmentChunk * | chunk | ) |
Renders the chunk.
| chunk | Pointer to the chunk |
| void Chunk_Start | ( | ) |
Starts the chunk.