Basic NPC loading (half done)
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
#include "world/chunk.h"
|
||||
#include "world/overworld.h"
|
||||
#include "display/render.h"
|
||||
#include "assert/assert.h"
|
||||
|
||||
Camera2D DRAW_OVERWORLD_CAMERA = { 0 };
|
||||
|
||||
@ -36,6 +37,7 @@ void drawOverworldDraw(void) {
|
||||
|
||||
BeginMode2D(DRAW_OVERWORLD_CAMERA);
|
||||
|
||||
// Bottom layer
|
||||
chunk_t *chunk = CHUNK_MAP.chunks;
|
||||
do {
|
||||
DrawRectangle(
|
||||
@ -48,5 +50,62 @@ void drawOverworldDraw(void) {
|
||||
chunk++;
|
||||
} while(chunk < CHUNK_MAP.chunks + CHUNK_MAP_COUNT);
|
||||
|
||||
// Entities
|
||||
entity_t *entity = ENTITIES;
|
||||
do {
|
||||
drawOverworldDrawEntity(entity++);
|
||||
} while(entity->type != ENTITY_TYPE_NULL);
|
||||
|
||||
EndMode2D();
|
||||
}
|
||||
|
||||
|
||||
void drawOverworldDrawEntity(const entity_t *entity) {
|
||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
||||
|
||||
uint32_t x = (uint32_t)floorf(entity->x);
|
||||
uint32_t y = (uint32_t)floorf(entity->y);
|
||||
|
||||
DrawRectangle(
|
||||
x,
|
||||
y,
|
||||
TILE_WIDTH,
|
||||
TILE_HEIGHT,
|
||||
(entity->type == ENTITY_TYPE_PLAYER) ? BLUE : YELLOW
|
||||
);
|
||||
|
||||
switch(entity->dir) {
|
||||
case ENTITY_DIR_NORTH:
|
||||
DrawTriangle(
|
||||
(Vector2){ x + TILE_WIDTH / 2, y },
|
||||
(Vector2){ x, y + TILE_HEIGHT },
|
||||
(Vector2){ x + TILE_WIDTH, y + TILE_HEIGHT },
|
||||
WHITE
|
||||
);
|
||||
break;
|
||||
case ENTITY_DIR_SOUTH:
|
||||
DrawTriangle(
|
||||
(Vector2){ x + TILE_WIDTH / 2, y + TILE_HEIGHT },
|
||||
(Vector2){ x + TILE_WIDTH, y },
|
||||
(Vector2){ x, y },
|
||||
WHITE
|
||||
);
|
||||
break;
|
||||
case ENTITY_DIR_WEST:
|
||||
DrawTriangle(
|
||||
(Vector2){ x, y + TILE_HEIGHT / 2 },
|
||||
(Vector2){ x + TILE_WIDTH, y + TILE_HEIGHT },
|
||||
(Vector2){ x + TILE_WIDTH, y },
|
||||
WHITE
|
||||
);
|
||||
break;
|
||||
case ENTITY_DIR_EAST:
|
||||
DrawTriangle(
|
||||
(Vector2){ x + TILE_WIDTH, y + TILE_HEIGHT / 2 },
|
||||
(Vector2){ x, y },
|
||||
(Vector2){ x, y + TILE_HEIGHT },
|
||||
WHITE
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user