bevyjam/src/main.rs

60 lines
1.5 KiB
Rust

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_hanabi::*;
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);
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)
.add_plugin(HanabiPlugin)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(64.0))
.add_plugin(RapierDebugRenderPlugin::default())
.add_plugin(menu::MenuPlugin)
.add_plugin(game::GamePlugin)
.add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new())
.add_startup_system(setup)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let font: Handle<Font> = 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,
});
}