Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ bevy = { version = "0.17.2", default-features = false, features = [
"bevy_winit",
"bevy_state",
"bevy_audio",
"default_font",
"multi_threaded",
"png",
"std",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added art/fonts.aseprite
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file modified assets/font.ttf
Binary file not shown.
Binary file removed assets/sprites/asteroids/asteroid1.png
Binary file not shown.
Binary file removed assets/sprites/asteroids/asteroid2.png
Binary file not shown.
Binary file removed assets/sprites/fonts.aseprite
Binary file not shown.
Binary file removed assets/sprites/fonts.png
Binary file not shown.
Binary file removed assets/sprites/newgame.png
Binary file not shown.
Binary file removed assets/sprites/planet.png
Binary file not shown.
Binary file removed assets/sprites/quit.png
Binary file not shown.
Binary file removed assets/sprites/settings.png
Binary file not shown.
Binary file removed assets/sprites/ships/ship1-hitbox.png
Binary file not shown.
Binary file removed assets/sprites/ships/ship1.png
Binary file not shown.
35 changes: 15 additions & 20 deletions src/audio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,22 @@ fn on_play_soundtrack_event(
Soundtrack::BattleTheme => soundtracks.battle_theme.clone(),
};

let Ok((entity, mut audio, mut playback)) = audio_player.single_mut() else {
commands.spawn((
SoundtrackPlayer,
AudioPlayer(track_handle.clone()),
PlaybackSettings {
mode: PlaybackMode::Loop,
volume: Volume::Linear(0.0),
..default()
},
FadeIn { duration: 4.0 },
Transform::default(),
GlobalTransform::default(),
));
return;
};

if audio.0 != track_handle {
audio.0 = track_handle.clone();
playback.volume = Volume::Linear(0.0);
commands.entity(entity).insert(FadeIn { duration: 4.0 });
for audio_player_entity in audio_player.iter_mut() {
commands.entity(audio_player_entity.0).despawn();
}

commands.spawn((
SoundtrackPlayer,
AudioPlayer(track_handle.clone()),
PlaybackSettings {
mode: PlaybackMode::Loop,
volume: Volume::Linear(0.0),
..default()
},
FadeIn { duration: 4.0 },
Transform::default(),
GlobalTransform::default(),
));
}

fn on_play_sfx_event(sfx_event: On<PlaySfxEvent>, mut commands: Commands, sfx: Res<SfxLibrary>) {
Expand Down
2 changes: 2 additions & 0 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ fn setup_input(mut commands: Commands) {
player_input_map.insert(Action::Select, KeyCode::Enter);
player_input_map.insert(Action::Select, GamepadButton::South);
player_input_map.insert(Action::Pause, KeyCode::Escape);
player_input_map.insert(Action::Pause, GamepadButton::Start);
player_input_map.insert(Action::Pause, GamepadButton::Select);

commands.spawn(player_input_map);
}
16 changes: 13 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy::{

use bevy_embedded_assets::{EmbeddedAssetPlugin, PluginMode};

use crate::input::InputPlugin;
use crate::{input::InputPlugin, sundry::BLACK};

mod audio;
mod input;
Expand Down Expand Up @@ -59,6 +59,7 @@ impl Plugin for AppPlugin {
mode: WindowMode::BorderlessFullscreen(MonitorSelection::Current),
#[cfg(debug_assertions)]
mode: WindowMode::Windowed,
// resolution: WindowResolution::new(853, 480),
resolution: WindowResolution::new(1920, 1080),
resizable: false,
position: WindowPosition::Centered(MonitorSelection::Current),
Expand All @@ -69,6 +70,8 @@ impl Plugin for AppPlugin {
.set(ImagePlugin::default_nearest()),
);

app.insert_resource(ScaleFactor(1.0));

app.add_plugins(InputPlugin);

app.add_plugins(audio::plugin);
Expand Down Expand Up @@ -120,10 +123,11 @@ fn spawn_camera(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
Camera {
order: -1,
target: RenderTarget::Image(image_handle.clone().into()),
clear_color: ClearColorConfig::Custom(Color::srgb_u8(9, 10, 20)),
clear_color: ClearColorConfig::Custom(BLACK),
..default()
},
Msaa::Off,
UiAntiAlias::Off,
InGameCamera,
PIXEL_PERFECT_LAYERS,
));
Expand All @@ -132,9 +136,13 @@ fn spawn_camera(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
commands.spawn((Camera2d, Msaa::Off, OuterCamera, HIGH_RES_LAYERS));
}

#[derive(Resource)]
pub struct ScaleFactor(f32);

fn fit_canvas(
mut resize_messages: MessageReader<WindowResized>,
mut projection: Single<&mut Projection, With<OuterCamera>>,
mut scale_factor: ResMut<ScaleFactor>,
) {
let Projection::Orthographic(proj) = &mut **projection else {
return;
Expand All @@ -143,6 +151,8 @@ fn fit_canvas(
for msg in resize_messages.read() {
let h_scale = msg.width / RES_WIDTH as f32;
let v_scale = msg.height / RES_HEIGHT as f32;
proj.scale = 1. / h_scale.min(v_scale);
let scale = h_scale.min(v_scale);
proj.scale = 1. / scale;
scale_factor.0 = scale;
}
}
Loading