From 0083fff73ada744a93289f24170d0eb729d04877 Mon Sep 17 00:00:00 2001 From: Priec Date: Thu, 11 Dec 2025 08:31:39 +0100 Subject: [PATCH] fixed crawling --- semestralka1/src/game/collision.h | 1 - semestralka1/src/game/state.cpp | 6 +++--- semestralka1/src/render/loop.cpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/semestralka1/src/game/collision.h b/semestralka1/src/game/collision.h index 1ea0ba4..a35cd56 100644 --- a/semestralka1/src/game/collision.h +++ b/semestralka1/src/game/collision.h @@ -13,7 +13,6 @@ struct Obstacle { int height; }; -// Axis-aligned bounding-box collision inline bool check_collision(const CharacterPosition& player, MovementType movement, const Obstacle& obs) { diff --git a/semestralka1/src/game/state.cpp b/semestralka1/src/game/state.cpp index 0046f74..6ade839 100644 --- a/semestralka1/src/game/state.cpp +++ b/semestralka1/src/game/state.cpp @@ -102,10 +102,10 @@ void MovementState::update() { } void MovementState::start_crawl(PlayerState crawl_type) { - if (crawl_type != PlayerState::Crawl1 && crawl_type != PlayerState::Crawl2) - return; + if (current_state != PlayerState::Crawl1 && current_state != PlayerState::Crawl2) { + previous_state = current_state; + } - previous_state = current_state; current_state = crawl_type; state_timer.stop(); state_timer.reset(); diff --git a/semestralka1/src/render/loop.cpp b/semestralka1/src/render/loop.cpp index c44df0e..a8faf2e 100644 --- a/semestralka1/src/render/loop.cpp +++ b/semestralka1/src/render/loop.cpp @@ -43,7 +43,7 @@ void render_loop(int speed) { int player_speed = 6; bool game_over = false; - player_state.set_state(PlayerState::Run); + player_state.set_state(PlayerState::Walk); CrawlObstacleType type = CrawlObstacleType::Crawl1; int start_x = VIEW_WIDTH + 10;