From a428a2f54433866be0a9044ed1cea693049a58f7 Mon Sep 17 00:00:00 2001 From: BernaTameirao Date: Fri, 12 Dec 2025 15:33:37 -0300 Subject: [PATCH 1/2] fix: snake starts in the wrong direction --- src/ecs/prefabs/snake.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ecs/prefabs/snake.py b/src/ecs/prefabs/snake.py index a6ff986..660b1fc 100644 --- a/src/ecs/prefabs/snake.py +++ b/src/ecs/prefabs/snake.py @@ -115,12 +115,8 @@ def create_snake( initial_segments = [] initial_size = 1 - # In autoplay mode, start with zero velocity so autoplay can set the first direction - # Otherwise start moving right - if autoplay_mode: - initial_dx, initial_dy = 0, 0 - else: - initial_dx, initial_dy = 1, 0 + # Start with zero velocity so the user can set the first direction + initial_dx, initial_dy = 0, 0 # create snake entity with all required components snake = Snake( From d0bc76fe1c6277e2ed3872180b60accd63cfd57d Mon Sep 17 00:00:00 2001 From: BernaTameirao Date: Fri, 12 Dec 2025 17:54:30 -0300 Subject: [PATCH 2/2] fix: snake starts turned to right --- src/ecs/prefabs/snake.py | 8 ++++++-- src/ecs/systems/snake_render.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ecs/prefabs/snake.py b/src/ecs/prefabs/snake.py index 660b1fc..a6ff986 100644 --- a/src/ecs/prefabs/snake.py +++ b/src/ecs/prefabs/snake.py @@ -115,8 +115,12 @@ def create_snake( initial_segments = [] initial_size = 1 - # Start with zero velocity so the user can set the first direction - initial_dx, initial_dy = 0, 0 + # In autoplay mode, start with zero velocity so autoplay can set the first direction + # Otherwise start moving right + if autoplay_mode: + initial_dx, initial_dy = 0, 0 + else: + initial_dx, initial_dy = 1, 0 # create snake entity with all required components snake = Snake( diff --git a/src/ecs/systems/snake_render.py b/src/ecs/systems/snake_render.py index 1327242..3fccb61 100644 --- a/src/ecs/systems/snake_render.py +++ b/src/ecs/systems/snake_render.py @@ -202,9 +202,9 @@ def _get_head_direction(self, position: Position) -> tuple[int, int]: dy = -1 elif dy < -1: dy = 1 - # Default to DOWN if no movement + # Default to RIGHT if no movement if dx == 0 and dy == 0: - return (0, 1) + return (1, 0) return (dx, dy) def _draw_snake_head(