Setup rpg stuff
This commit is contained in:
54
src/rpg/world/worldunit.h
Normal file
54
src/rpg/world/worldunit.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
|
||||
/**
|
||||
* Position in SUBTILE space in a world, each unit represents a single subtile.
|
||||
* This is divided by the size of the tile, e.g. if a tile is 16x16 then there
|
||||
* are 256 / tile size = units per pixel of a tile. This means there are always
|
||||
* uint8_t max subtiles in a tile.
|
||||
*/
|
||||
typedef uint8_t worldsubtile_t;
|
||||
|
||||
/**
|
||||
* Position in TILE space in a world, each unit represents a single tile. This
|
||||
* is within CHUNK space. This is not different depending on chunk size, if the
|
||||
* chunks are 32 tiles wide then the max tile value is 31.
|
||||
*/
|
||||
typedef uint8_t worldtile_t;
|
||||
|
||||
/**
|
||||
* Represents a position in a world in SUBTILE and TILE space. This is basically
|
||||
* just a convenience struct so you don't have to pass two variables around.
|
||||
*
|
||||
* For example, an entity may be at tile (2, 3) and subtile (8, 12).
|
||||
* meaning that the entity is at pixel (2 * TILE_SIZE + 8, 3 * TILE_SIZE + 12)
|
||||
* in world space.
|
||||
*
|
||||
* This is still within CHUNK space.
|
||||
*/
|
||||
typedef struct worldchunkpos_s {
|
||||
worldsubtile_t subtile;
|
||||
worldtile_t tile;
|
||||
} worldchunkpos_t;
|
||||
|
||||
/**
|
||||
* Position in CHUNK space in a world, each unit represents a single chunk.
|
||||
*/
|
||||
typedef uint8_t worldchunk_t;
|
||||
|
||||
/**
|
||||
* Represents a position in a world in SUBTILE, TILE and CHUNK space. This is in
|
||||
* WORLD space, so this is the full position of an entity in the world.
|
||||
*/
|
||||
typedef struct worldpos_s {
|
||||
worldsubtile_t subtile;
|
||||
worldtile_t tile;
|
||||
worldchunk_t chunk;
|
||||
} worldpos_t;
|
||||
Reference in New Issue
Block a user