mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-17 14:12:40 -06:00
feat: re-add board offset logic, fixup text rendering
This commit is contained in:
@@ -63,13 +63,13 @@ impl Renderable for Edible {
|
||||
let pos = self.base.pixel_position;
|
||||
let dest = match &mut self.sprite {
|
||||
EdibleSprite::Pellet(sprite) => {
|
||||
let mut tile = sprite.current_tile();
|
||||
let tile = sprite.current_tile();
|
||||
let x = pos.x + ((crate::constants::CELL_SIZE as i32 - tile.size.x as i32) / 2);
|
||||
let y = pos.y + ((crate::constants::CELL_SIZE as i32 - tile.size.y as i32) / 2);
|
||||
sdl2::rect::Rect::new(x, y, tile.size.x as u32, tile.size.y as u32)
|
||||
}
|
||||
EdibleSprite::PowerPellet(sprite) => {
|
||||
let mut tile = sprite.animation.current_tile();
|
||||
let tile = sprite.animation.current_tile();
|
||||
let x = pos.x + ((crate::constants::CELL_SIZE as i32 - tile.size.x as i32) / 2);
|
||||
let y = pos.y + ((crate::constants::CELL_SIZE as i32 - tile.size.y as i32) / 2);
|
||||
sdl2::rect::Rect::new(x, y, tile.size.x as u32, tile.size.y as u32)
|
||||
|
||||
@@ -6,7 +6,7 @@ pub mod pacman;
|
||||
pub mod speed;
|
||||
|
||||
use crate::{
|
||||
constants::{MapTile, BOARD_CELL_SIZE, BOARD_OFFSET, CELL_SIZE},
|
||||
constants::{MapTile, BOARD_CELL_OFFSET, BOARD_CELL_SIZE, CELL_SIZE},
|
||||
entity::{direction::Direction, speed::SimpleTickModulator},
|
||||
map::Map,
|
||||
};
|
||||
@@ -145,8 +145,8 @@ impl Moving for MovableEntity {
|
||||
}
|
||||
fn update_cell_position(&mut self) {
|
||||
self.base.cell_position = UVec2::new(
|
||||
(self.base.pixel_position.x as u32 / CELL_SIZE) - BOARD_OFFSET.x,
|
||||
(self.base.pixel_position.y as u32 / CELL_SIZE) - BOARD_OFFSET.y,
|
||||
(self.base.pixel_position.x as u32 / CELL_SIZE) - BOARD_CELL_OFFSET.x,
|
||||
(self.base.pixel_position.y as u32 / CELL_SIZE) - BOARD_CELL_OFFSET.y,
|
||||
);
|
||||
}
|
||||
fn next_cell(&self, direction: Option<Direction>) -> IVec2 {
|
||||
|
||||
Reference in New Issue
Block a user