Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to bevy 0.9 #288

Merged
merged 3 commits into from
Jan 2, 2023
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,439 changes: 825 additions & 614 deletions Cargo.lock

Large diffs are not rendered by default.

85 changes: 39 additions & 46 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,70 +1,63 @@
[package]
name = "punchy"
version = "0.1.0"
authors = ["The Fish Folk Game & Spicy Lobster Developers"]
description = "A 2.5D side-scroller beatemup"
authors = ["The Fish Folk Game & Spicy Lobster Developers"]
license = "MIT OR Apache-2.0"
edition = "2021"
edition = "2021"
license = "MIT OR Apache-2.0"
name = "punchy"
version = "0.1.0"

[workspace]
members = [
".",
"macros"
]
members = [".", "macros"]

[dependencies.bevy]
version = "0.8"
default-features = false
features = [
"x11",
"png",
"filesystem_watcher",
"bevy_gilrs"
]
features = ["x11", "png", "filesystem_watcher", "bevy_gilrs"]
version = "0.9"

[dependencies]
punchy_macros = { path = "./macros" }

anyhow = "1.0.58"
bevy-parallax = "0.2.0"
bevy_egui = "0.15.0"
egui_extras = "0.18.0"
bevy_kira_audio = { version = "0.11.0", features = ["mp3"] }
bevy_rapier2d = { version = "0.16.0", features = ["debug-render"] }
iyes_loopless = { version = "0.8.0", features = ["states"] }
serde = { version = "1.0.137", features = ["derive"] }
serde_yaml = "0.9.2"
thiserror = "1.0.31"
structopt = "0.3.26"
rand = "0.8.5"
getrandom = { version = "0.2", features = ["js"] }
anyhow = "1.0.58"
bevy-parallax = "0.3.0"
bevy_egui = "0.18.0"
bevy_kira_audio = { version = "0.13.0", features = ["mp3"] }
bevy_rapier2d = { version = "0.19.0", features = ["debug-render"] }
egui_extras = "0.20.0"
getrandom = { version = "0.2", features = ["js"] }
iyes_loopless = { version = "0.9.0", features = ["states"] }
rand = "0.8.5"
serde = { version = "1.0.137", features = ["derive"] }
serde_yaml = "0.9.2"
structopt = "0.3.26"
thiserror = "1.0.31"
Comment on lines +20 to +32
Copy link
Member

@zicklag zicklag Jan 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, how did you format this file?

I think I kind of like it, if there's an automatic way to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh i apologize. that is my vs-code extensions Even Better Toml auto formatting my toml for me. I forget to disable it on other projects since some people hate formatters being run on their code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If @odecay doesn't have a problem with it, I'm fine, it's no problem.

I was just curious what you used to format it, because I might want to use it. :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with it for now, if it becomes a problem to maintain formatting without that specific formatter in the future we can always change it back.


leafwing-input-manager = { version = "0.6", default-features = false }
unic-langid = "0.9.0"
bevy_fluent = "0.4.0"
sys-locale = "0.2.1"
fluent = "0.16.0"
directories = "4.0.1"
async-channel = "1.6.1"
once_cell = "1.13.0"
bevy_mod_js_scripting = { git = "https://github.com/jakobhellermann/bevy_mod_js_scripting.git" }
async-channel = "1.6.1"
bevy_fluent = "0.5.0"
bevy_mod_js_scripting = { git = "https://github.com/jakobhellermann/bevy_mod_js_scripting.git" }
directories = "4.0.1"
fluent = "0.16.0"
fluent_content = "0.0.3"
leafwing-input-manager = { version = "0.7", default-features = false }
once_cell = "1.13.0"
sys-locale = "0.2.1"
unic-langid = "0.9.0"

# Debug tools
bevy-inspector-egui = { version = "0.12.1" }
bevy-inspector-egui-rapier = { version = "0.5.0", features = ["rapier2d"] }
bevy_mod_debugdump = { version = "0.5.0", optional = true }
bevy-inspector-egui = { version = "0.15.0" }
bevy-inspector-egui-rapier = { version = "0.9.0", features = ["rapier2d"] }
bevy_mod_debugdump = { version = "0.6.0", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "0.3", features = ["Window","Location","Storage"] }
web-sys = { version = "0.3", features = ["Window", "Location", "Storage"] }

[features]
default = []
default = []
schedule_graph = ["bevy_mod_debugdump"]

# Enable optimizations for dependencies but not for our code
[profile.dev.package."*"]
debug = false
opt-level = 3
debug = false

[profile.dev]
# As of Jul/2022, opt-level=1 takes a considerable compilation time; with such configuration,
Expand All @@ -76,5 +69,5 @@ debug = false
# slower than opt-level=0.

[profile.release]
lto = true
codegen-units = 1 # Improves physics performance for release builds
codegen-units = 1 # Improves physics performance for release builds
lto = true
8 changes: 6 additions & 2 deletions src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Animation {
animations,
current_frame: 0,
current_animation: None,
timer: Timer::from_seconds(fps, false),
timer: Timer::from_seconds(fps, TimerMode::Once),
played_once: false,
}
}
Expand All @@ -132,7 +132,11 @@ impl Animation {
self.current_frame = 0;
self.timer.reset();
self.timer.unpause();
self.timer.set_repeating(repeating);
self.timer.set_mode(if repeating {
TimerMode::Repeating
} else {
TimerMode::Once
});
self.played_once = false;
}

