浏览代码

fix dying bugs

Getty Ritter 3 年之前
父节点
当前提交
e8025cd25d
共有 1 个文件被更改,包括 3 次插入2 次删除
  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);