Dependency update
parent
eb1a4830ca
commit
ed3f393b81
File diff suppressed because it is too large
Load Diff
|
@ -10,4 +10,5 @@ authors = [
|
||||||
name = "rust-pilot"
|
name = "rust-pilot"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
piston_window = "0.40.0"
|
piston_window = "*"
|
||||||
|
#"0.40.0"
|
||||||
|
|
|
@ -17,28 +17,26 @@ impl Controls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, inp: Input) {
|
pub fn update(&mut self, inp: &Event) {
|
||||||
match inp {
|
if let Some(b) = inp.press_args() {
|
||||||
Input::Press(b) => {
|
match b {
|
||||||
match b {
|
Button::Keyboard(Key::Up) => { self.up_d = true; }
|
||||||
Button::Keyboard(Key::Up) => { self.up_d = true; }
|
Button::Keyboard(Key::Down) => { self.down_d = true; }
|
||||||
Button::Keyboard(Key::Down) => { self.down_d = true; }
|
Button::Keyboard(Key::Left) => { self.left_d = true; }
|
||||||
Button::Keyboard(Key::Left) => { self.left_d = true; }
|
Button::Keyboard(Key::Right) => { self.right_d = true; }
|
||||||
Button::Keyboard(Key::Right) => { self.right_d = true; }
|
_ => {}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Input::Release(b) => {
|
|
||||||
match b {
|
}
|
||||||
Button::Keyboard(Key::Up) => { self.up_d = false; }
|
if let Some(b) = inp.release_args() {
|
||||||
Button::Keyboard(Key::Down) => { self.down_d = false; }
|
match b {
|
||||||
Button::Keyboard(Key::Left) => { self.left_d = false; }
|
Button::Keyboard(Key::Up) => { self.up_d = false; }
|
||||||
Button::Keyboard(Key::Right) => { self.right_d = false; }
|
Button::Keyboard(Key::Down) => { self.down_d = false; }
|
||||||
Button::Keyboard(Key::Space) => { self.fire = true; }
|
Button::Keyboard(Key::Left) => { self.left_d = false; }
|
||||||
_ => {}
|
Button::Keyboard(Key::Right) => { self.right_d = false; }
|
||||||
}
|
Button::Keyboard(Key::Space) => { self.fire = true; }
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
draw_background(gl);
|
||||||
|
|
||||||
let ds = context.draw_state.blend(Blend::Alpha);
|
let ds = context.draw_state.blend(Blend::Alpha);
|
||||||
|
@ -105,7 +107,7 @@ impl Game {
|
||||||
self.camera.follow(self.player.position, &self.map);
|
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);
|
self.controls.update(inp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -9,7 +9,7 @@ const XDIM: u32 = 600;
|
||||||
const YDIM: u32 = 600;
|
const YDIM: u32 = 600;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let window: PistonWindow = WindowSettings::new(
|
let mut window: PistonWindow = WindowSettings::new(
|
||||||
"rust-pilot",
|
"rust-pilot",
|
||||||
[XDIM, YDIM]
|
[XDIM, YDIM]
|
||||||
)
|
)
|
||||||
|
@ -21,18 +21,19 @@ fn main() {
|
||||||
|
|
||||||
// Create a new game and run it.
|
// Create a new game and run it.
|
||||||
let mut game = Game::new(XDIM as Scalar, YDIM as Scalar);
|
let mut game = Game::new(XDIM as Scalar, YDIM as Scalar);
|
||||||
for e in window {
|
while let Some(e) = window.next() {
|
||||||
match e.event {
|
match e {
|
||||||
Some(Event::Update(upd)) => {
|
Event::Loop(Loop::Update(upd)) => {
|
||||||
game.update(upd);
|
game.update(upd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Event::Render(ren)) => {
|
Event::Loop(Loop::Render(ren)) => {
|
||||||
game.render(ren, e);
|
game.render(ren, &mut window, &e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Event::Input(inp)) => {
|
Event::Input(inp) => {
|
||||||
game.input(inp);
|
let ev = Event::Input(inp);
|
||||||
|
game.input(&ev);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue