Refactored.
This commit is contained in:
23
include/dawn/world/entity/entity.h
Normal file
23
include/dawn/world/entity/entity.h
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
|
||||
#define ENTITY_COUNT 64
|
||||
|
||||
typedef struct {
|
||||
int32_t gridX, gridY, gridZ;
|
||||
int32_t oldGridX, oldGridY, oldGridZ;
|
||||
float positionX, positionY, positionZ;
|
||||
} entity_t;
|
||||
|
||||
typedef struct {
|
||||
entity_t entities[ENTITY_COUNT]
|
||||
} entitystate_t;
|
||||
|
||||
extern entitystate_t ENTITY_STATE;
|
33
include/dawn/world/map/chunk.h
Normal file
33
include/dawn/world/map/chunk.h
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2021 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../display/primitive.h"
|
||||
#include "tile.h"
|
||||
|
||||
/** When loading a chunk, how many chars to offset (ASCII char to byte) */
|
||||
#define CHUNK_TILE_LOAD_ASCII 48
|
||||
|
||||
/** Width (in tiles) of chunks. */
|
||||
#define CHUNK_WIDTH 16
|
||||
/** Height (in tiles) of chunks. */
|
||||
#define CHUNK_HEIGHT 16
|
||||
/** Depth (in tiles) of chunks. */
|
||||
#define CHUNK_DEPTH 8
|
||||
/** Count of tiles in the chunk. */
|
||||
#define CHUNK_TILE_COUNT CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH
|
||||
|
||||
/** Representation of a chunk, a group of tiles that can be buffered around. */
|
||||
typedef struct {
|
||||
/** Position (in absolute chunk coordinates) of this chunk */
|
||||
int32_t x, y, z;
|
||||
|
||||
/** Array of tiles within the chunk */
|
||||
tileid_t tiles[CHUNK_TILE_COUNT];
|
||||
|
||||
/** Ready to be rendered chunk 3d primitive */
|
||||
primitive_t *primitive;
|
||||
} chunk_t;
|
46
include/dawn/world/map/map.h
Normal file
46
include/dawn/world/map/map.h
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "tile.h"
|
||||
#include "chunk.h"
|
||||
#include "../../display/texture.h"
|
||||
#include "../../display/tileset.h"
|
||||
|
||||
/** Width of map (in chunks) */
|
||||
#define MAP_WIDTH 3
|
||||
/** Height of map (in chunks) */
|
||||
#define MAP_HEIGHT MAP_WIDTH
|
||||
/** Depth of map (in chunks) */
|
||||
#define MAP_DEPTH 2
|
||||
/** Count of chunks in the world */
|
||||
#define MAP_CHUNK_COUNT MAP_WIDTH * MAP_HEIGHT * MAP_DEPTH
|
||||
|
||||
#define MAP_ASSET_TEXTURE "world/tileset.png"
|
||||
|
||||
typedef struct {
|
||||
/** Tile definitions */
|
||||
tiledef_t *tileDefinitions;
|
||||
|
||||
/** Tileset predivided */
|
||||
tileset_t *tileset;
|
||||
|
||||
/** Texture of the tileset */
|
||||
texture_t *texture;
|
||||
|
||||
/** Current (chunk) coordinates of the first chunk in the chunk list */
|
||||
int32_t x, y, z;
|
||||
|
||||
/** Current chunk list, ordered */
|
||||
chunk_t *chunkList[MAP_CHUNK_COUNT];
|
||||
|
||||
/** Chunk array, unordered */
|
||||
chunk_t chunks[MAP_CHUNK_COUNT];
|
||||
} map_t;
|
||||
|
||||
extern map_t MAP_STATE;
|
29
include/dawn/world/map/tile.h
Normal file
29
include/dawn/world/map/tile.h
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2021 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
|
||||
/** Width of a tile (in pixels) */
|
||||
#define TILE_WIDTH 16
|
||||
/** Height of a tile (in pixels) */
|
||||
#define TILE_HEIGHT 16
|
||||
/** What a NULL tile is represented as. */
|
||||
#define TILE_NULL 0x00
|
||||
|
||||
/** Bitwise Flags from tiles. */
|
||||
typedef uint8_t tileflag_t;
|
||||
|
||||
/** Tile ID */
|
||||
typedef uint8_t tileid_t;
|
||||
|
||||
/** Representation of the information of a tile within a tilemap. */
|
||||
typedef struct {
|
||||
/** Flags of the tile */
|
||||
tileflag_t flags;
|
||||
|
||||
/** How many indices and vertices a tile with this definition has. */
|
||||
int32_t indiceCount, verticeCount;
|
||||
} tiledef_t;
|
9
include/dawn/world/world.h
Normal file
9
include/dawn/world/world.h
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright (c) 2021 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "map/chunk.h"
|
||||
#include "map/map.h"
|
Reference in New Issue
Block a user