mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-03-24 10:59:20 +00:00
fix texture bleeding and object jittering
This commit is contained in:
parent
f5c813aaab
commit
cf5ee5b9c5
|
@ -22,7 +22,7 @@ use crate::sound::SoundManager;
|
|||
use crate::stage::StageData;
|
||||
use crate::str;
|
||||
use crate::text_script::{ScriptMode, TextScriptExecutionState, TextScriptVM};
|
||||
use crate::texture_set::TextureSet;
|
||||
use crate::texture_set::{TextureSet, g_mag};
|
||||
use crate::touch_controls::TouchControls;
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||
|
@ -169,6 +169,8 @@ impl SharedGameState {
|
|||
pub fn new(ctx: &mut Context) -> GameResult<SharedGameState> {
|
||||
let screen_size = graphics::drawable_size(ctx);
|
||||
let scale = screen_size.1.div(235.0).floor().max(1.0);
|
||||
unsafe { g_mag = scale };
|
||||
|
||||
let canvas_size = (screen_size.0 / scale, screen_size.1 / scale);
|
||||
|
||||
let mut constants = EngineConstants::defaults();
|
||||
|
@ -344,6 +346,7 @@ impl SharedGameState {
|
|||
self.screen_size = graphics::drawable_size(ctx);
|
||||
self.scale = self.screen_size.1.div(240.0).floor().max(1.0);
|
||||
self.canvas_size = (self.screen_size.0 / self.scale, self.screen_size.1 / self.scale);
|
||||
unsafe { g_mag = self.scale };
|
||||
|
||||
graphics::set_screen_coordinates(ctx, graphics::Rect::new(0.0, 0.0, self.screen_size.0, self.screen_size.1))?;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ use crate::engine_constants::EngineConstants;
|
|||
use crate::shared_game_state::{Season, Settings};
|
||||
use crate::str;
|
||||
|
||||
pub static mut g_mag: f32 = 1.0;
|
||||
|
||||
pub struct SizedBatch {
|
||||
pub batch: SpriteBatch,
|
||||
width: usize,
|
||||
|
@ -76,11 +78,16 @@ impl SizedBatch {
|
|||
self.add_rect_scaled(x, y, self.scale_x, self.scale_y, rect)
|
||||
}
|
||||
|
||||
pub fn add_rect_scaled(&mut self, x: f32, y: f32, scale_x: f32, scale_y: f32, rect: &common::Rect<u16>) {
|
||||
pub fn add_rect_scaled(&mut self, mut x: f32, mut y: f32, scale_x: f32, scale_y: f32, rect: &common::Rect<u16>) {
|
||||
if (rect.right - rect.left) == 0 || (rect.bottom - rect.top) == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
x = (x * g_mag).floor() / g_mag;
|
||||
y = (y * g_mag).floor() / g_mag;
|
||||
}
|
||||
|
||||
let param = DrawParam::new()
|
||||
.src(Rect::new(rect.left as f32 / self.width as f32,
|
||||
rect.top as f32 / self.height as f32,
|
||||
|
|
Loading…
Reference in a new issue