Dependency update

master
Levi Pearson 2018-06-28 20:03:52 -06:00
parent eb1a4830ca
commit ed3f393b81
5 changed files with 712 additions and 378 deletions

1024
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -10,4 +10,5 @@ authors = [
name = "rust-pilot"
[dependencies]
piston_window = "0.40.0"
piston_window = "*"
#"0.40.0"

View File

@ -17,28 +17,26 @@ impl Controls {
}
}
pub fn update(&mut self, inp: Input) {
match inp {
Input::Press(b) => {
match b {
Button::Keyboard(Key::Up) => { self.up_d = true; }
Button::Keyboard(Key::Down) => { self.down_d = true; }
Button::Keyboard(Key::Left) => { self.left_d = true; }
Button::Keyboard(Key::Right) => { self.right_d = true; }
_ => {}
}
pub fn update(&mut self, inp: &Event) {
if let Some(b) = inp.press_args() {
match b {
Button::Keyboard(Key::Up) => { self.up_d = true; }
Button::Keyboard(Key::Down) => { self.down_d = true; }
Button::Keyboard(Key::Left) => { self.left_d = true; }
Button::Keyboard(Key::Right) => { self.right_d = true; }
_ => {}
}
Input::Release(b) => {
match b {
Button::Keyboard(Key::Up) => { self.up_d = false; }
Button::Keyboard(Key::Down) => { self.down_d = false; }
Button::Keyboard(Key::Left) => { self.left_d = false; }
Button::Keyboard(Key::Right) => { self.right_d = false; }
Button::Keyboard(Key::Space) => { self.fire = true; }
_ => {}
}
}
if let Some(b) = inp.release_args() {
match b {
Button::Keyboard(Key::Up) => { self.up_d = false; }
Button::Keyboard(Key::Down) => { self.down_d = false; }
Button::Keyboard(Key::Left) => { self.left_d = false; }
Button::Keyboard(Key::Right) => { self.right_d = false; }
Button::Keyboard(Key::Space) => { self.fire = true; }
_ => {}
}
_ => {}
}
}

View File

@ -60,9 +60,11 @@ impl Game {
}
}
pub fn render(&mut self, args: RenderArgs, w: PistonWindow) {
pub fn render<GE>(&mut self, args: RenderArgs, w: &mut PistonWindow, e: &GE) where
GE: GenericEvent
{
w.draw_2d(|context, gl| {
w.draw_2d(e, |context, gl| {
draw_background(gl);
let ds = context.draw_state.blend(Blend::Alpha);
@ -105,7 +107,7 @@ impl Game {
self.camera.follow(self.player.position, &self.map);
}
pub fn input(&mut self, inp: Input) {
pub fn input(&mut self, inp: &Event) {
self.controls.update(inp);
}
}

View File

@ -9,7 +9,7 @@ const XDIM: u32 = 600;
const YDIM: u32 = 600;
fn main() {
let window: PistonWindow = WindowSettings::new(
let mut window: PistonWindow = WindowSettings::new(
"rust-pilot",
[XDIM, YDIM]
)
@ -21,18 +21,19 @@ fn main() {
// Create a new game and run it.
let mut game = Game::new(XDIM as Scalar, YDIM as Scalar);
for e in window {
match e.event {
Some(Event::Update(upd)) => {
while let Some(e) = window.next() {
match e {
Event::Loop(Loop::Update(upd)) => {
game.update(upd);
}
Some(Event::Render(ren)) => {
game.render(ren, e);
Event::Loop(Loop::Render(ren)) => {
game.render(ren, &mut window, &e);
}
Some(Event::Input(inp)) => {
game.input(inp);
Event::Input(inp) => {
let ev = Event::Input(inp);
game.input(&ev);
}
_ => {