wasm thread
This commit is contained in:
parent
cc2877c9d8
commit
61cb0ce6b4
5 changed files with 131 additions and 8 deletions
18
src/main.rs
18
src/main.rs
|
|
@ -13,6 +13,11 @@ use bevy::{
|
|||
use bevy_common_assets::json::JsonAssetPlugin;
|
||||
use bevy_rapier2d::prelude::*;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use std::thread;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_thread as thread;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
enum AppState {
|
||||
Menu,
|
||||
|
|
@ -20,12 +25,23 @@ enum AppState {
|
|||
Win,
|
||||
}
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[wasm_bindgen(start)] pub fn dummy_main() {}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run() {
|
||||
main();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (audio_event_sender, audio_event_receiver) =
|
||||
crossbeam_channel::bounded::<game::AudioMsg>(512);
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
std::thread::spawn(move || audio::setup(audio_event_receiver));
|
||||
thread::spawn(move || audio::setup(audio_event_receiver));
|
||||
thread::spawn(|| {/* ... */});
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let first_level = game::LevelId(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue