Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Engel Simulator 2020
Engel Simulator 2020
Commits
d7cf3670
Commit
d7cf3670
authored
Jan 25, 2021
by
Rahix
🦀
Browse files
Only spawn trojan later into a run
parent
0a775f4d
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/entities/obstacle.rs
View file @
d7cf3670
...
...
@@ -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
),
));
}
}
}
src/states/ingame.rs
View file @
d7cf3670
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment