Fix WASM build
This commit is contained in:
parent
972cd26876
commit
ce37ddd0bd
7 changed files with 38 additions and 203 deletions
19
src/main.rs
19
src/main.rs
|
|
@ -1,14 +1,11 @@
|
|||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod audio;
|
||||
mod game;
|
||||
mod levels;
|
||||
mod menu;
|
||||
mod particle_effect;
|
||||
|
||||
use bevy::{
|
||||
core_pipeline::clear_color::ClearColorConfig,
|
||||
prelude::*,
|
||||
render::settings::{WgpuFeatures, WgpuSettings},
|
||||
};
|
||||
use bevy::{core_pipeline::clear_color::ClearColorConfig, prelude::*};
|
||||
use bevy_rapier2d::prelude::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
||||
|
|
@ -19,16 +16,13 @@ enum AppState {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let (audio_event_sender, audio_event_receiver) = crossbeam_channel::bounded(512);
|
||||
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));
|
||||
|
||||
let mut options = WgpuSettings::default();
|
||||
options
|
||||
.features
|
||||
.set(WgpuFeatures::VERTEX_WRITABLE_STORAGE, true);
|
||||
App::new()
|
||||
.insert_resource(options)
|
||||
.insert_resource(audio_event_sender)
|
||||
.add_state(AppState::Menu)
|
||||
.add_plugins(DefaultPlugins)
|
||||
|
|
@ -43,6 +37,9 @@ fn main() {
|
|||
}
|
||||
|
||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let font: Handle<Font> = asset_server.load("UacariLegacy-Thin.ttf");
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let font: Handle<Font> = asset_server.load("UacariLegacy-Thin.ttf");
|
||||
commands.insert_resource(font);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue