fix render mouselook

This commit is contained in:
Andrew Pamment 2025-04-22 14:44:05 +10:00
parent 15075e33af
commit 965a76000b

View File

@ -124,7 +124,9 @@ void Gui::message(const TCOD_ColorRGB& col, const char* text, ...) {
} while (lineEnd);
}
void Gui::renderMouseLook() {
if (!engine->map->isInFov(engine->mouse.cx, engine->mouse.cy)) {
int offset_x = engine->player->x - Engine::VIEW_WIDTH / 2;
int offset_y = engine->player->y - Engine::VIEW_HEIGHT / 2;
if (!engine->map->isInFov(engine->mouse.cx + offset_x, engine->mouse.cy + offset_y)) {
// if mouse is out of fov, nothing to render
return;
}
@ -134,7 +136,7 @@ void Gui::renderMouseLook() {
for (Actor** it = engine->actors.begin(); it != engine->actors.end(); it++) {
Actor* actor = *it;
// find actors under the mouse cursor
if (actor->x == engine->mouse.cx && actor->y == engine->mouse.cy) {
if (actor->x == engine->mouse.cx + offset_x && actor->y == engine->mouse.cy + offset_y) {
if (!first) {
ss << ", ";
}