invaders/src/lib.rs

28 lines
650 B
Rust

use wasm_bindgen::prelude::*;
mod config;
mod game;
mod render;
mod utils;
// use wee_alloc as the global allocator if the feature is enabled
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[wasm_bindgen]
pub fn wasm_main() {
// set panic hook when console_error_panic_hook feature is enabled
#[cfg(feature = "console_error_panic_hook")]
utils::set_panic_hook();
}
/// starts the game. gets called when the "play game" button is pressed.
#[wasm_bindgen]
pub fn game_start() {
match game::run() {
Ok(_) => (),
Err(x) => utils::alert_err(x),
}
}