Draw snake onto screen

This commit is contained in:
Yash Karandikar 2022-04-29 11:30:14 -05:00
parent 7d5baa7a4a
commit 63ab319691
2 changed files with 9 additions and 0 deletions

BIN
snakecell.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

View file

@ -3,6 +3,13 @@ use sdl2::keyboard::Scancode;
fn main() {
let game = Game::new("Snake", 1000, 1000);
let snake_boxes: Vec<(i32, i32)> = vec![(13, 13), (14, 13)];
let mut snake = SpriteCollection::with_capacity(snake_boxes.len());
for (x, y) in snake_boxes {
let s = Sprite::new("snakecell.png", x * 37, y * 37).unwrap();
snake.push(s);
}
game.run(|ctx| {
let keys = get_keyboard_state(ctx).keys;
@ -12,6 +19,8 @@ fn main() {
game.terminate();
}
}
snake.draw(ctx).unwrap();
})
.unwrap();
}