Browse Source

fix dying bugs

Getty Ritter 2 years ago
parent
commit
e8025cd25d
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/snake.rs

+ 3 - 2
src/snake.rs

@@ -32,6 +32,7 @@ pub fn spawn(
             .insert(c::SnakeHead {
                 direction: c::Direction::Up,
             })
+            .insert(c::SnakeSegment)
             .insert(c::Position { x: 3, y: 3 })
             .insert(c::GridSize::square(0.8))
             .id(),
@@ -84,8 +85,8 @@ pub fn movement(
         }
         if head_pos.x < 0
             || head_pos.y < 0
-            || head_pos.x as u32 > c::ARENA_WIDTH
-            || head_pos.y as u32 > c::ARENA_HEIGHT
+            || head_pos.x as u32 >= c::ARENA_WIDTH
+            || head_pos.y as u32 >= c::ARENA_HEIGHT
             || segment_positions.contains(&head_pos)
         {
             game_over_writer.send(c::GameOverEvent);