voxelThing/source/blockTypes.c
2025-05-26 20:59:26 -04:00

76 lines
2.2 KiB
C

// blockTypes.c
// Definitions for which blocks exist in voxelThing, as well as the tile from the atlas for each face of the block.
#include "blockTypes.h"
#include "atlasDefinitions.h"
static const BlockType blockTable[] = {
[BLOCK_AIR] = {
.id = BLOCK_AIR,
.name = "Air",
.faceTiles = { -1, -1, -1, -1, -1, -1 }
},
[BLOCK_STONE] = {
.id = BLOCK_STONE,
.name = "Stone",
.faceTiles = { TILE_STONE, TILE_STONE, TILE_STONE, TILE_STONE, TILE_STONE, TILE_STONE }
},
[BLOCK_DIRT] = {
.id = BLOCK_DIRT,
.name = "Dirt",
.faceTiles = { TILE_DIRT, TILE_DIRT, TILE_DIRT, TILE_DIRT, TILE_DIRT, TILE_DIRT }
},
[BLOCK_GRASS] = {
.id = BLOCK_GRASS,
.name = "Grass",
.faceTiles = {
TILE_GRASS_SIDE, // -X
TILE_GRASS_SIDE, // +X
TILE_DIRT, // -Y
TILE_GRASS_TOP, // +Y
TILE_GRASS_SIDE, // -Z
TILE_GRASS_SIDE // +Z
}
},
[BLOCK_SAND] = {
.id = BLOCK_SAND,
.name = "Sand",
.faceTiles = { TILE_SAND, TILE_SAND, TILE_SAND, TILE_SAND, TILE_SAND, TILE_SAND }
},
[BLOCK_GRAVEL] = {
.id = BLOCK_GRASS,
.name = "Grass",
.faceTiles = {
TILE_GRASS_SIDE, // -X
TILE_GRASS_SIDE, // +X
TILE_DIRT, // -Y
TILE_GRASS_TOP, // +Y
TILE_GRASS_SIDE, // -Z
TILE_GRASS_SIDE // +Z
}
},
[BLOCK_LOG] = {
.id = BLOCK_LOG,
.name = "Log",
.faceTiles = {
TILE_LOG_SIDE, // -X
TILE_LOG_SIDE, // +X
TILE_LOG_TOP, // -Y
TILE_LOG_TOP, // +Y
TILE_LOG_SIDE, // -Z
TILE_LOG_SIDE // +Z
}
},
[BLOCK_LEAF] = {
.id = BLOCK_LEAF,
.name = "Leaves",
.faceTiles = { TILE_LEAF, TILE_LEAF, TILE_LEAF, TILE_LEAF, TILE_LEAF, TILE_LEAF }
},
};
const BlockType *GetBlockType(int blockID) {
if (blockID < 1 || blockID >= (sizeof(blockTable) / sizeof(blockTable[0]))) {
return &blockTable[BLOCK_AIR];
}
return &blockTable[blockID];
}