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