From 961b455c40da0640f2fe9dcd9a982a77c9406b27 Mon Sep 17 00:00:00 2001 From: gallant Date: Sat, 21 May 2022 13:08:14 -0500 Subject: [PATCH] here karx --- Cargo.lock | 1 + Cargo.toml | 3 ++- src/main.rs | 18 +++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fb9420..bd464fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,6 +40,7 @@ name = "practice_game" version = "0.1.0" dependencies = [ "cat-box", + "sdl2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index dd202c7..434492c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +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.6" \ No newline at end of file +cat-box = "0.1.6" +sdl2 = "0.35.2" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 7442e15..e8710e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,14 @@ use cat_box::{draw_text, Game, Sprite, SpriteCollection, get_keyboard_state}; use std::{thread, time}; - +use sdl2::keyboard::Scancode; struct state { running: bool, jumping: bool } + + fn main() { let game = Game::new("Running", 500, 500); @@ -38,7 +40,7 @@ fn main() { i=200; } - /*for key in keys { + for key in keys { let offset = match key { Scancode::Escape => { game.terminate(); @@ -51,8 +53,18 @@ fn main() { _ => (0, 0), }; + let mut spriteindex = sprites.get(0).unwrap(); + /* - }*/ + */ + /*pub const fn unwrap(self) -> T { + match self { + Some(val) => val, + None => panic("called `Option::unwrap()` on a `None` value"), + } + }*/ + //spriteindex.translate(offset); + } ctx.set_background_colour( 129, 201, i); sprites.draw(ctx).unwrap();