fixed messed up scaling code
This commit is contained in:
parent
c3677a3ff4
commit
ddc8076734
|
@ -85,19 +85,20 @@ pub(crate) fn render_to_window(
|
|||
src: &mut [u8],
|
||||
palette: &[Rgb; 256],
|
||||
window_size: IVec2,
|
||||
screen_size: IVec2,
|
||||
scale: usize,
|
||||
off_x: usize,
|
||||
off_y: usize,
|
||||
) {
|
||||
let start = window_size.x as usize * off_y;
|
||||
let end = start + window_size.x as usize * window_size.y as usize * scale;
|
||||
let end = start + window_size.x as usize * screen_size.y as usize * scale;
|
||||
for (y, row) in target[start..end]
|
||||
.chunks_exact_mut(window_size.x as usize * scale)
|
||||
.enumerate()
|
||||
{
|
||||
let y = y as i32;
|
||||
for x in 0..window_size.x as usize {
|
||||
let p = src[x + y as usize * window_size.x as usize];
|
||||
for x in 0..screen_size.x as usize {
|
||||
let p = src[x + y as usize * screen_size.x as usize];
|
||||
|
||||
for scaley in 0..scale {
|
||||
for scalex in 0..scale {
|
||||
|
|
|
@ -152,8 +152,8 @@ pub(crate) fn run_mapedit() {
|
|||
},
|
||||
WindowEvent::CursorMoved { position, .. } => {
|
||||
let new_pos = IVec2 {
|
||||
x: position.x as i32,
|
||||
y: position.y as i32,
|
||||
x: position.x as i32 / 2,
|
||||
y: position.y as i32 / 2,
|
||||
};
|
||||
let delta = new_pos - *mouse_pos;
|
||||
if *middle_down {
|
||||
|
@ -233,15 +233,15 @@ pub(crate) fn run_mapedit() {
|
|||
)
|
||||
.unwrap();
|
||||
let mut screen_buffer =
|
||||
vec![TRANSPARENT; size.width as usize * size.height as usize];
|
||||
vec![TRANSPARENT; size.width as usize * size.height as usize / 4];
|
||||
let mut window_buffer = surface.buffer_mut().unwrap();
|
||||
render_to_screen(
|
||||
&mut screen_buffer,
|
||||
&gsa,
|
||||
&tileset,
|
||||
IVec2 {
|
||||
x: size.width as i32,
|
||||
y: size.height as i32,
|
||||
x: size.width as i32 / 2,
|
||||
y: size.height as i32 / 2,
|
||||
},
|
||||
);
|
||||
render_to_screen(
|
||||
|
@ -249,8 +249,8 @@ pub(crate) fn run_mapedit() {
|
|||
&gsa2,
|
||||
&tileset,
|
||||
IVec2 {
|
||||
x: size.width as i32,
|
||||
y: size.height as i32,
|
||||
x: size.width as i32 / 2,
|
||||
y: size.height as i32 / 2,
|
||||
},
|
||||
);
|
||||
render_to_window(
|
||||
|
@ -261,7 +261,11 @@ pub(crate) fn run_mapedit() {
|
|||
x: size.width as i32,
|
||||
y: size.height as i32,
|
||||
},
|
||||
1,
|
||||
IVec2 {
|
||||
x: size.width as i32 / 2,
|
||||
y: size.height as i32 / 2,
|
||||
},
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
|
|
|
@ -212,6 +212,10 @@ pub fn run<TGame: 'static>(
|
|||
x: size.width as i32,
|
||||
y: size.height as i32,
|
||||
},
|
||||
IVec2 {
|
||||
x: SCREEN_WIDTH as i32,
|
||||
y: SCREEN_HEIGHT as i32,
|
||||
},
|
||||
*scale,
|
||||
*off_x,
|
||||
*off_y,
|
||||
|
|
Loading…
Reference in New Issue