Switched to using tile coordinates, losing my angled movement unfortunately.
This commit is contained in:
@@ -44,16 +44,18 @@ void renderOverworldDraw(void) {
|
||||
meshDraw(&chunk->meshBase, -1, -1);
|
||||
}
|
||||
|
||||
|
||||
for(uint8_t i = 0; i < ENTITY_COUNT_MAX; i++) {
|
||||
entity_t *entity = &ENTITIES[i];
|
||||
if(entity->type == ENTITY_TYPE_NULL) continue;
|
||||
|
||||
float_t x = (entity->x * TILE_WIDTH_HEIGHT) + entity->subX;
|
||||
float_t y = (entity->y * TILE_WIDTH_HEIGHT) + entity->subY;
|
||||
|
||||
// Draw the entity
|
||||
spriteBatchPush(
|
||||
NULL,
|
||||
floorf(entity->x), floorf(entity->y),
|
||||
floorf(entity->x + TILE_WIDTH_HEIGHT), floorf(entity->y + TILE_WIDTH_HEIGHT),
|
||||
x, y,
|
||||
x + TILE_WIDTH_HEIGHT, y + TILE_WIDTH_HEIGHT,
|
||||
0xFF, 0x00, 0xFF, 0XFF,
|
||||
0.0f, 0.0f, 1.0f, 1.0f
|
||||
);
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -9,24 +9,38 @@
|
||||
#include "display/render.h"
|
||||
#include "display/ui/rendertext.h"
|
||||
#include "time.h"
|
||||
#include "game.h"
|
||||
|
||||
float_t RENDER_FPS_AVG = -1.0f;
|
||||
float_t RENDER_TPS_AVG = -1.0f;
|
||||
|
||||
void renderFPSDraw(void) {
|
||||
float_t fps = 1.0f / TIME.delta;
|
||||
|
||||
if(TIME.delta > 0) {
|
||||
float_t fps = 1.0f / TIME.realDelta;
|
||||
|
||||
char_t buffer[32];
|
||||
snprintf(buffer, sizeof(buffer), "%.1f FPS", fps);
|
||||
if(RENDER_FPS_AVG == -1.0f) {
|
||||
RENDER_FPS_AVG = fps;
|
||||
} else {
|
||||
RENDER_FPS_AVG = (RENDER_FPS_AVG + fps) / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if(TIME.time != TIME.lastTick) {
|
||||
float_t timeSinceLastTick = TIME.realTime - TIME.lastTick;
|
||||
float_t tps = 1.0f / timeSinceLastTick;
|
||||
|
||||
if(RENDER_TPS_AVG == -1.0f) {
|
||||
RENDER_TPS_AVG = tps;
|
||||
} else {
|
||||
RENDER_TPS_AVG = (RENDER_TPS_AVG + tps) / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
char_t buffer[64];
|
||||
snprintf(buffer, sizeof(buffer), "%.1f/%.1f", RENDER_FPS_AVG, RENDER_TPS_AVG);
|
||||
|
||||
int32_t width, height;
|
||||
renderTextMeasure(buffer, &width, &height);
|
||||
|
||||
if(fps >= 50.0f) {
|
||||
// Green
|
||||
renderTextDraw(RENDER_WIDTH - width, 0, buffer, 0x00, 0xFF, 0x00);
|
||||
} else if(fps >= 30.0f) {
|
||||
// Yellow
|
||||
renderTextDraw(RENDER_WIDTH - width, 0, buffer, 0xFF, 0xFF, 0x00);
|
||||
} else {
|
||||
// Red
|
||||
renderTextDraw(RENDER_WIDTH - width, 0, buffer, 0xFF, 0x00, 0x00);
|
||||
}
|
||||
renderTextDraw(RENDER_WIDTH - width, 0, buffer, 0x00, 0xFF, 0x00);
|
||||
}
|
||||
+8
-10
@@ -8,14 +8,12 @@
|
||||
#include "time.h"
|
||||
#include "dusksdl2.h"
|
||||
|
||||
#if DUSK_TIME_DYNAMIC
|
||||
uint32_t TIME_LAST = 0;
|
||||
uint32_t TIME_LAST = 0;
|
||||
|
||||
float_t timeDeltaGet(void) {
|
||||
// Get the current time in milliseconds
|
||||
uint32_t currentTime = SDL_GetTicks();
|
||||
float_t delta = (currentTime - TIME_LAST) / 1000.0f;
|
||||
TIME_LAST = currentTime;
|
||||
return delta;
|
||||
}
|
||||
#endif
|
||||
float_t timeDeltaGet(void) {
|
||||
// Get the current time in milliseconds
|
||||
uint32_t currentTime = SDL_GetTicks();
|
||||
float_t delta = (currentTime - TIME_LAST) / 1000.0f;
|
||||
TIME_LAST = currentTime;
|
||||
return delta;
|
||||
}
|
||||
Reference in New Issue
Block a user