diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..d423183 Binary files /dev/null and b/.DS_Store differ diff --git a/Cargo.lock b/Cargo.lock index bd464fe..5fb9420 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,7 +40,6 @@ name = "practice_game" version = "0.1.0" dependencies = [ "cat-box", - "sdl2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 434492c..dd202c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,4 @@ 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" \ No newline at end of file +cat-box = "0.1.6" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 089fa9b..7442e15 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,27 +1,61 @@ -use cat_box::{draw_text, Game, Sprite, SpriteCollection}; +use cat_box::{draw_text, Game, Sprite, SpriteCollection, get_keyboard_state}; use std::{thread, time}; + +struct state { + running: bool, + jumping: bool +} + 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); + let mut sprites = SpriteCollection::new(); + let mut run1 = Sprite::new("runner_0.png", 200, 250).unwrap(); + let mut run2 = Sprite::new("runner_1.png", 300, 250).unwrap(); + let mut stand = Sprite::new("runner_s.png", 400, 250).unwrap(); + + sprites.push(run1); + sprites.push(run2); + sprites.push(stand); + + let guy = state { + running: false, + jumping: false + }; + //sleeper agent let sleep = thread::sleep; //main game loop game.run(|ctx|{ + let keys = get_keyboard_state(ctx).keys; + if i<200{ i = i + 10; }else if i >= 255{ i=200; } + + /*for key in keys { + let offset = match key { + Scancode::Escape => { + game.terminate(); + (0, 0) + } + Scancode::W | Scancode::Up => (0, 5), + Scancode::S | Scancode::Down => (0, -5), + Scancode::A | Scancode::Left => (-5, 0), + Scancode::D | Scancode::Right => (5, 0), + _ => (0, 0), + }; + + + }*/ + ctx.set_background_colour( 129, 201, i); - running.draw(ctx).unwrap(); + sprites.draw(ctx).unwrap(); }).unwrap(); }