Skip to content

Commit 75f1209

Browse files
committed
Pass current particles in setup
1 parent adc1fbd commit 75f1209

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

src/app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl App {
1919
pub fn new() -> Self {
2020
App {
2121
running: true,
22-
particles: vec![vec![0.0; 100]; 100],
22+
particles: vec![vec![0.0; 1]; 1],
2323
show_info: false,
2424
texture_index: 0,
2525
textures: vec![],

src/lua_sim.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ impl LuaSim {
2929

3030
// Call methods on the instance
3131
let init_func: mlua::Function = instance.get("setup")?;
32-
let sim: mlua::Table = init_func.call(())?;
33-
34-
sim.call_method("set_particles", particles)?;
32+
let sim: mlua::Table = init_func.call(particles)?;
3533

3634
self.simulation_instance = Some(sim);
3735

src/main.rs

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ fn main() -> AppResult<()> {
1717
let mut tui = init_terminal(&mut app)?;
1818
tui.init()?;
1919

20+
let terminal_size = tui.terminal.size()?;
21+
let width = terminal_size.width as usize;
22+
let height = terminal_size.height as usize;
23+
app.change_dimensions(width, height);
24+
2025
let mut lua_sim = LuaSim::new();
2126

2227
// Set up the initial simulation
@@ -27,6 +32,7 @@ fn main() -> AppResult<()> {
2732
.unwrap_or(0);
2833
lua_sim.current_simulation_idx = noise_idx;
2934
app.current_simulation_idx = noise_idx;
35+
3036
lua_sim.load_simulation(&mut app)?;
3137

3238
while app.running {

src/simulations_lua/fire/simulation.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Simulation = {}
22
Simulation.__index = Simulation
33

4-
function Simulation.setup()
4+
function Simulation.setup(particles)
55
local self = setmetatable({}, Simulation)
6-
self.particles = { {} }
6+
self.particles = particles
77
self.textures = { { ' ', '·', '+', '#' }, { ' ', '.', 'o', '@' } }
88
self.params = {
99
noise_intensity = 0.07,

src/simulations_lua/noise/simulation.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Simulation = {}
22
Simulation.__index = Simulation
33

4-
function Simulation.setup()
4+
function Simulation.setup(particles)
55
local self = setmetatable({}, Simulation)
6-
self.particles = { {} }
6+
self.particles = particles
77
self.textures = { { ' ', '·', '+', '#' }, { ' ', '.', 'o', '@' } }
88
self.params = {
99
noise_intensity = 1,

0 commit comments

Comments
 (0)