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
4 changes: 4 additions & 0 deletions assets/player/skins/catty/catty.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ sounds:
drop: ../../sounds/drop.ogg
drop_volume: 0.05

movement:
air_move_speed: 7
slow_fall_speed: 1.5

spritesheet:
image: catty.png
tile_size: [96, 80]
Expand Down
4 changes: 4 additions & 0 deletions assets/player/skins/fishy/fishy.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ sounds:
drop: ../../sounds/drop.ogg
drop_volume: 0.05

movement:
air_move_speed: 7
slow_fall_speed: 1.5

spritesheet:
image: fishy.png
tile_size: [96, 80]
Expand Down
4 changes: 4 additions & 0 deletions assets/player/skins/lionfishy/lionfishy.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ sounds:
drop: ../../sounds/drop.ogg
drop_volume: 0.05

movement:
air_move_speed: 7
slow_fall_speed: 1.5

spritesheet:
image: lionfishy.png
tile_size: [96, 80]
Expand Down
4 changes: 4 additions & 0 deletions assets/player/skins/orcy/orcy.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ sounds:
drop: ../../sounds/drop.ogg
drop_volume: 0.05

movement:
air_move_speed: 7
slow_fall_speed: 1.5

spritesheet:
image: orcy.png
tile_size: [96, 80]
Expand Down
4 changes: 4 additions & 0 deletions assets/player/skins/pescy/pescy.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ sounds:
drop: ../../sounds/drop.ogg
drop_volume: 0.05

movement:
air_move_speed: 7
slow_fall_speed: 1.5

spritesheet:
image: pescy.png
tile_size: [96, 80]
Expand Down
4 changes: 4 additions & 0 deletions assets/player/skins/sharky/sharky.player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ sounds:
drop: ../../sounds/drop.ogg
drop_volume: 0.05

movement:
air_move_speed: 7
slow_fall_speed: 1.5

spritesheet:
image: sharky.png
tile_size: [96, 80]
Expand Down
15 changes: 0 additions & 15 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ pub struct EngineConfig {
#[arg(default_value = "default.game.yaml")]
pub game_asset: String,

/// Skip the menu and automatically start the game
#[arg(short = 's', long)]
pub auto_start: bool,

/// Enable the debug tools which can be accessed by pressing F12
#[arg(short = 'd', long)]
pub debug_tools: bool,

/// Set the log level
///
/// May additionally specify log levels for specific modules as a comma-separated list of
Expand Down Expand Up @@ -72,12 +64,6 @@ impl EngineConfig {
config.auto_start = auto_start;
}

if let Some(debug_tools) =
parse_url_query_string(&query, "debug_tools").and_then(|s| s.parse().ok())
{
config.debug_tools = debug_tools;
}

if let Some(log_level) = parse_url_query_string(&query, "log_level") {
config.log_level = log_level.into();
}
Expand All @@ -98,7 +84,6 @@ impl EngineConfig {
hot_reload: false,
asset_dir: None,
game_asset: "default.game.yaml".into(),
auto_start: false,
debug_tools: false,
log_level: DEFAULT_LOG_LEVEL.into(),
}
Expand Down
15 changes: 6 additions & 9 deletions src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
use bevy_inspector_egui::{WorldInspectorParams, WorldInspectorPlugin};

use crate::{config::ENGINE_CONFIG, prelude::*};
use crate::prelude::*;

pub struct DebugPlugin;

impl Plugin for DebugPlugin {
fn build(&self, app: &mut App) {
// Add debug plugins if enabled
if ENGINE_CONFIG.debug_tools {
app.insert_resource(WorldInspectorParams {
enabled: false,
..default()
})
.add_plugin(WorldInspectorPlugin::new());
}
app.insert_resource(WorldInspectorParams {
enabled: false,
..default()
})
.add_plugin(WorldInspectorPlugin::new());
}
}
8 changes: 8 additions & 0 deletions src/metadata/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ pub struct PlayerMeta {
pub name: String,
pub spritesheet: PlayerSpritesheetMeta,
pub sounds: PlayerSounds,
pub movement: PlayerMovementMeta,
}

#[derive(Reflect, Deserialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct PlayerMovementMeta {
pub slow_fall_speed: f32,
pub air_move_speed: f32,
}

