// example of using bevy games engine with hot reloadable
// $ cargo init
// $ cargo add bevy
//
// Cargo.toml
// [package]
// name = "project name"
// version = "0.1.0"
// authors = ["XXXXX "]
// edition = "2025"
//
// [features]
// hot = ["bevy_dexterous_developer/hot"]
//
// [dependencies]
// bevy = "0.14"
// bevy_dexterous_developer = "0.4"
use bevy::prelude::*;
use bevy_dexterous_developer::*;
const GAME_TITLE: &str = "My 2D Action Game";
const DEFAULT_WINDOW_WIDTH: f32 = 1280.0;
const DEFAULT_WINDOW_HEIGHT: f32 = 720.0;
reloadable_main!((initial_plugins) {
App::new()
// Specifying the window background color
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
// Window initial settings
.insert_resource(
WindowDescriptor {
title: GAME_TITLE.to_string(),
width: DEFAULT_WINDOW_WIDTH,
height: DEFAULT_WINDOW_HEIGHT,
resizable: false, // Disable window resizing
..Default::default()
}
)
// All functionality of the Bevy engine is implemented as plugins.
.add_plugins(initial_plugins.initialize::())
.add_systems(Startup, setup)
//.add_systems(OnEnter, sound_setup)
//.add_systems(Update, (sound_system, play_sound))
//.add_systems(OnExit, sound_cleanup);
.add_systems(Update, player_movement.reloadable())
.run();
});
// set-up scene
fn setup(mut commands: Commands, asset_server: Res) {
commands.spawn(Camera2d::default());
commands.spawn(Sprite::from_image(asset_server.load("bevy_bird_dark.png")));
}
// hot re-loadable function
fn player_movement(
mut query: Query<&mut Transform, With>,
time: Res