#[cfg(not(target_arch = "wasm32"))] mod audio; mod game; mod levels; mod menu; mod particle_effect; use bevy::{core_pipeline::clear_color::ClearColorConfig, prelude::*}; use bevy_rapier2d::prelude::*; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] enum AppState { Menu, Game, Win, } fn main() { let (audio_event_sender, audio_event_receiver) = crossbeam_channel::bounded::(512); #[cfg(not(target_arch = "wasm32"))] std::thread::spawn(move || audio::setup(audio_event_receiver)); App::new() .insert_resource(audio_event_sender) .add_state(AppState::Menu) .add_plugins(DefaultPlugins) .add_plugin(RapierPhysicsPlugin::::pixels_per_meter(64.0)) .add_plugin(RapierDebugRenderPlugin::default()) .add_plugin(menu::MenuPlugin) .add_plugin(game::GamePlugin) .add_plugin(particle_effect::ParticleEffectPlugin) .add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new()) .add_startup_system(setup) .run(); } fn setup(mut commands: Commands, asset_server: Res) { #[cfg(not(target_arch = "wasm32"))] let font: Handle = asset_server.load("UacariLegacy-Thin.ttf"); #[cfg(target_arch = "wasm32")] let font: Handle = asset_server.load("UacariLegacy-Thin.ttf"); commands.insert_resource(font); commands.spawn_bundle(Camera2dBundle { camera_2d: Camera2d { clear_color: ClearColorConfig::Custom(Color::BLACK), }, ..Default::default() }); commands.insert_resource(AmbientLight { color: Color::WHITE, brightness: 0.6, }); }