feat: re-add board offset logic, fixup text rendering

This commit is contained in:
2025-07-26 15:26:37 -05:00
parent a1d37a1a0b
commit 7a6182cb85
8 changed files with 42 additions and 28 deletions

View File

@@ -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)

View File

@@ -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 {