From 12a96cba66e27969724690d36fc4e52d1515533f Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sun, 22 Feb 2026 01:49:54 +0100 Subject: [PATCH] decrease special mass size + add hjkl movement bindings --- include/input.hpp | 10 +++++----- src/input.cpp | 8 ++++---- src/main.cpp | 1 - src/renderer.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/input.hpp b/include/input.hpp index 15055b3..bad4dc9 100644 --- a/include/input.hpp +++ b/include/input.hpp @@ -14,14 +14,14 @@ public: int sel_x; int sel_y; - bool has_block_add_xy = false; - int block_add_x = -1; - int block_add_y = -1; + bool has_block_add_xy; + int block_add_x; + int block_add_y; public: InputHandler(StateManager &state, Renderer &renderer) - : state(state), renderer(renderer), hov_x(-1), hov_y(-1), sel_x(-1), - sel_y(-1), has_block_add_xy(false), block_add_x(-1), block_add_y(-1) {} + : state(state), renderer(renderer), hov_x(-1), hov_y(-1), sel_x(0), + sel_y(0), has_block_add_xy(false), block_add_x(-1), block_add_y(-1) {} InputHandler(const InputHandler ©) = delete; InputHandler &operator=(const InputHandler ©) = delete; diff --git a/src/input.cpp b/src/input.cpp index 3c3db2e..df06a17 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -88,19 +88,19 @@ auto InputHandler::HandleMouse() -> void { } auto InputHandler::HandleKeys() -> void { - if (IsKeyPressed(KEY_W)) { + if (IsKeyPressed(KEY_W) || IsKeyPressed(KEY_K)) { if (state.current_state.MoveBlockAt(sel_x, sel_y, Direction::NOR)) { sel_y--; } - } else if (IsKeyPressed(KEY_A)) { + } else if (IsKeyPressed(KEY_A) || IsKeyPressed(KEY_H)) { if (state.current_state.MoveBlockAt(sel_x, sel_y, Direction::WES)) { sel_x--; } - } else if (IsKeyPressed(KEY_S)) { + } else if (IsKeyPressed(KEY_S) || IsKeyPressed(KEY_J)) { if (state.current_state.MoveBlockAt(sel_x, sel_y, Direction::SOU)) { sel_y++; } - } else if (IsKeyPressed(KEY_D)) { + } else if (IsKeyPressed(KEY_D) || IsKeyPressed(KEY_L)) { if (state.current_state.MoveBlockAt(sel_x, sel_y, Direction::EAS)) { sel_x++; } diff --git a/src/main.cpp b/src/main.cpp index 8078c71..993a5ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -109,7 +109,6 @@ auto main(int argc, char *argv[]) -> int { renderer.DrawMassSprings(mass_springs, state.current_state, state.winning_states); - // TODO: Don't render each frame renderer.DrawKlotski(state.current_state, input.hov_x, input.hov_y, input.sel_x, input.sel_y, input.block_add_x, input.block_add_y, state.CurrentWinCondition()); diff --git a/src/renderer.cpp b/src/renderer.cpp index 5d64601..8035675 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -216,16 +216,16 @@ auto Renderer::DrawMassSprings(const MassSpringSystem &mass_springs, // Mark current state const Mass ¤t_mass = mass_springs.GetMass(current_state); - DrawCube(current_mass.position, VERTEX_SIZE * 4, VERTEX_SIZE * 4, - VERTEX_SIZE * 4, RED); + DrawCube(current_mass.position, VERTEX_SIZE * 2, VERTEX_SIZE * 2, + VERTEX_SIZE * 2, RED); // Mark winning states if (mark_solutions || connect_solutions) { for (const auto &state : winning_states) { const Mass &winning_mass = mass_springs.GetMass(state); if (mark_solutions) { - DrawCube(winning_mass.position, 4 * VERTEX_SIZE, 4 * VERTEX_SIZE, - 4 * VERTEX_SIZE, BLUE); + DrawCube(winning_mass.position, 2 * VERTEX_SIZE, 2 * VERTEX_SIZE, + 2 * VERTEX_SIZE, BLUE); } if (connect_solutions) {