/** * Copyright (c) 2024 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "assert/assert.h" #include "rpg/entity/entitydirection.h" #include "symbol.h" #include "time.h" char_t symbolGetCharByEntity(const entity_t *ent) { assertNotNull(ent, "Entity cannot be NULL."); switch(ent->direction) { case ENTITY_DIRECTION_EAST: return '>'; case ENTITY_DIRECTION_WEST: return '<'; case ENTITY_DIRECTION_NORTH: return '^'; case ENTITY_DIRECTION_SOUTH: return 'v'; default: assertUnreachable("Invalid entity direction."); } } char_t symbolGetCharByTile(const tile_t tile) { switch(tile.id) { case TILE_ID_GRASS: return '#'; case TILE_ID_WATER: // Take remainder int32_t j = (int32_t)(TIME.time * 2) % 4; switch(j) { case 0: return '/'; case 1: return '|'; case 2: return '\\'; case 3: return '|'; } default: return ' '; } } uint8_t symbolGetColorByEntity(const entity_t *ent) { assertNotNull(ent, "Entity cannot be NULL."); switch(ent->type) { case ENTITY_TYPE_PLAYER: return COLOR_RED; case ENTITY_TYPE_NPC: return COLOR_YELLOW; default: assertUnreachable("Invalid entity type."); } } uint8_t symbolGetColorByTile(const tile_t tile) { switch(tile.id) { case TILE_ID_GRASS: return COLOR_GREEN; case TILE_ID_WATER: return COLOR_BLUE; default: return COLOR_BLACK; } }