summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs
index 492f0ba..7620f92 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -28,10 +28,9 @@ use crate::{
},
renderer::RendererState,
sim::{
- cell::cell::Cell,
+ cell::Cell,
cell_manager::manager::CellManager,
- lib::force::apply_explosion,
- particle_manager::particle::Particle,
+ lib::force::{apply_bullet, apply_explosion},
rb_manager::DebugRenderMode,
sim_manager::{SimCtx, SimManager},
},
@@ -80,6 +79,9 @@ struct App {
window: Option<Arc<Window>>,
renderer_state: Option<RendererState>,
+ // tests
+ bullet_origin: Option<Vec2>,
+
// game
input: Input,
camera: Option<Camera>,
@@ -125,16 +127,20 @@ impl App {
&& let Some(lm) = self.input.last_mouse_world_pos
{
self.input.trigger_test_3 = false;
- for _ in 0..100 {
- sim.particle_manager.particles.push(Particle {
- position: Vec2::new(
- lm.0 + random_range(-25.0..25.0),
- lm.1 + random_range(-25.0..25.0),
- ),
- velocity: Vec2::ZERO,
- material: MaterialId::Sand,
- life: 2.0,
- })
+ if let Some(origin) = self.bullet_origin {
+ apply_bullet(
+ &mut SimCtx {
+ cell_manager: &mut sim.cell_manager,
+ particle_manager: &mut sim.particle_manager,
+ rb_manager: &mut sim.rb_manager,
+ },
+ origin,
+ Vec2::new(lm.0, lm.1),
+ 800,
+ );
+ self.bullet_origin = None;
+ } else {
+ self.bullet_origin = Some(Vec2::new(lm.0, lm.1));
}
}
@@ -202,6 +208,8 @@ impl Default for App {
window: None,
renderer_state: None,
+ bullet_origin: None,
+
input: Input {
last_mouse_pos_on_screen: None,
last_mouse_world_pos: None,