This commit is contained in:
2025-06-11 09:42:20 -05:00
parent d1b1ecf3ca
commit e3438cae77
28 changed files with 451 additions and 375 deletions

View File

@ -0,0 +1,11 @@
# 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
drawentity.c
drawui.c
)

View File

@ -0,0 +1,63 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "drawentity.h"
#include "rpg/world/map.h"
void drawEntities() {
uint8_t x, y;
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;
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:
break;
}
ent++;
} while(ent->type != ENTITY_TYPE_NULL);
}

View File

@ -0,0 +1,14 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "display/renderraylib.h"
/**
* Draws all entities on the map.
*/
void drawEntities();

View File

@ -0,0 +1,27 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "drawui.h"
#include "ui/ui.h"
#include "ui/uitextbox.h"
void drawUITextbox() {
if(!UI_TEXTBOX.visible) return;
DrawRectangle(
UI_TEXTBOX.x, UI_TEXTBOX.y,
UI_TEXTBOX.width, UI_TEXTBOX.height,
Fade(SKYBLUE, 0.5f)
);
DrawTextEx(
FONT,
UI_TEXTBOX.text,
(Vector2){ UI_TEXTBOX.x + 2, UI_TEXTBOX.y + 2 },
FONT.baseSize, 0, BLACK
);
}

View File

@ -0,0 +1,14 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "display/renderraylib.h"
/**
* Draws the UI textbox.
*/
void drawUITextbox();