Render test
This commit is contained in:
10
src/duskraylib/display/CMakeLists.txt
Normal file
10
src/duskraylib/display/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
render.c
|
||||
)
|
53
src/duskraylib/display/render.c
Normal file
53
src/duskraylib/display/render.c
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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/entity/entity.h"
|
||||
|
||||
const uint16_t RENDER_WIDTH = 800;
|
||||
const uint16_t RENDER_HEIGHT = 600;
|
||||
|
||||
void renderInit() {
|
||||
InitWindow(RENDER_WIDTH, RENDER_HEIGHT, "Dusk");
|
||||
SetTargetFPS(60);
|
||||
}
|
||||
|
||||
bool_t renderUpdate() {
|
||||
// End rendering?
|
||||
if(WindowShouldClose()) return false;
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Hello, Dusk!", 10, 10, 20, BLACK);
|
||||
|
||||
entity_t *ent = ENTITIES;
|
||||
do {
|
||||
if(ent->type == ENTITY_TYPE_NULL) {
|
||||
ent++;
|
||||
continue;
|
||||
}
|
||||
|
||||
DrawRectangle(
|
||||
(ent->x * ENTITY_WIDTH) + ent->subX,
|
||||
(ent->y * ENTITY_HEIGHT) + ent->subY,
|
||||
ENTITY_WIDTH,
|
||||
ENTITY_HEIGHT,
|
||||
RED
|
||||
);
|
||||
ent++;
|
||||
} while(ent < (ENTITIES + ENTITY_COUNT));
|
||||
|
||||
EndDrawing();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void renderDispose() {
|
||||
CloseWindow();
|
||||
}
|
Reference in New Issue
Block a user