diff options
| author | Mica White <botahamec@outlook.com> | 2026-07-06 13:59:36 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-07-06 13:59:36 -0400 |
| commit | e8f85e4a723b772c099a3c03a6cb721c48561e4b (patch) | |
| tree | a879493f40ba52399c2af05eacdb95b8939b0712 /src/main.rs | |
| parent | bdbd5faeb7be5e5f81c1f4a952c8110df9e9b990 (diff) | |
Fully support WASM (in some contexts)
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs index bd42e18..d39b0f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::time::SystemTime; +use std::{io::BufWriter, time::SystemTime}; use crossterm::{event::KeyCode, style::ContentStyle}; use mimalloc::MiMalloc; @@ -7,7 +7,8 @@ use tortuise::{ file::FileManager, input::InputManager, scene::switch_scenes, - script::{ScriptContext, ScriptDeclaration, ScriptManager, WasmRunner}, + script::{ScriptContext, ScriptManager, WasmRunner}, + time::TimeContext, }; #[global_allocator] @@ -63,28 +64,17 @@ fn main() { .unwrap_manifest() .clone(); - let stdout = Box::new(std::io::stdout().lock()); + let stdout = Box::new(BufWriter::new(std::io::stdout().lock())); let mut buffer = Buffer::new(stdout).unwrap(); let mut input = InputManager::new(); + let mut time = TimeContext::new(); + let mut scripts = ScriptManager::new(&manifest.scripts); let mut context = ScriptContext { buffer: &mut buffer, input: &input, + time: &time, }; - let scripts = [ - ScriptDeclaration::Static { - start: Some(init_first_frame), - update: Some(render_frame_rate), - end: None, - }, - ScriptDeclaration::Static { - start: None, - update: Some(exit_on_escape), - end: None, - }, - ]; - let mut scripts = ScriptManager::new(&scripts); - switch_scenes( &manifest.scenes, &mut scripts, @@ -105,13 +95,15 @@ fn main() { } } Event::Render => { + buffer.cells.clear(); let mut context = ScriptContext { buffer, input: &input, + time: &time, }; scripts.run_scripts(&mut context, &wasm_runner, &mut files); input.reset_next_frame(); - puffin::GlobalProfiler::lock().new_frame(); + time.next_frame(); } }) .unwrap(); |
