Commit d7cf3670 authored by Rahix's avatar Rahix 🦀
Browse files

Only spawn trojan later into a run

parent 0a775f4d
......@@ -4,7 +4,11 @@ use crate::sprites;
use crate::svg_loader;
use rand::seq::SliceRandom;
pub fn create_stationary_obstacles(world: &mut legion::World, level: &svg_loader::SvgLevel) {
pub fn create_stationary_obstacles(
world: &mut legion::World,
level: &svg_loader::SvgLevel,
player: &components::Player,
) {
let spawn_locations_barriers = level
.spawnpoints
.get("stationary_obstacle_type_1")
......@@ -19,17 +23,19 @@ pub fn create_stationary_obstacles(world: &mut legion::World, level: &svg_loader
));
}
let spawn_locations_insanity = level
.spawnpoints
.get("stationary_obstacle_type_2")
.map_or([].as_ref(), |x| x.as_ref());
for obs in spawn_locations_insanity.choose_multiple(&mut rand::thread_rng(), 1) {
let new_obs = components::ObstacleInsanity::new();
world.push((
new_obs,
components::Position::new(obs.x, obs.y),
colliders::Collider::new_sensor_circle(new_obs.r),
components::Sprite::new(sprites::Sprite::TrojanHorse),
));
if player.difficulty > 0.25 {
let spawn_locations_insanity = level
.spawnpoints
.get("stationary_obstacle_type_2")
.map_or([].as_ref(), |x| x.as_ref());
for obs in spawn_locations_insanity.choose_multiple(&mut rand::thread_rng(), 1) {
let new_obs = components::ObstacleInsanity::new();
world.push((
new_obs,
components::Position::new(obs.x, obs.y),
colliders::Collider::new_sensor_circle(new_obs.r),
components::Sprite::new(sprites::Sprite::TrojanHorse),
));
}
}
}
......@@ -38,8 +38,8 @@ impl InGameState {
resources.insert(resources::Camera::new(1920.0, 1080.0));
resources.insert(colliders::CollisionWorld::new());
let obstacles = entities::create_stationary_obstacles(&mut world, &level, &player);
let player = entities::create_player(&mut world, &level, player);
let obstacles = entities::create_stationary_obstacles(&mut world, &level);
resources.insert(resources::Player(player));
resources.insert(obstacles);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment