Loop canvas

This commit is contained in:
Yash Karandikar 2022-04-30 12:47:42 -05:00
parent 487f2e40fe
commit 47de327e05
Signed by: karx
GPG key ID: A794DA2529474BA5

View file

@ -105,6 +105,24 @@ fn main() {
snake.push(s);
}
{
let (mut x, mut y) = snake[0].position();
x /= 37;
y /= 37;
if x == 0 {
snake[0].translate((27 * 37, 0));
} else if x == 27 {
snake[0].translate((-27 * 37, 0));
};
if y == 0 {
snake[0].translate((0, -27 * 37));
} else if y == 27 {
snake[0].translate((0, 27 * 37));
}
}
// So that the snake doesn't move at super speed
std::thread::sleep(Duration::from_millis(125));
apple.draw(ctx).unwrap();