Display a window

This commit is contained in:
Yash Karandikar 2022-04-29 11:10:54 -05:00
parent b9db335b5d
commit 7d5baa7a4a
3 changed files with 90 additions and 1 deletions

73
Cargo.lock generated Normal file
View file

@ -0,0 +1,73 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cat-box"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dda647bd577598f5c8c1f2a9753d033c2d26379a97f78489bde0055e2531c2a"
dependencies = [
"sdl2",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
[[package]]
name = "sdl2"
version = "0.35.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7959277b623f1fb9e04aea73686c3ca52f01b2145f8ea16f4ff30d8b7623b1a"
dependencies = [
"bitflags",
"lazy_static",
"libc",
"sdl2-sys",
]
[[package]]
name = "sdl2-sys"
version = "0.35.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3586be2cf6c0a8099a79a12b4084357aa9b3e0b0d7980e3b67aaf7a9d55f9f0"
dependencies = [
"cfg-if",
"libc",
"version-compare",
]
[[package]]
name = "snake"
version = "0.1.0"
dependencies = [
"cat-box",
"sdl2",
]
[[package]]
name = "version-compare"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73"

View file

@ -6,3 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cat-box = "0.1.4"
sdl2 = "0.35.2"

View file

@ -1,3 +1,17 @@
use cat_box::{get_keyboard_state, Game, Sprite, SpriteCollection};
use sdl2::keyboard::Scancode;
fn main() {
println!("Hello, world!");
let game = Game::new("Snake", 1000, 1000);
game.run(|ctx| {
let keys = get_keyboard_state(ctx).keys;
for key in keys {
if key == Scancode::Q {
game.terminate();
}
}
})
.unwrap();
}