fixed crawling

This commit is contained in:
Priec
2025-12-11 08:31:39 +01:00
parent ca7eac70e4
commit 0083fff73a
3 changed files with 4 additions and 5 deletions

View File

@@ -13,7 +13,6 @@ struct Obstacle {
int height; int height;
}; };
// Axis-aligned bounding-box collision
inline bool check_collision(const CharacterPosition& player, inline bool check_collision(const CharacterPosition& player,
MovementType movement, MovementType movement,
const Obstacle& obs) { const Obstacle& obs) {

View File

@@ -102,10 +102,10 @@ void MovementState::update() {
} }
void MovementState::start_crawl(PlayerState crawl_type) { void MovementState::start_crawl(PlayerState crawl_type) {
if (crawl_type != PlayerState::Crawl1 && crawl_type != PlayerState::Crawl2) if (current_state != PlayerState::Crawl1 && current_state != PlayerState::Crawl2) {
return;
previous_state = current_state; previous_state = current_state;
}
current_state = crawl_type; current_state = crawl_type;
state_timer.stop(); state_timer.stop();
state_timer.reset(); state_timer.reset();

View File

@@ -43,7 +43,7 @@ void render_loop(int speed) {
int player_speed = 6; int player_speed = 6;
bool game_over = false; bool game_over = false;
player_state.set_state(PlayerState::Run); player_state.set_state(PlayerState::Walk);
CrawlObstacleType type = CrawlObstacleType::Crawl1; CrawlObstacleType type = CrawlObstacleType::Crawl1;
int start_x = VIEW_WIDTH + 10; int start_x = VIEW_WIDTH + 10;