Skip to content

Commit

Permalink
added level to loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietrek14 committed Jul 9, 2023
1 parent 57947c6 commit ecbb429
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/ball/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{actions::Actions, hole::Won, loading::AudioAssets, GameState};

use self::ui::BallUiPlugin;

const MAX_BALL_ENERGY: f32 = 500.;
const BALL_FORCE: f32 = 50.;
const MAX_BALL_ENERGY: f32 = 90.;
const BALL_FORCE: f32 = 10.;

mod ui;

Expand Down Expand Up @@ -133,7 +133,7 @@ fn lose_condition(

fn play_knock_sound(
ball_query: Query<Entity, With<Ball>>,
wall_query: Query<(), With<Wall>>,
wall_query: Query<Entity, With<Wall>>,
wall_mesh_query: Query<&Parent, With<Handle<Mesh>>>,
rapier_context: Res<RapierContext>,
audio_assets: Res<AudioAssets>,
Expand All @@ -148,6 +148,7 @@ fn play_knock_sound(
};

// Play the sound only on collision with wall
// Doesn't work :(
if let Ok(parent) = wall_mesh_query.get(other) {
if wall_query.get(parent.get()).is_err() {
continue;
Expand All @@ -161,7 +162,7 @@ fn play_knock_sound(
for manifold in contact_pair.manifolds() {
for contact_point in manifold.points() {
println!("{}", contact_point.impulse().abs());
if contact_point.impulse().abs() > 2. {
if contact_point.impulse().abs() > 0.5 {
audio
.play(audio_assets.knock.clone())
.with_playback_rate(0.9 + rand::thread_rng().gen::<f64>() / 5.);
Expand Down
2 changes: 1 addition & 1 deletion src/loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct TextureAssets {
#[derive(AssetCollection, Resource)]
pub struct ModelAssets {
#[asset(
paths("models/levels/level_1.glb#Scene0"),
paths("models/levels/level_1.glb#Scene0", "models/levels/level_2.glb#Scene0"),
collection(typed)
)]
pub levels: Vec<Handle<Scene>>,
Expand Down

0 comments on commit ecbb429

Please sign in to comment.