decrease special mass size + add hjkl movement bindings
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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++;
|
||||
}
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user