summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 7a54638..976a272 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -41,6 +41,7 @@ struct Input {
last_mouse_pos_on_screen: Option<(f32, f32)>,
last_mouse_world_pos: Option<(f32, f32)>,
is_lmb_pressed: bool,
+ trigger_test_1: bool,
// keybindings
is_up_pressed: bool,
@@ -95,7 +96,16 @@ impl App {
camera.handle_camera_input(&self.input, delta_time)
}
- // // --TEST DRAWING--
+ // --TEST SPAWNING--
+ if self.input.trigger_test_1
+ && let Some(lm) = self.input.last_mouse_world_pos
+ && let Some(rbsm) = &mut self.rb_sim_manager
+ {
+ self.input.trigger_test_1 = false;
+ rbsm.test_spawn_box(lm.0, lm.1);
+ }
+
+ // --TEST DRAWING--
if self.input.is_lmb_pressed
&& let Some(lm) = self.input.last_mouse_world_pos
{
@@ -157,6 +167,7 @@ impl Default for App {
last_mouse_pos_on_screen: None,
last_mouse_world_pos: None,
+ trigger_test_1: false,
is_lmb_pressed: false,
is_up_pressed: false,
is_left_pressed: false,
@@ -240,6 +251,7 @@ impl ApplicationHandler for App {
KeyEvent {
physical_key: PhysicalKey::Code(code),
state,
+ repeat,
..
},
..
@@ -251,12 +263,9 @@ impl ApplicationHandler for App {
KeyCode::KeyS => self.input.is_down_pressed = pressed,
KeyCode::KeyD => self.input.is_right_pressed = pressed,
KeyCode::KeyC => self.world = Some(World::from_default_size()),
- KeyCode::Space => {
- if pressed {
- self.sim_paused = !self.sim_paused
- }
- }
+ KeyCode::Space if pressed => self.sim_paused = !self.sim_paused,
KeyCode::KeyX if pressed => self.ignore_pause_next_tick = true,
+ KeyCode::KeyQ if pressed && !repeat => self.input.trigger_test_1 = true,
_ => {}
}
}