Expand Down
17 changes: 17 additions & 0 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ impl AssetLoader for FighterLoader {
meta.spritesheet.tile_size.as_vec2(),
meta.spritesheet.columns,
meta.spritesheet.rows,
None,
None,
))
.with_dependency(texture_path),
);
Expand All @@ -331,6 +333,8 @@ impl AssetLoader for FighterLoader {
attachment.tile_size.as_vec2(),
attachment.columns,
attachment.rows,
None,
None,
))
.with_dependency(texture_path),
);
Expand Down Expand Up @@ -420,6 +424,8 @@ impl AssetLoader for ItemLoader {
spritesheet.tile_size.as_vec2(),
spritesheet.columns,
spritesheet.rows,
None,
None,
))
.with_dependency(texture_path),
);
Expand Down Expand Up @@ -447,6 +453,8 @@ impl AssetLoader for ItemLoader {
spritesheet.tile_size.as_vec2(),
spritesheet.columns,
spritesheet.rows,
None,
None,
))
.with_dependency(texture_path),
);
Expand Down Expand Up @@ -494,3 +502,12 @@ impl AssetLoader for EguiFontLoader {
&["ttf"]
}
}

#[derive(Debug, Clone, Resource, Deref, DerefMut)]
pub struct EguiFontDefinitions(pub egui::FontDefinitions);

impl EguiFontDefinitions {
pub fn get_fonts(&self) -> &egui::FontDefinitions {
&self.0
}
}
2 changes: 1 addition & 1 deletion src/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fn attack_damage_system(
commands
.entity(hurtbox_parent_entity)
.insert(FlashingTimer {
timer: Timer::new(Duration::from_millis(100), true),
timer: Timer::new(Duration::from_millis(100), TimerMode::Repeating),
});

event_writer.send(DamageEvent {
Expand Down
8 changes: 5 additions & 3 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ use rand::{prelude::SliceRandom, thread_rng};

use bevy::{prelude::*, utils::HashMap};
use bevy_egui::{egui::output::OutputEvent, EguiContext};
use bevy_kira_audio::{AudioApp, AudioChannel, AudioSource};
use bevy_kira_audio::{AudioApp, AudioChannel, AudioControl, AudioSource};
use iyes_loopless::prelude::*;

use crate::{
animation::Animation,
config::ENGINE_CONFIG,
metadata::{GameMeta, LevelMeta},
metadata::{GameMeta, LevelHandle, LevelMeta},
GameState,
};

/// For readability.
const IMPOSSIBLE_ANIMATION_I: usize = usize::MAX;

#[derive(Resource)]
pub struct MusicChannel;

#[derive(Resource)]
pub struct EffectsChannel;

pub fn set_audio_channels_volume(
Expand Down Expand Up @@ -137,7 +139,7 @@ pub fn stop_menu_music(music_channel: Res<AudioChannel<MusicChannel>>) {
}

pub fn play_level_music(
level_handle: Res<Handle<LevelMeta>>,
level_handle: Res<LevelHandle>,
assets: Res<Assets<LevelMeta>>,
music_channel: Res<AudioChannel<MusicChannel>>,
) {
Expand Down
14 changes: 7 additions & 7 deletions src/collision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ impl BodyLayers {
// The layer is represented by 1 shifted 0 places to the left: 0b0001.
// The second layer is represented by 1 shifted one place to the left: 0b0010.
// And so on for the rest of the layers.
pub const ENEMY: u32 = 1 << 0;
pub const PLAYER: u32 = 1 << 1;
pub const PLAYER_ATTACK: u32 = 1 << 2;
pub const ENEMY_ATTACK: u32 = 1 << 3;
pub const BREAKABLE_ITEM: u32 = 1 << 4;
pub const ENEMY: Group = Group::GROUP_1;
pub const PLAYER: Group = Group::GROUP_2;
pub const PLAYER_ATTACK: Group = Group::GROUP_3;
pub const ENEMY_ATTACK: Group = Group::GROUP_4;
pub const BREAKABLE_ITEM: Group = Group::GROUP_5;
// u32::MAX is a u32 with all of it's bits set to 1, so this will contain all of the layers.
pub const ALL: u32 = u32::MAX;
pub const ALL: Group = Group::ALL;
}

#[derive(Bundle)]
Expand All @@ -32,7 +32,7 @@ pub struct PhysicsBundle {
}

impl PhysicsBundle {
pub fn new(meta: &ColliderMeta, body_layers: u32) -> Self {
pub fn new(meta: &ColliderMeta, body_layers: Group) -> Self {
PhysicsBundle {
collider: (Collider::cuboid(meta.size.x / 2., meta.size.y / 2.)),
sensor: Sensor,
Expand Down
20 changes: 11 additions & 9 deletions src/fighter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,22 @@ impl ActiveFighterBundle {
},
};
let hurtbox = commands
.spawn_bundle(PhysicsBundle::new(&fighter.hurtbox, body_layers))
.insert_bundle(TransformBundle::from_transform(Transform::from_xyz(
0.0,
fighter.collision_offset,
0.0,
)))
.insert(Hurtbox)
.spawn((
PhysicsBundle::new(&fighter.hurtbox, body_layers),
TransformBundle::from_transform(Transform::from_xyz(
0.0,
fighter.collision_offset,
0.0,
)),
Hurtbox,
))
.id();

let animated_spritesheet_bundle = active_fighter_bundle.animated_spritesheet_bundle.clone();

commands
.entity(entity)
.insert_bundle(active_fighter_bundle)
.insert(active_fighter_bundle)
.push_children(&[hurtbox]);

if let Some(attachment) = &fighter.attachment {
Expand All @@ -179,7 +181,7 @@ impl ActiveFighterBundle {
attachment_spritesheet.sprite_sheet.sprite.anchor = bevy::sprite::Anchor::Center;

let attachment_ent = commands
.spawn_bundle(attachment_spritesheet)
.spawn(attachment_spritesheet)
.insert(Attached {
position_face: false,
sync_animation: true,
Expand Down
Loading