mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-07 11:15:47 -06:00
reformat: default debug off, conditional debug grid rendering, remove unused redraw()
This commit is contained in:
@@ -29,7 +29,7 @@ impl Game<'_> {
|
|||||||
Game {
|
Game {
|
||||||
canvas,
|
canvas,
|
||||||
pacman: pacman,
|
pacman: pacman,
|
||||||
debug: true,
|
debug: false,
|
||||||
map_texture: texture_creator
|
map_texture: texture_creator
|
||||||
.load_texture("assets/map.png")
|
.load_texture("assets/map.png")
|
||||||
.expect("Could not load pacman texture"),
|
.expect("Could not load pacman texture"),
|
||||||
@@ -74,6 +74,7 @@ impl Game<'_> {
|
|||||||
self.pacman.render(self.canvas);
|
self.pacman.render(self.canvas);
|
||||||
|
|
||||||
// Draw a grid
|
// Draw a grid
|
||||||
|
if self.debug {
|
||||||
for x in 0..BOARD_WIDTH {
|
for x in 0..BOARD_WIDTH {
|
||||||
for y in 0..BOARD_HEIGHT {
|
for y in 0..BOARD_HEIGHT {
|
||||||
let tile = BOARD[x as usize][y as usize];
|
let tile = BOARD[x as usize][y as usize];
|
||||||
@@ -93,7 +94,6 @@ impl Game<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
self.canvas.present();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,6 @@ mod pacman;
|
|||||||
mod entity;
|
mod entity;
|
||||||
mod animation;
|
mod animation;
|
||||||
|
|
||||||
fn redraw(canvas: &mut Canvas<sdl2::video::Window>, tex: &Texture, i: u8) {
|
|
||||||
canvas.set_draw_color(Color::RGB(i, i, i));
|
|
||||||
canvas.clear();
|
|
||||||
canvas
|
|
||||||
.copy(tex, None, None)
|
|
||||||
.expect("Could not render texture on canvas");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let sdl_context = sdl2::init().unwrap();
|
let sdl_context = sdl2::init().unwrap();
|
||||||
let video_subsystem = sdl_context.video().unwrap();
|
let video_subsystem = sdl_context.video().unwrap();
|
||||||
@@ -36,6 +28,7 @@ pub fn main() {
|
|||||||
|
|
||||||
let mut canvas = window
|
let mut canvas = window
|
||||||
.into_canvas()
|
.into_canvas()
|
||||||
|
.accelerated()
|
||||||
.build()
|
.build()
|
||||||
.expect("Could not build canvas");
|
.expect("Could not build canvas");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user