Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
chunk_utils.c File Reference

Utility functions for environment chunks. More...

#include <maps.h>
#include <random.h>

Functions

bool Chunk_IsValid (Vec2 chunkIndex)
 [Utility] Checks if a chunk index is valid within the map bounds
 
EnvironmentChunk * Chunk_GetCurrentChunk (Vec2 position)
 [Utility] Gets the chunk at a specific world position
 
Vec2 Chunk_GetChunkCenter (EnvironmentChunk *chunk)
 Gets the center of the chunk.
 
Vec2 Chunk_GetRandomTileInRoom (EnvironmentChunk *chunk)
 [Utility] Gets a random tile position within a room's boundaries
 
Vec2 Chunk_GetRandomTileCenterInRoom (EnvironmentChunk *chunk)
 [Utility] Gets a random position at the center of a tile within a room
 
Vec2 Chunk_GetRoomTopLeft (EnvironmentChunk *chunk)
 [Utility] Gets the top-left corner of the current room in the current chunk
 
Vec2 Chunk_GetRoomBottomRight (EnvironmentChunk *chunk)
 [Utility] Gets the bottom-right corner of the current room in the current chunk
 
bool Chunk_IsOnMainPath (EnvironmentChunk *chunk)
 

Detailed Description

Utility functions for environment chunks.

Provides helper functions for chunk manipulation, validation, and coordinate conversions between world space and chunks.

Author
Mango
Date
2025-03-03

Function Documentation

◆ Chunk_GetChunkCenter()

Vec2 Chunk_GetChunkCenter ( EnvironmentChunk *  chunk)

Gets the center of the chunk.

Parameters
chunkPointer to the chunk
Returns
Vec2 Center of the chunk

◆ Chunk_GetCurrentChunk()

EnvironmentChunk * Chunk_GetCurrentChunk ( Vec2  position)

[Utility] Gets the chunk at a specific world position

Gets the current chunk based on position.

Parameters
positionWorld position to check
Returns
EnvironmentChunk* Pointer to the chunk at that position

◆ Chunk_GetRandomTileCenterInRoom()

Vec2 Chunk_GetRandomTileCenterInRoom ( EnvironmentChunk *  chunk)

[Utility] Gets a random position at the center of a tile within a room

Gets a random tile center in the room.

Parameters
chunkPointer to the chunk containing the room
Returns
Vec2 Random centered tile position in world coordinates

◆ Chunk_GetRandomTileInRoom()

Vec2 Chunk_GetRandomTileInRoom ( EnvironmentChunk *  chunk)

[Utility] Gets a random tile position within a room's boundaries

Gets a random tile in the room.

Parameters
chunkPointer to the chunk containing the room
Returns
Vec2 Random tile position in world coordinates

◆ Chunk_GetRoomBottomRight()

Vec2 Chunk_GetRoomBottomRight ( EnvironmentChunk *  chunk)

[Utility] Gets the bottom-right corner of the current room in the current chunk

Gets the bottom-right corner of the current room in the current chunk.

Parameters
chunkPointer to the chunk containing the room
Returns
Vec2 Bottom-right corner position in world coordinates

◆ Chunk_GetRoomTopLeft()

Vec2 Chunk_GetRoomTopLeft ( EnvironmentChunk *  chunk)

[Utility] Gets the top-left corner of the current room in the current chunk

Gets the top-left corner of the current room in the current chunk.

Parameters
chunkPointer to the chunk containing the room
Returns
Vec2 Top-left corner position in world coordinates

◆ Chunk_IsOnMainPath()

bool Chunk_IsOnMainPath ( EnvironmentChunk *  chunk)

◆ Chunk_IsValid()

bool Chunk_IsValid ( Vec2  chunkIndex)

[Utility] Checks if a chunk index is valid within the map bounds

Checks if a chunk index is valid.

Parameters
chunkIndexIndex of the chunk to check
Returns
bool True if the chunk is valid, false otherwise