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
Binary file added art/banner.aseprite
Binary file not shown.
Binary file added art/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/cover.aseprite
Binary file not shown.
Binary file added art/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified art/fonts.aseprite
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file modified assets/font.ttf
Binary file not shown.
191 changes: 191 additions & 0 deletions src/screens/credits.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
use bevy::{prelude::*, text::FontSmoothing};
use leafwing_input_manager::prelude::ActionState;

use crate::{PIXEL_PERFECT_LAYERS, ScaleFactor, input::Action, screens::Screen};

pub(super) fn plugin(app: &mut App) {
app.add_systems(OnEnter(Screen::Credits), spawn_credits);
app.add_systems(
Update,
(credits_input, credits_button).run_if(in_state(Screen::Credits)),
);
}

fn spawn_credits(
mut commands: Commands,
scale_factor: Res<ScaleFactor>,
asset_server: Res<AssetServer>,
) {
let scale = scale_factor.0;
let font_handle = asset_server.load("font.ttf");
commands.spawn((
Name::new("Credits container"),
Node {
width: Val::Percent(80.0),
height: Val::Percent(80.0),
margin: UiRect::all(Val::Auto),
padding: UiRect::all(Val::Px(8.0 * scale)),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
flex_direction: FlexDirection::Column,
..default()
},
DespawnOnExit(Screen::Credits),
PIXEL_PERFECT_LAYERS,
children![
(
Name::new("Credits"),
Text::new("CREDITS"),
TextFont {
font_size: 16.0 * scale,
font: font_handle.clone(),
font_smoothing: FontSmoothing::None,
..default()
},
Node {
position_type: PositionType::Absolute,
top: Val::Px(0.0),
margin: UiRect {
left: Val::Auto,
right: Val::Auto,
..default()
},
..default()
}
),
(
Text::new("MADE WITH LOVE AND BEVY FOR LDG GAME JAM 3"),
TextFont {
font_size: 12.0 * scale,
font: font_handle.clone(),
font_smoothing: FontSmoothing::None,
..default()
},
Node {
padding: UiRect {
top: Val::Px(8.0 * scale),
bottom: Val::Px(8.0 * scale),
..default()
},
..default()
},
),
(
Name::new("TITLE THEME"),
Text::new("TITLE THEME - OPENGAMEART.ORG SPACE-THEME"),
TextFont {
font_size: 8.0 * scale,
font: font_handle.clone(),
font_smoothing: FontSmoothing::None,
..default()
},
Node {
padding: UiRect {
top: Val::Px(8.0 * scale),
bottom: Val::Px(8.0 * scale),
..default()
},
..default()
},
),
(
Name::new("LEVEL THEME"),
Text::new("LEVEL THEME - OPENGAMEART.ORG THROUGH-SPACE"),
TextFont {
font_size: 8.0 * scale,
font: font_handle.clone(),
font_smoothing: FontSmoothing::None,
..default()
},
Node {
padding: UiRect {
top: Val::Px(8.0 * scale),
bottom: Val::Px(8.0 * scale),
..default()
},
..default()
},
),
(
Name::new("SFX"),
Text::new("SFX - OPENGAMEART.ORG 512-SOUND-EFFECTS-8-BIT-STYLE"),
TextFont {
font_size: 8.0 * scale,
font: font_handle.clone(),
font_smoothing: FontSmoothing::None,
..default()
},
Node {
padding: UiRect {
top: Val::Px(8.0 * scale),
bottom: Val::Px(8.0 * scale),
..default()
},
..default()
},
),
(
Name::new("EVERYTHING ELSE"),
Text::new("EVERYTHING ELSE - JODA"),
TextFont {
font_size: 8.0 * scale,
font: font_handle.clone(),
font_smoothing: FontSmoothing::None,
..default()
},
Node {
padding: UiRect {
top: Val::Px(8.0 * scale),
bottom: Val::Px(8.0 * scale),
..default()
},
..default()
},
),
(
Name::new("Back to menu button"),
Button,
Node {
position_type: PositionType::Absolute,
bottom: Val::Px(0.0),
margin: UiRect {
left: Val::Auto,
right: Val::Auto,
..default()
},
..default()
},
children![(
Name::new("Back to menu text"),
Text::new("BACK TO MENU"),
TextFont {
font_size: 16.0 * scale,
font: font_handle.clone(),
font_smoothing: FontSmoothing::None,
..default()
}
)]
),
],
));
}

