chore(screen): delete Credits screen

This commit is contained in:
Kristofers Solo 2025-01-05 17:44:51 +02:00
parent 603d0646bf
commit 1c01feee27
7 changed files with 3 additions and 86 deletions

View File

@ -309,7 +309,6 @@ pub enum Screen {
Splash,
Loading,
Title,
Credits,
Gameplay,
Victory,
Leaderboard,

View File

@ -103,9 +103,6 @@ fn spawn_camera(mut commands: Commands) {
}
fn load_background(mut commands: Commands) {
#[cfg(feature = "dev")]
let colorcheme = rose_pine::RosePine::Base;
#[cfg(not(feature = "dev"))]
let colorcheme = rose_pine::RosePineDawn::Base;
commands.insert_resource(ClearColor(colorcheme.to_color()));
}

View File

@ -222,6 +222,7 @@ impl From<LogicalDirection> for EdgeDirection {
direction.rotate_cw(0)
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -1,71 +0,0 @@
//! A credits screen that can be accessed from the title screen.
use bevy::prelude::*;
use crate::{asset_tracking::LoadResource, audio::Music, screens::Screen, theme::prelude::*};
pub(super) fn plugin(app: &mut App) {
app.add_systems(OnEnter(Screen::Credits), spawn_credits_screen);
app.load_resource::<CreditsMusic>();
app.add_systems(OnEnter(Screen::Credits), play_credits_music);
app.add_systems(OnExit(Screen::Credits), stop_music);
}
fn spawn_credits_screen(mut commands: Commands) {
commands
.ui_root()
.insert(StateScoped(Screen::Credits))
.with_children(|children| {
children.header("Made by");
children.label("Joe Shmoe - Implemented aligator wrestling AI");
children.label("Jane Doe - Made the music for the alien invasion");
children.header("Assets");
children.label("Bevy logo - All rights reserved by the Bevy Foundation. Permission granted for splash screen use when unmodified.");
children.label("Ducky sprite - CC0 by Caz Creates Games");
children.label("Button SFX - CC0 by Jaszunio15");
children.label("Music - CC BY 3.0 by Kevin MacLeod");
children.button("Back").observe(enter_title_screen);
});
}
fn enter_title_screen(_trigger: Trigger<OnPress>, mut next_screen: ResMut<NextState<Screen>>) {
next_screen.set(Screen::Title);
}
#[derive(Resource, Asset, Reflect, Clone)]
pub struct CreditsMusic {
#[dependency]
music: Handle<AudioSource>,
entity: Option<Entity>,
}
impl FromWorld for CreditsMusic {
fn from_world(world: &mut World) -> Self {
let assets = world.resource::<AssetServer>();
Self {
music: assets.load("audio/music/Monkeys Spinning Monkeys.ogg"),
entity: None,
}
}
}
fn play_credits_music(mut commands: Commands, mut music: ResMut<CreditsMusic>) {
music.entity = Some(
commands
.spawn((
AudioPlayer::<AudioSource>(music.music.clone()),
PlaybackSettings::LOOP,
Music,
))
.id(),
);
}
fn stop_music(mut commands: Commands, mut music: ResMut<CreditsMusic>) {
if let Some(entity) = music.entity.take() {
commands.entity(entity).despawn_recursive();
}
}

View File

@ -4,7 +4,7 @@
use bevy::prelude::*;
use crate::{
screens::{credits::CreditsMusic, gameplay::GameplayMusic, Screen},
screens::{gameplay::GameplayMusic, Screen},
theme::{interaction::InteractionAssets, prelude::*},
};
@ -35,8 +35,7 @@ fn continue_to_title_screen(mut next_screen: ResMut<NextState<Screen>>) {
const fn all_assets_loaded(
interaction_assets: Option<Res<InteractionAssets>>,
credits_music: Option<Res<CreditsMusic>>,
gameplay_music: Option<Res<GameplayMusic>>,
) -> bool {
interaction_assets.is_some() && credits_music.is_some() && gameplay_music.is_some()
interaction_assets.is_some() && gameplay_music.is_some()
}

View File

@ -1,6 +1,5 @@
//! The game's main screen states and transitions between them.
mod credits;
mod gameplay;
mod loading;
mod splash;
@ -13,7 +12,6 @@ pub(super) fn plugin(app: &mut App) {
app.enable_state_scoped_entities::<Screen>();
app.add_plugins((
credits::plugin,
gameplay::plugin,
loading::plugin,
splash::plugin,
@ -29,6 +27,5 @@ pub enum Screen {
#[cfg_attr(feature = "dev", default)]
Loading,
Title,
Credits,
Gameplay,
}

View File

@ -14,7 +14,6 @@ fn spawn_title_screen(mut commands: Commands) {
.insert(StateScoped(Screen::Title))
.with_children(|children| {
children.button("Play").observe(enter_gameplay_screen);
children.button("Credits").observe(enter_credits_screen);
#[cfg(not(target_family = "wasm"))]
children.button("Exit").observe(exit_app);
@ -25,10 +24,6 @@ fn enter_gameplay_screen(_trigger: Trigger<OnPress>, mut next_screen: ResMut<Nex
next_screen.set(Screen::Gameplay);
}
fn enter_credits_screen(_trigger: Trigger<OnPress>, mut next_screen: ResMut<NextState<Screen>>) {
next_screen.set(Screen::Credits);
}
#[cfg(not(target_family = "wasm"))]
fn exit_app(_trigger: Trigger<OnPress>, mut app_exit: EventWriter<AppExit>) {
app_exit.send(AppExit::Success);