|
|
|
@ -2,6 +2,7 @@
|
|
|
|
#![allow(clippy::type_complexity)]
|
|
|
|
#![allow(clippy::type_complexity)]
|
|
|
|
|
|
|
|
|
|
|
|
use bevy::audio::PlaybackMode;
|
|
|
|
use bevy::audio::PlaybackMode;
|
|
|
|
|
|
|
|
use bevy::image::{ImageLoaderSettings, ImageSampler};
|
|
|
|
use bevy::render::view::ColorGrading;
|
|
|
|
use bevy::render::view::ColorGrading;
|
|
|
|
use games::physics2d::*;
|
|
|
|
use games::physics2d::*;
|
|
|
|
use games::*;
|
|
|
|
use games::*;
|
|
|
|
@ -417,7 +418,7 @@ struct RewindSfx;
|
|
|
|
#[derive(Component)]
|
|
|
|
#[derive(Component)]
|
|
|
|
struct RewindButton;
|
|
|
|
struct RewindButton;
|
|
|
|
|
|
|
|
|
|
|
|
fn init_ui(mut commands: Commands) {
|
|
|
|
fn init_ui(mut commands: Commands, mut server: ResMut<AssetServer>) {
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
@ -550,6 +551,14 @@ fn init_ui(mut commands: Commands) {
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
|
|
|
|
let rewind_image = server.load_with_settings(
|
|
|
|
|
|
|
|
"flappy/rewind.png",
|
|
|
|
|
|
|
|
|settings: &mut ImageLoaderSettings| {
|
|
|
|
|
|
|
|
// Need to use nearest filtering to avoid bleeding between the slices with tiling
|
|
|
|
|
|
|
|
settings.sampler = ImageSampler::nearest();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
parent
|
|
|
|
parent
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
@ -562,13 +571,27 @@ fn init_ui(mut commands: Commands) {
|
|
|
|
BackgroundColor::default(),
|
|
|
|
BackgroundColor::default(),
|
|
|
|
RewindButton,
|
|
|
|
RewindButton,
|
|
|
|
children![
|
|
|
|
children![
|
|
|
|
Text::new("Rewind! (R)"),
|
|
|
|
(
|
|
|
|
TextLayout::new_with_justify(JustifyText::Center)
|
|
|
|
ImageNode { color: BLACK.into(), image: rewind_image, ..default() },
|
|
|
|
|
|
|
|
Node { height: Val::Px(50.0), ..default() },
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
Text::new("Rewind! (R)"),
|
|
|
|
|
|
|
|
TextFont::from_font_size(30.0),
|
|
|
|
|
|
|
|
TextLayout::new_with_justify(JustifyText::Center)
|
|
|
|
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.observe(start_rewind)
|
|
|
|
.observe(start_rewind)
|
|
|
|
.observe(end_rewind);
|
|
|
|
.observe(end_rewind);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let play_image = server.load_with_settings(
|
|
|
|
|
|
|
|
"flappy/play.png",
|
|
|
|
|
|
|
|
|settings: &mut ImageLoaderSettings| {
|
|
|
|
|
|
|
|
// Need to use nearest filtering to avoid bleeding between the slices with tiling
|
|
|
|
|
|
|
|
settings.sampler = ImageSampler::nearest();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
parent
|
|
|
|
parent
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
@ -580,9 +603,15 @@ fn init_ui(mut commands: Commands) {
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
|
FlapButton,
|
|
|
|
FlapButton,
|
|
|
|
children![
|
|
|
|
children![
|
|
|
|
Text::new("Flap! (Spacebar)"),
|
|
|
|
(
|
|
|
|
TextFont::from_font_size(30.0),
|
|
|
|
Text::new("Flap! (Spacebar)"),
|
|
|
|
TextLayout::new_with_justify(JustifyText::Center)
|
|
|
|
TextFont::from_font_size(30.0),
|
|
|
|
|
|
|
|
TextLayout::new_with_justify(JustifyText::Center)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
ImageNode { color: BLACK.into(), image: play_image, ..default() },
|
|
|
|
|
|
|
|
Node { height: Val::Px(50.0), ..default() },
|
|
|
|
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.observe(flap_button);
|
|
|
|
.observe(flap_button);
|
|
|
|
|