Initial Fyrox project
This commit is contained in:
commit
27d327933e
23 changed files with 5633 additions and 0 deletions
45
executor-wasm/src/lib.rs
Normal file
45
executor-wasm/src/lib.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
//! Executor with your game connected to it as a plugin.
|
||||
use fyrox::engine::executor::Executor;
|
||||
use red_dragon_pon::Game;
|
||||
use fyrox::core::wasm_bindgen::{self, prelude::*};
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
fn error(msg: String);
|
||||
|
||||
type Error;
|
||||
|
||||
#[wasm_bindgen(constructor)]
|
||||
fn new() -> Error;
|
||||
|
||||
#[wasm_bindgen(structural, method, getter)]
|
||||
fn stack(error: &Error) -> String;
|
||||
}
|
||||
|
||||
fn custom_panic_hook(info: &std::panic::PanicHookInfo) {
|
||||
let mut msg = info.to_string();
|
||||
msg.push_str("\n\nStack:\n\n");
|
||||
let e = Error::new();
|
||||
let stack = e.stack();
|
||||
msg.push_str(&stack);
|
||||
msg.push_str("\n\n");
|
||||
error(msg);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_panic_hook() {
|
||||
use std::sync::Once;
|
||||
static SET_HOOK: Once = Once::new();
|
||||
SET_HOOK.call_once(|| {
|
||||
std::panic::set_hook(Box::new(custom_panic_hook));
|
||||
});
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn main() {
|
||||
set_panic_hook();
|
||||
let mut executor = Executor::new();
|
||||
executor.add_plugin(Game::default());
|
||||
executor.run()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue