This commit is contained in:
gallant 2022-05-25 08:16:39 -05:00
parent da847a73b2
commit 21bda8d268
3 changed files with 18 additions and 117 deletions

106
Cargo.lock generated
View file

@ -2,12 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
@ -29,16 +23,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00"
dependencies = [
"num",
"time",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -51,54 +35,12 @@ version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "num"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
dependencies = [
"num-integer",
"num-iter",
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
"autocfg",
]
[[package]]
name = "practice_game"
version = "0.1.0"
dependencies = [
"cat-box",
"sdl2",
"timer",
]
[[package]]
@ -124,56 +66,8 @@ dependencies = [
"version-compare",
]
[[package]]
name = "time"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi",
"winapi",
]
[[package]]
name = "timer"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9522a9ec40055e2f9e514e38d2415a496e81dbfc1ece15d98d2fe55c44946b3"
dependencies = [
"chrono",
]
[[package]]
name = "version-compare"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73"
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View file

@ -8,4 +8,3 @@ edition = "2021"
[dependencies]
cat-box = "0.1.7"
sdl2 = "0.35.2"
timer = "0.1.3"

View file

@ -1,7 +1,9 @@
use cat_box::{Game, Sprite, SpriteCollection, get_keyboard_state, draw_text};
use cat_box::{Game, Sprite, SpriteCollection, get_keyboard_state, draw_text,physics};
use std::{time::{Instant}};
use sdl2::keyboard::Scancode;
//use gravitas::{Simulation,Gravity};
/*
keep track of accel, vel and pos
every tick:
@ -18,13 +20,14 @@ fn main() {
//let meter = 13;
let now = Instant::now();
//let (mut pos, mut vel, mut accel) = (20.0,0.0,-9.8);
let mut background = SpriteCollection::new();
let mut run1 = Sprite::new("runner_0.png", 200, 320).unwrap();
let sun = Sprite::new("sun.png", 50, 50).unwrap();
let grass = Sprite::new("grass.png", 250, 450).unwrap();
/*
let mut grav = Gravity::new(2.0);
grav.set(0.0, 3.0);
*/
background.push(sun);
@ -53,20 +56,21 @@ fn main() {
let (x,y) = run1.position();
run1.translate((0,-3));
if x < 0 {
run1.translate((x*-1+5,0));
} else if x > 500 {
run1.translate((500-x-5,0));
}
//- run1.rect.height() as i32
if y < 0{
run1.translate((0,y - run1.rect.height() as i32))
}else if y > 320 {
run1.translate((0,5));
}
draw_text(
ctx,
format!("x is {} and y is {}, {:?} Seconds have passed", x, y, now.elapsed().as_secs()),
@ -84,15 +88,19 @@ fn main() {
Scancode::Escape | Scancode::Q => {
game.terminate();
(0, 0)
}
//Scancode::W | Scancode::Up => (0, 5),
} //Simulation::x(&grav,1.0) as i32
Scancode::W | Scancode::Up => (0, 3),
Scancode::S | Scancode::Down => (0, -5),
Scancode::A | Scancode::Left => (-5, 0),
Scancode::D | Scancode::Right => (5, 0),
_ => (0, 0),
};
//if physics::check_for_collision(&run1, background.get_mut(1).unwrap()){
run1.translate((offset.0,offset.1));
//}
}