mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
chore(screen): delete Credits screen
This commit is contained in:
parent
603d0646bf
commit
1c01feee27
@ -309,7 +309,6 @@ pub enum Screen {
|
|||||||
Splash,
|
Splash,
|
||||||
Loading,
|
Loading,
|
||||||
Title,
|
Title,
|
||||||
Credits,
|
|
||||||
Gameplay,
|
Gameplay,
|
||||||
Victory,
|
Victory,
|
||||||
Leaderboard,
|
Leaderboard,
|
||||||
|
|||||||
@ -103,9 +103,6 @@ fn spawn_camera(mut commands: Commands) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn load_background(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;
|
let colorcheme = rose_pine::RosePineDawn::Base;
|
||||||
commands.insert_resource(ClearColor(colorcheme.to_color()));
|
commands.insert_resource(ClearColor(colorcheme.to_color()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -222,6 +222,7 @@ impl From<LogicalDirection> for EdgeDirection {
|
|||||||
direction.rotate_cw(0)
|
direction.rotate_cw(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -4,7 +4,7 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
screens::{credits::CreditsMusic, gameplay::GameplayMusic, Screen},
|
screens::{gameplay::GameplayMusic, Screen},
|
||||||
theme::{interaction::InteractionAssets, prelude::*},
|
theme::{interaction::InteractionAssets, prelude::*},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,8 +35,7 @@ fn continue_to_title_screen(mut next_screen: ResMut<NextState<Screen>>) {
|
|||||||
|
|
||||||
const fn all_assets_loaded(
|
const fn all_assets_loaded(
|
||||||
interaction_assets: Option<Res<InteractionAssets>>,
|
interaction_assets: Option<Res<InteractionAssets>>,
|
||||||
credits_music: Option<Res<CreditsMusic>>,
|
|
||||||
gameplay_music: Option<Res<GameplayMusic>>,
|
gameplay_music: Option<Res<GameplayMusic>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
interaction_assets.is_some() && credits_music.is_some() && gameplay_music.is_some()
|
interaction_assets.is_some() && gameplay_music.is_some()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
//! The game's main screen states and transitions between them.
|
//! The game's main screen states and transitions between them.
|
||||||
|
|
||||||
mod credits;
|
|
||||||
mod gameplay;
|
mod gameplay;
|
||||||
mod loading;
|
mod loading;
|
||||||
mod splash;
|
mod splash;
|
||||||
@ -13,7 +12,6 @@ pub(super) fn plugin(app: &mut App) {
|
|||||||
app.enable_state_scoped_entities::<Screen>();
|
app.enable_state_scoped_entities::<Screen>();
|
||||||
|
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
credits::plugin,
|
|
||||||
gameplay::plugin,
|
gameplay::plugin,
|
||||||
loading::plugin,
|
loading::plugin,
|
||||||
splash::plugin,
|
splash::plugin,
|
||||||
@ -29,6 +27,5 @@ pub enum Screen {
|
|||||||
#[cfg_attr(feature = "dev", default)]
|
#[cfg_attr(feature = "dev", default)]
|
||||||
Loading,
|
Loading,
|
||||||
Title,
|
Title,
|
||||||
Credits,
|
|
||||||
Gameplay,
|
Gameplay,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,6 @@ fn spawn_title_screen(mut commands: Commands) {
|
|||||||
.insert(StateScoped(Screen::Title))
|
.insert(StateScoped(Screen::Title))
|
||||||
.with_children(|children| {
|
.with_children(|children| {
|
||||||
children.button("Play").observe(enter_gameplay_screen);
|
children.button("Play").observe(enter_gameplay_screen);
|
||||||
children.button("Credits").observe(enter_credits_screen);
|
|
||||||
|
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
children.button("Exit").observe(exit_app);
|
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);
|
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"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
fn exit_app(_trigger: Trigger<OnPress>, mut app_exit: EventWriter<AppExit>) {
|
fn exit_app(_trigger: Trigger<OnPress>, mut app_exit: EventWriter<AppExit>) {
|
||||||
app_exit.send(AppExit::Success);
|
app_exit.send(AppExit::Success);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user