This commit is contained in:
2025-06-10 17:24:12 -05:00
parent 1b6db0c643
commit ac917901e4
2 changed files with 64 additions and 9 deletions

View File

@ -10,8 +10,8 @@
#include "raylib.h" #include "raylib.h"
#include "rpg/entity/entity.h" #include "rpg/entity/entity.h"
const uint16_t RENDER_WIDTH = 800; const uint16_t RENDER_WIDTH = 480;
const uint16_t RENDER_HEIGHT = 600; const uint16_t RENDER_HEIGHT = 270;
void renderInit() { void renderInit() {
InitWindow(RENDER_WIDTH, RENDER_HEIGHT, "Dusk"); InitWindow(RENDER_WIDTH, RENDER_HEIGHT, "Dusk");
@ -19,6 +19,9 @@ void renderInit() {
} }
bool_t renderUpdate() { bool_t renderUpdate() {
uint8_t x, y;
char_t buffer[64];
// End rendering? // End rendering?
if(WindowShouldClose()) return false; if(WindowShouldClose()) return false;
@ -33,13 +36,52 @@ bool_t renderUpdate() {
continue; continue;
} }
DrawRectangle( x = ent->x * ENTITY_WIDTH + ent->subX;
(ent->x * ENTITY_WIDTH) + ent->subX, y = ent->y * ENTITY_HEIGHT + ent->subY;
(ent->y * ENTITY_HEIGHT) + ent->subY,
ENTITY_WIDTH, // DrawRectangle(
ENTITY_HEIGHT, // x, y,
// ENTITY_WIDTH, ENTITY_HEIGHT,
// BLUE
// );
switch(ent->dir) {
case ENTITY_DIR_UP:
DrawTriangle(
(Vector2){ x, y + ENTITY_HEIGHT },
(Vector2){ x + ENTITY_WIDTH, y + ENTITY_HEIGHT },
(Vector2){ x + ENTITY_WIDTH / 2, y },
RED RED
); );
break;
case ENTITY_DIR_DOWN:
DrawTriangle(
(Vector2){ x, y },
(Vector2){ x + ENTITY_WIDTH / 2, y + ENTITY_HEIGHT },
(Vector2){ x + ENTITY_WIDTH, y },
RED
);
break;
case ENTITY_DIR_LEFT:
DrawTriangle(
(Vector2){ x + ENTITY_WIDTH, y },
(Vector2){ x, y + ENTITY_HEIGHT / 2 },
(Vector2){ x + ENTITY_WIDTH, y + ENTITY_HEIGHT },
RED
);
break;
case ENTITY_DIR_RIGHT:
DrawTriangle(
(Vector2){ x, y },
(Vector2){ x, y + ENTITY_HEIGHT },
(Vector2){ x + ENTITY_WIDTH, y + ENTITY_HEIGHT / 2 },
RED
);
break;
default:
assertUnreachable("Invalid entity direction");
}
ent++; ent++;
} while(ent < (ENTITIES + ENTITY_COUNT)); } while(ent < (ENTITIES + ENTITY_COUNT));

View File

@ -18,8 +18,21 @@ const inputmap_t INPUT_MAP[] = {
{ KEY_S, INPUT_DOWN }, { KEY_S, INPUT_DOWN },
{ KEY_A, INPUT_LEFT }, { KEY_A, INPUT_LEFT },
{ KEY_D, INPUT_RIGHT }, { KEY_D, INPUT_RIGHT },
{ KEY_SPACE, INPUT_ACTION }, { KEY_SPACE, INPUT_ACTION },
{ KEY_E, INPUT_ACTION },
{ KEY_ENTER, INPUT_ACTION },
{ KEY_ESCAPE, INPUT_CANCEL }, { KEY_ESCAPE, INPUT_CANCEL },
{ KEY_Q, INPUT_CANCEL },
{ KEY_BACKSPACE, INPUT_CANCEL },
{ KEY_UP, INPUT_UP },
{ KEY_DOWN, INPUT_DOWN },
{ KEY_LEFT, INPUT_LEFT },
{ KEY_RIGHT, INPUT_RIGHT },
{ KEY_ENTER, INPUT_ACTION },
{ KEY_BACKSPACE, INPUT_CANCEL },
{ 0, 0 } { 0, 0 }
}; };