Skip to content

Commit

Permalink
Merge pull request #8 from tbm2/master
Browse files Browse the repository at this point in the history
use latest versions of dependencies
  • Loading branch information
xojoc committed Sep 27, 2015
2 parents 1794c3f + 2c7bec9 commit 96686ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ name = "snake"
path = "snake.rs"

[dependencies]
piston = "0.1.5"
pistoncore-glutin_window = "0.2.0"
piston2d-graphics = "0.1.4"
piston2d-opengl_graphics = "0.1.0"
rand = "0.3"
piston = "0.10"
pistoncore-glutin_window = "0.12"
piston2d-graphics = "0.9"
piston2d-opengl_graphics = "0.12"
rand = "0.3"
33 changes: 19 additions & 14 deletions snake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use std::collections::VecDeque;

use graphics::*;
use opengl_graphics::{ GlGraphics, OpenGL };
use piston::event::*;
use piston::event_loop::Events;
use piston::input::{Button, Event, Input, RenderEvent};
use piston::input::keyboard::Key;
use rand::{thread_rng, Rng};

Expand Down Expand Up @@ -396,25 +397,29 @@ fn main() {
let window = Window::new(
WindowSettings::new("Snake - Piston",
[BOARD_WIDTH as u32 * TILE_SIZE as u32, BOARD_HEIGHT as u32 * TILE_SIZE as u32])
.exit_on_esc(true));
.exit_on_esc(true)
).unwrap();

let mut gfx = GlGraphics::new(OpenGL::_3_2);
let mut gfx = GlGraphics::new(OpenGL::V3_2);

let mut game = Game::new();

for e in window.events() {
use piston::input::Button;
if let Some(args) = e.render_args() {
let t = Context::new_viewport(args.viewport()).transform;
game.render(t, &mut gfx);
}
match e {
Event::Render(args) => {
let t = Context::new_viewport(args.viewport()).transform;
game.render(t, &mut gfx);
}

if let Some(Button::Keyboard(key)) = e.press_args() {
game.key_press(key);
}
Event::Input(Input::Press(Button::Keyboard(key))) => {
game.key_press(key);
}

Event::Update(args) => {
game.update(args.dt);
}

if let Some(args) = e.update_args() {
game.update(args.dt);
_ => {}
}
}
}

0 comments on commit 96686ac

Please sign in to comment.