mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-09 12:08:05 -06:00
fix: do not use canvas.output_size() for calculations due to browser behavior
This commit is contained in:
@@ -49,6 +49,13 @@ pub const CANVAS_SIZE: UVec2 = UVec2::new(
|
||||
(BOARD_CELL_SIZE.y + BOARD_CELL_OFFSET.y) * CELL_SIZE,
|
||||
);
|
||||
|
||||
pub const LARGE_SCALE: f32 = 2.6;
|
||||
|
||||
pub const LARGE_CANVAS_SIZE: UVec2 = UVec2::new(
|
||||
(((BOARD_CELL_SIZE.x + BOARD_CELL_OFFSET.x) * CELL_SIZE) as f32 * LARGE_SCALE) as u32,
|
||||
(((BOARD_CELL_SIZE.y + BOARD_CELL_OFFSET.y) * CELL_SIZE) as f32 * LARGE_SCALE) as u32,
|
||||
);
|
||||
|
||||
/// Collider size constants for different entity types
|
||||
pub mod collider {
|
||||
use super::CELL_SIZE;
|
||||
|
||||
@@ -157,9 +157,9 @@ impl Game {
|
||||
map_texture.set_scale_mode(ScaleMode::Nearest);
|
||||
|
||||
// Create debug texture at output resolution for crisp debug rendering
|
||||
let output_size = canvas.output_size().unwrap();
|
||||
let output_size = constants::LARGE_CANVAS_SIZE;
|
||||
let mut debug_texture = texture_creator
|
||||
.create_texture_target(Some(sdl2::pixels::PixelFormatEnum::ARGB8888), output_size.0, output_size.1)
|
||||
.create_texture_target(Some(sdl2::pixels::PixelFormatEnum::ARGB8888), output_size.x, output_size.y)
|
||||
.map_err(|e| GameError::Sdl(e.to_string()))?;
|
||||
|
||||
// Debug texture is copied over the backbuffer, it requires transparency abilities
|
||||
|
||||
@@ -142,8 +142,6 @@ pub fn ghost_collision_system(
|
||||
events.write(AudioEvent::PlayEat);
|
||||
} else {
|
||||
// Pac-Man dies (this would need a death system)
|
||||
// For now, just log it
|
||||
tracing::warn!("Pac-Man collided with ghost while not frightened!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Debug rendering system
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use crate::constants::{BOARD_PIXEL_OFFSET, CANVAS_SIZE};
|
||||
use crate::constants::{self, BOARD_PIXEL_OFFSET};
|
||||
use crate::map::builder::Map;
|
||||
use crate::systems::{Collider, CursorPosition, NodeId, Position, SystemTimings};
|
||||
use crate::texture::ttf::{TtfAtlas, TtfRenderer};
|
||||
@@ -215,9 +215,7 @@ pub fn debug_render_system(
|
||||
if !debug_state.enabled {
|
||||
return;
|
||||
}
|
||||
let output = UVec2::from(canvas.output_size().unwrap()).as_vec2();
|
||||
let logical = CANVAS_SIZE.as_vec2();
|
||||
let scale = (output / logical).min_element();
|
||||
let scale = constants::LARGE_SCALE as f32;
|
||||
|
||||
// Create debug text renderer
|
||||
let text_renderer = TtfRenderer::new(1.0);
|
||||
|
||||
Reference in New Issue
Block a user