Skip to content

Commit

Permalink
fix spawning out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
stillonearth committed Dec 27, 2023
1 parent d160305 commit 9785047
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
14 changes: 10 additions & 4 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ pub fn event_spawn_mierda(
let mut offset_position = Vec3::new(0.0, 0.0, 0.);
let mut mierda_position = player_translation + offset_position;

while (player_translation - mierda_position).length() < 50.0 {
while (player_translation - mierda_position).length() < 50.0
|| mierda_position.x < 0.0 + 24.0
|| mierda_position.x > (level.px_wid as f32) - 24.0
|| mierda_position.y < 0.0 + 24.0
|| mierda_position.y > (level.px_hei as f32) - 24.0
{
let x = rng.gen_range(-100.0..100.0);
let y = rng.gen_range(-100.0..100.0);

Expand Down Expand Up @@ -200,7 +205,7 @@ pub fn event_mierda_hit(
asyn!(state, mut commands: Commands, asset_server: Res<AssetServer>, q_mierdas: Query<(Entity, &GlobalTransform)> => {

let mierda_transform = q_mierdas.get(state.value).unwrap().1.clone();

commands.spawn((
ParticleSystemBundle {
transform: (mierda_transform).into(),
Expand All @@ -222,6 +227,9 @@ pub fn event_mierda_hit(
looping: false,
..ParticleSystem::default()
},



..default()
},
Playing,
Expand Down Expand Up @@ -323,6 +331,4 @@ pub fn event_on_pizza_step_over(
commands.entity(e_pizza).despawn_recursive();
}
}


}
20 changes: 1 addition & 19 deletions src/ldtk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,6 @@ impl LdtkEntity for PlayerBundle {
collider_bundle,
active_events: ActiveEvents::COLLISION_EVENTS,
player: Player { health: 100 },
// particle_system_bundle: ParticleSystemBundle {
// particle_system: ParticleSystem {
// max_particles: 10_000,
// texture: ParticleTexture::Sprite(asset_server.load("my_particle.png")),
// spawn_rate_per_second: 25.0.into(),
// initial_speed: JitteredValue::jittered(3.0, -1.0..1.0),
// lifetime: JitteredValue::jittered(8.0, -2.0..2.0),
// color: ColorOverTime::Gradient(Curve::new(vec![
// CurvePoint::new(Color::PURPLE, 0.0),
// CurvePoint::new(Color::RED, 0.5),
// CurvePoint::new(Color::rgba(0.0, 0.0, 1.0, 0.0), 1.0),
// ])),
// looping: true,
// system_duration_seconds: 10.0,
// ..ParticleSystem::default()
// },
// ..ParticleSystemBundle::default()
// },
}
}
}
Expand All @@ -342,7 +324,7 @@ impl LdtkEntity for MierdaBundle {

impl LdtkEntity for PizzaBundle {
fn bundle_entity(
entity_instance: &EntityInstance,
_entity_instance: &EntityInstance,
_layer_instance: &LayerInstance,
_: Option<&Handle<Image>>,
_: Option<&TilesetDefinition>,
Expand Down

0 comments on commit 9785047

Please sign in to comment.