bevyjam/src/main.rs

56 lines
1.5 KiB
Rust

#[cfg(not(target_arch = "wasm32"))]
mod audio;
mod filters;
mod game;
mod levels;
mod menu;
mod particle_effect;
use bevy::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::<game::AudioMsg>(512);
#[cfg(not(target_arch = "wasm32"))]
std::thread::spawn(move || audio::setup(audio_event_receiver));
App::new()
.insert_resource(Msaa { samples: 4 })
.insert_resource(audio_event_sender)
.add_state(AppState::Menu)
.insert_resource(ClearColor(Color::BLACK))
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::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_system(bevy::window::close_on_esc)
.add_startup_system(setup)
.run();
}
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);
commands.spawn_bundle(Camera2dBundle::default());
commands.insert_resource(AmbientLight {
color: Color::WHITE,
brightness: 0.6,
});
}