#[derive(Reflect, Deserialize, Clone, Debug, Default)]
Expand Down
6 changes: 2 additions & 4 deletions src/physics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::math::vec2;

use crate::{config::ENGINE_CONFIG, metadata::GameMeta, prelude::*};
use crate::{metadata::GameMeta, prelude::*};

use self::collisions::{Actor, Collider, CollisionWorld, Rect, TileCollision};

Expand Down Expand Up @@ -44,9 +44,7 @@ impl Plugin for PhysicsPlugin {
);
});

if ENGINE_CONFIG.debug_tools {
app.add_plugin(debug::PhysicsDebugRenderPlugin);
}
app.add_plugin(debug::PhysicsDebugRenderPlugin);
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/player/state/states/midair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use super::*;

pub const ID: &str = "core:midair";

pub const AIR_MOVE_SPEED: f32 = 7.0;

pub fn player_state_transition(
mut players: Query<(&mut PlayerState, &KinematicBody, &Handle<PlayerMeta>)>,
player_inputs: Res<PlayerInputs>,
Expand Down Expand Up @@ -39,12 +37,15 @@ pub fn handle_player_state(
Entity,
&PlayerState,
&PlayerIdx,
&Handle<PlayerMeta>,
&mut AnimationBankSprite,
&mut KinematicBody,
)>,
collision_world: CollisionWorld,
player_assets: Res<Assets<PlayerMeta>>,
) {
for (player_ent, player_state, player_idx, mut sprite, mut body) in &mut players {
for (player_ent, player_state, player_idx, meta_handle, mut sprite, mut body) in &mut players {
let meta = player_assets.get(meta_handle).unwrap();
if player_state.id != ID {
continue;
}
Expand All @@ -57,6 +58,11 @@ pub fn handle_player_state(

let control = &player_inputs.players[player_idx.0].control;

// Limit fall speed if holding jump button
if control.jump_pressed {
body.velocity.y = body.velocity.y.max(-meta.movement.slow_fall_speed);
}

// Check for item in player inventory
let mut has_item = false;
'items: for (item_parent, ..) in &items {
Expand Down Expand Up @@ -100,7 +106,7 @@ pub fn handle_player_state(
}

// Add controls
body.velocity.x = control.move_direction.x * AIR_MOVE_SPEED;
body.velocity.x = control.move_direction.x * meta.movement.air_move_speed;

// Fall through platforms
body.fall_through = control.move_direction.y < -0.5 && control.jump_pressed;
Expand Down
16 changes: 6 additions & 10 deletions src/ui/debug_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ use bevy_egui::*;
use bevy_fluent::Localization;
use bevy_inspector_egui::WorldInspectorParams;

use crate::{
config::ENGINE_CONFIG, localization::LocalizationExt, physics::debug::PhysicsDebugRenderConfig,
};
use crate::{localization::LocalizationExt, physics::debug::PhysicsDebugRenderConfig};

pub struct DebugToolsPlugin;

impl Plugin for DebugToolsPlugin {
fn build(&self, app: &mut App) {
if ENGINE_CONFIG.debug_tools {
app.add_plugin(FrameTimeDiagnosticsPlugin)
// .init_resource::<ShowNetworkVisualizer>()
.init_resource::<ShowFameTimeDiagnostics>()
.add_system(debug_tools_window)
.add_system(frame_diagnostic_window);
}
app.add_plugin(FrameTimeDiagnosticsPlugin)
// .init_resource::<ShowNetworkVisualizer>()
.init_resource::<ShowFameTimeDiagnostics>()
.add_system(debug_tools_window)
.add_system(frame_diagnostic_window);
}
}

Expand Down