diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/src/main.rs b/src/main.rs index c947f05..e066e56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ use crate::{ materials::{MaterialId, fire::FireCellView}, }, cell_sim::{sim::sim_tick, world::World}, + lib::force::apply_explosion, particle_sim::{ParticleManager, particle::Particle}, rb_sim::{DebugRenderMode, RbSimManager, debug_ops::DebugOperator}, write_rb_entity_to_world, @@ -157,40 +158,16 @@ impl App { { let mouse = Vec2::new(lm.0, lm.1); self.input.trigger_test_4 = false; - let r: i32 = 30; - for x in -r..r { - for y in -r..r { - if x.pow(2) + y.pow(2) < r.pow(2) { - // if there's a cell, convert it to a particle - let pos = Vec2::new(mouse.x + x as f32, mouse.y + y as f32); - let ipos = pos.round().as_ivec2(); - if let Some(cell) = world.get_cell_from_game_position(ipos.x, ipos.y) { - let mut fire = Cell::from_material(MaterialId::Fire); - fire.set_ticks_lived(300); - fire.match_parity(self.sim_seqno + 1); - if cell.material == MaterialId::Void && random_range(0.0..1.0) > 0.5 { - world.set_cell_from_game_position(ipos.x, ipos.y, fire, false); - } else { - world.set_cell_from_game_position(ipos.x, ipos.y, fire, false); - if random_range(0.0..1.0) > 0.6 { - let d = pos.distance(mouse); - if d < 0.001 { - continue; - } // skip the center cell - let dir = (pos - mouse) / d; // normalize, reusing d - let falloff = 1.0 - (d / r as f32); // 1 at center, 0 at edge - let vel = (Vec2::new(0.0, -0.6) + dir) - * 300.0 - * random_range(0.5..1.5) - * falloff; - pm.particles - .push(Particle::new(pos, vel, cell.material, 5.0)); - } - } - } - } - } - } + apply_explosion( + mouse, + 30, + Vec2::new(0.0, -0.6), + 300.0, + self.sim_seqno, + pm, + world, + rbsm, + ); } // --TEST DRAWING-- |
