43 lines
889 B
Rust
43 lines
889 B
Rust
extern crate piston_window;
|
|
use piston_window::*;
|
|
use piston_window::math::{Scalar};
|
|
|
|
mod game;
|
|
use game::Game;
|
|
|
|
const XDIM: u32 = 600;
|
|
const YDIM: u32 = 600;
|
|
|
|
fn main() {
|
|
let mut window: PistonWindow = WindowSettings::new(
|
|
"rust-pilot",
|
|
[XDIM, YDIM]
|
|
)
|
|
.exit_on_esc(true)
|
|
.samples(8)
|
|
.vsync(true)
|
|
.build()
|
|
.unwrap();
|
|
|
|
// Create a new game and run it.
|
|
let mut game = Game::new(Scalar::from(XDIM), Scalar::from(YDIM));
|
|
while let Some(e) = window.next() {
|
|
match e {
|
|
Event::Loop(Loop::Update(upd)) => {
|
|
game.update(upd);
|
|
}
|
|
|
|
Event::Loop(Loop::Render(ren)) => {
|
|
game.render(ren, &mut window, &e);
|
|
}
|
|
|
|
Event::Input(_) => {
|
|
game.input(&e);
|
|
}
|
|
_ => {
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|