Defines and manages environment tiles for game world construction. More...
Go to the source code of this file.
Classes | |
| struct | EnvironmentTile |
| Represents a single environment tile. More... | |
| struct | EnvironmentTileResources |
| Contains loaded textures for all tile types. More... | |
| struct | EnvironmentTileConfig |
| Configuration for tile resources. More... | |
| struct | EnvironmentTileData |
| Global tile data container. More... | |
Macros | |
| #define | TILE_SIZE_PIXELS 20 |
| Defines the size of a tile in pixels. | |
| #define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
| Safely calculates maximum of two values. | |
| #define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
| Safely calculates minimum of two values. | |
Enumerations | |
| enum | TileType { TILE_VOID , TILE_FLOOR_1 , TILE_FLOOR_2 , TILE_FLOOR_3 , TILE_FLOOR_VENT_1 , TILE_FLOOR_VENT_2 , TILE_FLOOR_VENT_3 , TILE_FLOOR_SCRATCHED_1 , TILE_FLOOR_SCRATCHED_2 , TILE_FLOOR_SCRATCHED_3 , TILE_WALL_TOP , TILE_WALL_BOTTOM , TILE_WALL_CORNER_BORDER_SMALL , TILE_WALL_CORNER_BORDER , TILE_WALL_SIDE_BORDER , TILE_TYPE_COUNT } |
| Defines various types of environment tiles. More... | |
| enum | TileRotation { TILE_ROTATE_NONE , TILE_ROTATE_CLOCKWISE , TILE_ROTATE_COUNTERCLOCKWISE , TILE_ROTATE_180 } |
| Defines rotation options for tiles. More... | |
Functions | |
| void | Tile_Start () |
| Initialize tile system. | |
| EnvironmentTile | Tile_Create (TileType type, TileRotation rotation) |
| Create a new environment tile. | |
| void | Tile_Destroy (EnvironmentTile *tile) |
| Destroy a tile and free resources. | |
| void | Tile_Render (EnvironmentTile tile, Vec2 tilePosition) |
| Render a tile at the specified position. | |
| void | Tile_FromPixelPoint (Vec2 pixelPoint, Vec2 *chunkIndex, Vec2 *tileIndex) |
| Convert a pixel coordinate to tile and chunk indices. | |
| bool | Tile_IsValid (Vec2 tileIndex) |
| Check if a tile index is valid. | |
| Vec2 | Tile_GetPositionFromPixel (Vec2 pixelPoint) |
| Convert a pixel coordinate to a tile position. | |
| SDL_Rect | Tile_GetRectFromPixel (Vec2 pixelPoint) |
| Get the rectangle of a tile from a pixel coordinate. | |
| Vec2 | Tile_GetRandomPixelInRect (SDL_Rect rect) |
| Get a random pixel coordinate within a rectangle. | |
| Vec2 | Tile_TileIndexToPixel (Vec2 tileIndex, Vec2 chunkIndex) |
| Convert tile and chunk indices to a pixel coordinate. | |
Variables | |
| EnvironmentTileData | tiles |
| Global tile data instance. | |
Defines and manages environment tiles for game world construction.
| #define MAX | ( | a, | |
| b | |||
| ) | ((a) > (b) ? (a) : (b)) |
Safely calculates maximum of two values.
| a | First value to compare |
| b | Second value to compare |
| #define MIN | ( | a, | |
| b | |||
| ) | ((a) < (b) ? (a) : (b)) |
Safely calculates minimum of two values.
| a | First value to compare |
| b | Second value to compare |
| #define TILE_SIZE_PIXELS 20 |
Defines the size of a tile in pixels.
| enum TileRotation |
| enum TileType |
Defines various types of environment tiles.
| EnvironmentTile Tile_Create | ( | TileType | type, |
| TileRotation | rotation | ||
| ) |
Create a new environment tile.
| type | The type of tile to create |
| rotation | The rotation to apply to the tile |
Create a new environment tile.
Factory function that constructs a tile with the appropriate texture and rotation.
| type | The type of tile to create |
| rotation | The rotation to apply to the tile |
| void Tile_Destroy | ( | EnvironmentTile * | tile | ) |
Destroy a tile and free resources.
| tile | Pointer to the tile to destroy |
Convert a pixel coordinate to tile and chunk indices.
| pixelPoint | The pixel coordinate to convert |
| chunkIndex | Output parameter for the chunk index |
| tileIndex | Output parameter for the tile index |
Convert a pixel coordinate to tile and chunk indices.
Takes a world-space pixel coordinate and determines which tile and chunk it belongs to.
| pixelPoint | The world position in pixels |
| chunkIndex | Output parameter for the chunk index |
| tileIndex | Output parameter for the tile index within the chunk |
Convert a pixel coordinate to a tile position.
| pixelPoint | The pixel coordinate to convert |
Convert a pixel coordinate to a tile position.
| pixelPoint | The pixel coordinates to convert |
| Vec2 Tile_GetRandomPixelInRect | ( | SDL_Rect | rect | ) |
Get a random pixel coordinate within a rectangle.
| rect | The rectangle to get a random pixel from |
Get a random pixel coordinate within a rectangle.
| rect | The rectangle to get a random point within |
| SDL_Rect Tile_GetRectFromPixel | ( | Vec2 | pixelPoint | ) |
Get the rectangle of a tile from a pixel coordinate.
| pixelPoint | The pixel coordinate |
Get the rectangle of a tile from a pixel coordinate.
| pixelPoint | The pixel coordinates within the tile |
| bool Tile_IsValid | ( | Vec2 | tileIndex | ) |
Check if a tile index is valid.
| tileIndex | The tile index to check |
Check if a tile index is valid.
| tileIndex | The tile index to check |
| void Tile_Render | ( | EnvironmentTile | tile, |
| Vec2 | tilePosition | ||
| ) |
Render a tile at the specified position.
| tile | The tile to render |
| tilePosition | Position where the tile should be rendered |
| void Tile_Start | ( | ) |
Initialize tile system.
Initialize tile system.
Loads all tile textures from disk and creates texture resources for each tile type.
Convert tile and chunk indices to a pixel coordinate.
| tileIndex | The tile index |
| chunkIndex | The chunk index |
Convert tile and chunk indices to a pixel coordinate.
| tileIndex | The tile index within the chunk |
| chunkIndex | The chunk index |
|
extern |
Global tile data instance.