mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-11 02:08:01 -06:00
chore: lifetimes
This commit is contained in:
12
src/game.rs
12
src/game.rs
@@ -11,16 +11,16 @@ use sdl2::ttf::Font;
|
|||||||
use sdl2::video::WindowContext;
|
use sdl2::video::WindowContext;
|
||||||
use sdl2::{pixels::Color, render::Canvas, video::Window};
|
use sdl2::{pixels::Color, render::Canvas, video::Window};
|
||||||
|
|
||||||
|
use crate::animation::AtlasTexture;
|
||||||
use crate::audio::Audio;
|
use crate::audio::Audio;
|
||||||
use crate::animation::{AtlasTexture, FrameDrawn};
|
|
||||||
use crate::constants::RAW_BOARD;
|
use crate::constants::RAW_BOARD;
|
||||||
|
use crate::debug::{DebugMode, DebugRenderer};
|
||||||
use crate::direction::Direction;
|
use crate::direction::Direction;
|
||||||
use crate::entity::{Entity, Renderable};
|
use crate::edible::{reconstruct_edibles, Edible, EdibleKind};
|
||||||
|
use crate::entity::Renderable;
|
||||||
use crate::ghosts::blinky::Blinky;
|
use crate::ghosts::blinky::Blinky;
|
||||||
use crate::map::Map;
|
use crate::map::Map;
|
||||||
use crate::pacman::Pacman;
|
use crate::pacman::Pacman;
|
||||||
use crate::debug::{DebugMode, DebugRenderer};
|
|
||||||
use crate::edible::{reconstruct_edibles, Edible, EdibleKind};
|
|
||||||
|
|
||||||
// Embed texture data directly into the executable
|
// Embed texture data directly into the executable
|
||||||
static PACMAN_TEXTURE_DATA: &[u8] = include_bytes!("../assets/32/pacman.png");
|
static PACMAN_TEXTURE_DATA: &[u8] = include_bytes!("../assets/32/pacman.png");
|
||||||
@@ -52,7 +52,7 @@ pub struct Game<'a> {
|
|||||||
edibles: Vec<Edible<'a>>,
|
edibles: Vec<Edible<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Game<'_> {
|
impl<'a> Game<'a> {
|
||||||
/// Creates a new `Game` instance.
|
/// Creates a new `Game` instance.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -61,7 +61,7 @@ impl Game<'_> {
|
|||||||
/// * `texture_creator` - The SDL texture creator.
|
/// * `texture_creator` - The SDL texture creator.
|
||||||
/// * `ttf_context` - The SDL TTF context.
|
/// * `ttf_context` - The SDL TTF context.
|
||||||
/// * `_audio_subsystem` - The SDL audio subsystem (currently unused).
|
/// * `_audio_subsystem` - The SDL audio subsystem (currently unused).
|
||||||
pub fn new<'a>(
|
pub fn new(
|
||||||
canvas: &'a mut Canvas<Window>,
|
canvas: &'a mut Canvas<Window>,
|
||||||
texture_creator: &'a TextureCreator<WindowContext>,
|
texture_creator: &'a TextureCreator<WindowContext>,
|
||||||
ttf_context: &'a sdl2::ttf::Sdl2TtfContext,
|
ttf_context: &'a sdl2::ttf::Sdl2TtfContext,
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ impl<'a> Moving for Ghost<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Renderable for Ghost<'_> {
|
impl<'a> Renderable for Ghost<'a> {
|
||||||
fn render(&self, canvas: &mut sdl2::render::Canvas<sdl2::video::Window>) {
|
fn render(&self, canvas: &mut sdl2::render::Canvas<sdl2::video::Window>) {
|
||||||
let pos = self.base.base.pixel_position;
|
let pos = self.base.base.pixel_position;
|
||||||
self.body_sprite.render(canvas, pos, Direction::Right, None);
|
self.body_sprite.render(canvas, pos, Direction::Right, None);
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ unsafe fn attach_console() {
|
|||||||
mod animation;
|
mod animation;
|
||||||
mod audio;
|
mod audio;
|
||||||
mod constants;
|
mod constants;
|
||||||
|
mod debug;
|
||||||
mod direction;
|
mod direction;
|
||||||
|
mod edible;
|
||||||
mod entity;
|
mod entity;
|
||||||
mod game;
|
mod game;
|
||||||
mod ghost;
|
mod ghost;
|
||||||
@@ -64,8 +66,6 @@ mod helper;
|
|||||||
mod map;
|
mod map;
|
||||||
mod modulation;
|
mod modulation;
|
||||||
mod pacman;
|
mod pacman;
|
||||||
mod debug;
|
|
||||||
mod edible;
|
|
||||||
|
|
||||||
/// The main entry point of the application.
|
/// The main entry point of the application.
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user