/** * Copyright (c) 2025 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "assert/assert.h" #include "display/render.h" #include "raylib.h" #include "rpg/world/map.h" const uint16_t RENDER_WIDTH = 480; const uint16_t RENDER_HEIGHT = 270; void renderInit() { InitWindow(RENDER_WIDTH, RENDER_HEIGHT, "Dusk"); SetTargetFPS(60); } bool_t renderUpdate() { uint8_t x, y; char_t buffer[64]; // End rendering? if(WindowShouldClose()) return false; BeginDrawing(); ClearBackground(RAYWHITE); DrawText("Hello, Dusk!", 10, 10, 20, BLACK); entity_t *ent = MAP.entities; do { if(ent->type == ENTITY_TYPE_NULL) { ent++; continue; } x = ent->x * ENTITY_WIDTH + ent->subX; y = ent->y * ENTITY_HEIGHT + ent->subY; // DrawRectangle( // 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 ); 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++; } while(ent < (MAP.entities + MAP_ENTITY_COUNT)); EndDrawing(); return true; } void renderDispose() { CloseWindow(); }