fn credits_button(
interaction_query: Query<&Interaction, Changed<Interaction>>,
mut screen: ResMut<NextState<Screen>>,
) {
for interaction in interaction_query.iter() {
if *interaction == Interaction::Pressed {
screen.set(Screen::Title)
}
}
}

fn credits_input(
action_state: Single<&ActionState<Action>>,
mut screen: ResMut<NextState<Screen>>,
) {
if action_state.just_pressed(&Action::Select) {
screen.set(Screen::Title);
}
}
3 changes: 3 additions & 0 deletions src/screens/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bevy::prelude::*;

mod credits;
mod game;
mod gameover;
mod pause;
Expand All @@ -13,6 +14,7 @@ pub(super) fn plugin(app: &mut App) {
splash::plugin,
title::plugin,
game::plugin,
credits::plugin,
pause::plugin,
gameover::plugin,
));
Expand All @@ -24,4 +26,5 @@ pub enum Screen {
Splash,
Title,
Game,
Credits,
}
35 changes: 21 additions & 14 deletions src/screens/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(super) fn plugin(app: &mut App) {
enum MenuButton {
NewGame,
// Settings,
Credits,
#[cfg(not(target_arch = "wasm32"))]
Quit,
}
Expand Down Expand Up @@ -81,13 +82,20 @@ fn spawn_title_screen(
// font_handle.clone(),
// scale,
// );
let credits = title_menu_button(
"CREDITS",
1,
MenuButton::Credits,
font_handle.clone(),
scale,
);

#[cfg(target_arch = "wasm32")]
let menu_buttons = children![new_game];
let menu_buttons = children![new_game, credits];
#[cfg(not(target_arch = "wasm32"))]
let quit = title_menu_button("QUIT", 1, MenuButton::Quit, font_handle.clone(), scale);
let quit = title_menu_button("QUIT", 2, MenuButton::Quit, font_handle.clone(), scale);
#[cfg(not(target_arch = "wasm32"))]
let menu_buttons = children![new_game, quit];
let menu_buttons = children![new_game, credits, quit];

commands.spawn((
Node {
Expand Down Expand Up @@ -125,9 +133,9 @@ fn input_system(
let action_state = input_query.single().unwrap();

#[cfg(not(target_arch = "wasm32"))]
let max_index = 1;
let max_index = 2;
#[cfg(target_arch = "wasm32")]
let max_index = 0;
let max_index = 1;

if action_state.just_pressed(&Action::Up) {
if active_index.0 == 0 {
Expand Down Expand Up @@ -159,6 +167,9 @@ fn input_system(
screen_state.set(Screen::Game);
}
1 => {
screen_state.set(Screen::Credits);
}
2 => {
message_writer.write(AppExit::Success);
}
_ => {}
Expand All @@ -176,12 +187,11 @@ fn button_system(
for (interaction, menu_button, children) in interaction_query {
match *interaction {
Interaction::Pressed => match menu_button {
MenuButton::NewGame => {
screen_state.set(Screen::Game);
}
MenuButton::NewGame => screen_state.set(Screen::Game),
// MenuButton::Settings => {
// println!("Settings button pressed");
// }
MenuButton::Credits => screen_state.set(Screen::Credits),
#[cfg(not(target_arch = "wasm32"))]
MenuButton::Quit => {
message_writer.write(AppExit::Success);
Expand All @@ -192,16 +202,13 @@ fn button_system(
.entity(*children.first().unwrap())
.insert(TextColor(WHITE));
match menu_button {
MenuButton::NewGame => {
active_index.0 = 0;
}
MenuButton::NewGame => active_index.0 = 0,
MenuButton::Credits => active_index.0 = 1,
// MenuButton::Settings => {
// active_index.0 = 1;
// }
#[cfg(not(target_arch = "wasm32"))]
MenuButton::Quit => {
active_index.0 = 1;
}
MenuButton::Quit => active_index.0 = 2,
}
}
Interaction::None => {
Expand Down