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

Creates and initializes environment chunks. More...

#include <chunks.h>
#include <enemy.h>
#include <enemy_types.h>
#include <random.h>
#include <player.h>

Functions

EnvironmentChunk Chunk_GenerateTiles (Vec2 position, RoomType roomType, Vec2 roomSize, RoomFloorPattern floorPattern, RoomHallways hallways)
 [Utility] Generates a complete chunk with tiles, hallways, and colliders
 
void Chunk_GenerateTilesButVoid (EnvironmentChunk *chunk)
 [Utility] Regenerates all tiles for an existing chunk
 
void Chunk_GenerateFloorTiles (EnvironmentChunk *chunk)
 [Utility] Generates floor tiles for a chunk
 
void Chunk_GenerateHallways (EnvironmentChunk *chunk)
 [Utility] Generates hallway tiles for a chunk
 
void Chunk_GenerateWallTiles (EnvironmentChunk *chunk)
 [Utility] Generates wall tiles for a chunk
 
void Chunk_GenerateHallwayWallTiles (EnvironmentChunk *chunk)
 [Utility] Generates wall tiles for hallways
 
void Chunk_GenerateColliders (EnvironmentChunk *chunk)
 [Utility] Generates collision boxes for a chunk
 
void Chunk_AddWallCollider (Vec2 startTile, Vec2 endTile, EnvironmentChunk *chunk)
 [Utility] Adds a wall collider to a chunk
 
void Chunk_HandlePlayerInsideRoom ()
 [Event Handler] Event handler for when player enters a room
 
void Chunk_HandlePlayerInsideHallway ()
 [Event Handler] Event handler for when player enters a hallway
 
void Chunk_HandlePlayerInsideEnd ()
 [Event Handler] Event handler for when player enters an end room
 
void Chunk_AddRoomTrigger (Vec2 startTile, Vec2 endTile, EnvironmentChunk *chunk)
 [Utility] Adds a room trigger collider to a chunk
 
void Chunk_AddHallwayTrigger (Vec2 startTile, Vec2 endTile, EnvironmentChunk *chunk)
 [Utility] Adds a hallway trigger collider to a chunk
 
void Chunk_AddEndTrigger (Vec2 startTile, Vec2 endTile, EnvironmentChunk *chunk)
 [Utility] Adds an end room trigger collider to a chunk
 

Detailed Description

Creates and initializes environment chunks.

Handles the procedural generation of chunk tiles, walls, and collision boundaries based on chunk parameters.

Author
Mango
Date
2025-03-03

Function Documentation

◆ Chunk_AddEndTrigger()

void Chunk_AddEndTrigger ( Vec2  startTile,
Vec2  endTile,
EnvironmentChunk *  chunk 
)

[Utility] Adds an end room trigger collider to a 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.

Parameters
startTileStarting tile position
endTileEnding tile position
chunkPointer to the chunk

◆ Chunk_AddHallwayTrigger()

void Chunk_AddHallwayTrigger ( Vec2  startTile,
Vec2  endTile,
EnvironmentChunk *  chunk 
)

[Utility] Adds a hallway trigger collider to a chunk

Adds a hallway trigger to a chunk.

Creates a trigger zone that detects when the player is inside a hallway.

Parameters
startTileStarting tile position
endTileEnding tile position
chunkPointer to the chunk

◆ Chunk_AddRoomTrigger()

void Chunk_AddRoomTrigger ( Vec2  startTile,
Vec2  endTile,
EnvironmentChunk *  chunk 
)

[Utility] Adds a room trigger collider to a chunk

Adds a room trigger to a chunk.

Creates a trigger zone that detects when the player is inside a room.

Parameters
startTileStarting tile position
endTileEnding tile position
chunkPointer to the chunk

◆ Chunk_AddWallCollider()

void Chunk_AddWallCollider ( Vec2  startTile,
Vec2  endTile,
EnvironmentChunk *  chunk 
)

[Utility] Adds a wall collider to a chunk

Adds a wall collider to a chunk.

Creates a physical collision box for walls at the specified location.

Parameters
startTileStarting tile position of the wall
endTileEnding tile position of the wall
chunkPointer to the chunk

◆ Chunk_GenerateColliders()

void Chunk_GenerateColliders ( EnvironmentChunk *  chunk)

[Utility] Generates collision boxes for a chunk

Generates colliders for a chunk.

Creates colliders for walls and hallways, as well as trigger zones for room and hallway detection.

Parameters
chunkPointer to the chunk

◆ Chunk_GenerateFloorTiles()

void Chunk_GenerateFloorTiles ( EnvironmentChunk *  chunk)

[Utility] Generates floor tiles for a chunk

Generates floor tiles for a chunk.

Creates the base floor tiles for a room based on its size and floor pattern.

Parameters
chunkPointer to the chunk

◆ Chunk_GenerateHallways()

void Chunk_GenerateHallways ( EnvironmentChunk *  chunk)

[Utility] Generates hallway tiles for a chunk

Generates hallways for a chunk.

Creates floor tiles for hallways based on the room's hallway configuration.

Parameters
chunkPointer to the chunk

◆ Chunk_GenerateHallwayWallTiles()

void Chunk_GenerateHallwayWallTiles ( EnvironmentChunk *  chunk)

[Utility] Generates wall tiles for hallways

Generates hallway wall tiles for a chunk.

Creates wall tiles along the sides of hallways with appropriate corner pieces at junctions.

Parameters
chunkPointer to the chunk

◆ Chunk_GenerateTiles()

EnvironmentChunk Chunk_GenerateTiles ( Vec2  position,
RoomType  roomType,
Vec2  roomSize,
RoomFloorPattern  floorPattern,
RoomHallways  hallways 
)

[Utility] Generates a complete chunk with tiles, hallways, and colliders

Generates tiles for a chunk.

Creates a fully-formed environment chunk with all necessary components including floor tiles, walls, hallways, and collision boxes.

Parameters
positionWorld position of the chunk
roomTypeType of room to generate (start, normal, boss, end)
roomSizeSize of the room in tiles
floorPatternPattern to use for floor tiles
hallwaysConfiguration of hallways connected to this room
Returns
EnvironmentChunk The fully generated chunk

◆ Chunk_GenerateTilesButVoid()

void Chunk_GenerateTilesButVoid ( EnvironmentChunk *  chunk)

[Utility] Regenerates all tiles for an existing 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.

Parameters
chunkPointer to the chunk to regenerate

◆ Chunk_GenerateWallTiles()

void Chunk_GenerateWallTiles ( EnvironmentChunk *  chunk)

[Utility] Generates wall tiles for a chunk

Generates wall tiles for a chunk.

Creates wall tiles around the room perimeter using appropriate wall sprites with correct rotations.

Parameters
chunkPointer to the chunk

◆ Chunk_HandlePlayerInsideEnd()

void Chunk_HandlePlayerInsideEnd ( )

[Event Handler] Event handler for when player enters an end room

Handles player inside the end.

Updates player state to indicate they have reached the end of the level, enabling level completion functionality.

◆ Chunk_HandlePlayerInsideHallway()

void Chunk_HandlePlayerInsideHallway ( )

[Event Handler] Event handler for when player enters a hallway

Handles player inside a hallway.

Updates player state to indicate they are inside a hallway, which affects combat and movement.

◆ Chunk_HandlePlayerInsideRoom()

void Chunk_HandlePlayerInsideRoom ( )

[Event Handler] Event handler for when player enters a room

Handles player inside a room.

Updates player state to indicate they are inside a room, which affects combat and other game systems.