mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-12 16:12:22 -06:00
reformat: general, target conditional module
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -1,20 +1,21 @@
|
|||||||
use crate::constants::{WINDOW_HEIGHT, WINDOW_WIDTH};
|
use crate::constants::{WINDOW_HEIGHT, WINDOW_WIDTH};
|
||||||
use crate::game::Game;
|
use crate::game::Game;
|
||||||
use sdl2::event::{Event};
|
use sdl2::event::Event;
|
||||||
use sdl2::keyboard::Keycode;
|
use sdl2::keyboard::Keycode;
|
||||||
use sdl2::pixels::Color;
|
|
||||||
use sdl2::render::{Canvas, Texture};
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
#[cfg(target_os = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
pub mod emscripten;
|
pub mod emscripten;
|
||||||
|
|
||||||
|
mod animation;
|
||||||
mod constants;
|
mod constants;
|
||||||
mod direction;
|
mod direction;
|
||||||
|
mod entity;
|
||||||
mod game;
|
mod game;
|
||||||
mod pacman;
|
mod pacman;
|
||||||
mod entity;
|
|
||||||
mod animation;
|
#[cfg(target_os = "emscripten")]
|
||||||
|
mod emscripten;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let sdl_context = sdl2::init().unwrap();
|
let sdl_context = sdl2::init().unwrap();
|
||||||
@@ -59,9 +60,9 @@ pub fn main() {
|
|||||||
keycode: Some(Keycode::Escape) | Some(Keycode::Q),
|
keycode: Some(Keycode::Escape) | Some(Keycode::Q),
|
||||||
..
|
..
|
||||||
} => return false,
|
} => return false,
|
||||||
Event::KeyDown { keycode , .. } => {
|
Event::KeyDown { keycode, .. } => {
|
||||||
game.keyboard_event(keycode.unwrap());
|
game.keyboard_event(keycode.unwrap());
|
||||||
},
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,10 @@ pub fn main() {
|
|||||||
if start.elapsed() < loop_time {
|
if start.elapsed() < loop_time {
|
||||||
::std::thread::sleep(loop_time - start.elapsed());
|
::std::thread::sleep(loop_time - start.elapsed());
|
||||||
} else {
|
} else {
|
||||||
println!("Game loop behind schedule by: {:?}", start.elapsed() - loop_time);
|
println!(
|
||||||
|
"Game loop behind schedule by: {:?}",
|
||||||
|
start.elapsed() - loop_time
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|||||||
Reference in New Issue
Block a user