This commit is contained in:
gallant 2022-05-20 19:29:16 -05:00
commit 571f65e9a0
7 changed files with 111 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

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.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24bda0d6fb9dc5a286c9afe6286b1de1f3fe7175310b4b0c2c34174fccafbd19"
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.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "practice_game"
version = "0.1.0"
dependencies = [
"cat-box",
"sdl2",
]
[[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 = "version-compare"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73"

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "practice_game"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cat-box = "0.1.6"
sdl2 = "0.35.2"

BIN
runner_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 947 B

BIN
runner_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

BIN
runner_s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

27
src/main.rs Normal file
View File

@ -0,0 +1,27 @@
use cat_box::{draw_text, Game, Sprite, SpriteCollection};
use std::{thread, time};
fn main() {
let game = Game::new("Running", 500, 500);
//main sprite introductions
let mut i = 255u8;
let mut running = SpriteCollection::new();
let mut run1 = Sprite::new("runner_0.png", 250, 250).unwrap();
let mut run2 = Sprite::new("runner_1.png", 250, 250).unwrap();
let mut stand = Sprite::new("runner_s.png", 250, 250).unwrap();
running.push(run1);
//sleeper agent
let sleep = thread::sleep;
//main game loop
game.run(|ctx|{
if i<200{
i = i + 10;
}else if i >= 255{
i=200;
}
ctx.set_background_colour( 129, 201, i);
running.draw(ctx).unwrap();
}).unwrap();
}