Skip to content

Commit 7a0de80

Browse files
Made it so you can pan around in the editor with the middle mouse button
This is way better than the arrow keys lol. Also it's kinda weird in fullscreen just so you know.
1 parent 487935d commit 7a0de80

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/game/editor.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,14 @@ pub fn object_ped(
229229
} else {
230230
println!("wtf did you do bro");
231231
}
232+
}
233+
234+
pub fn panning(
235+
cam_pos_x: &mut f32,
236+
cam_pos_y: &mut f32
237+
) {
238+
let mouse_delta = mouse_delta_position();
239+
240+
*cam_pos_x += mouse_delta.x * 70.0;
241+
*cam_pos_y -= mouse_delta.y * 60.0;
232242
}

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,10 @@ async fn main() {
910910
&mut cam_pos_x,
911911
&mut obj_grid
912912
);
913+
914+
if is_mouse_button_down(MouseButton::Middle) {
915+
editor::panning(&mut cam_pos_x, &mut cam_pos_y);
916+
}
913917
}
914918

915919
GameState::LevelComplete => {

0 commit comments

Comments
 (0)