Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Sommersemester 2019
Cpp
PhaseShifter
Commits
b9008682
Commit
b9008682
authored
Sep 18, 2019
by
Tim Scheiber
Browse files
Added a continuous path movement behaviour
parent
a0b660a5
Pipeline
#3254
failed with stage
in 6 minutes and 51 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
assets/game_assets/blueprints/bullet.json
0 → 100644
View file @
b9008682
{
"Transform"
:
{
"scale"
:
{
"x"
:
0.3
,
"y"
:
0.3
,
"z"
:
0.3
}
},
"Model"
:
{
"aid"
:
"model:cube"
},
"Shadowcaster"
:
{
},
"Movement"
:
{
"beats_per_step"
:
1
,
"distance_per_step"
:
1
,
"step_time_percentage"
:
0.2
,
"off_beat_threshold"
:
0.2
},
"ContinuousPath"
:
{
"direction"
:
270
,
"curvature"
:
0
,
}
}
src/gameplay/continuous_path_comp.cpp
0 → 100644
View file @
b9008682
#include
"continuous_path_comp.hpp"
namespace
phase_shifter
::
gameplay
{
float
Continuous_path_comp
::
next_direction
()
{
float
dir
=
direction
;
direction
+=
curvature
;
return
dir
;
}
}
\ No newline at end of file
src/gameplay/continuous_path_comp.hpp
0 → 100644
View file @
b9008682
#pragma once
#include
<mirrage/ecs/ecs.hpp>
namespace
phase_shifter
::
gameplay
{
struct
Continuous_path_comp
:
public
mirrage
::
ecs
::
Component
<
Continuous_path_comp
>
{
static
constexpr
const
char
*
name
()
{
return
"ContinuousPath"
;
}
using
Component
::
Component
;
float
next_direction
();
float
direction
=
0
;
// angle of direction with 0 beeing North (-Z)
float
curvature
=
0
;
// angle of curvature in degrees
};
sf2_structDef
(
Continuous_path_comp
,
direction
,
curvature
);
}
// namespace phase_shifter::gameplay
\ No newline at end of file
src/gameplay/enemy_system.cpp
View file @
b9008682
...
...
@@ -9,6 +9,7 @@ namespace phase_shifter::gameplay {
{
_entity_manager
.
register_component_type
<
Fixed_path_comp
>
();
_entity_manager
.
register_component_type
<
Follow_target_comp
>
();
_entity_manager
.
register_component_type
<
Continuous_path_comp
>
();
}
void
Enemy_system
::
update
(
mirrage
::
util
::
Time
dt
)
...
...
@@ -38,5 +39,14 @@ namespace phase_shifter::gameplay {
}
}
}
for
(
auto
&&
[
movement
,
cont_path
]
:
_entity_manager
.
list
<
Movement_comp
,
Continuous_path_comp
>
())
{
if
(
!
movement
.
move
)
{
float
rad_direction
=
cont_path
.
next_direction
()
*
mirrage
::
util
::
PI
/
180.
f
;
movement
.
aim
.
x
=
std
::
sin
(
rad_direction
);
movement
.
aim
.
y
=
-
std
::
cos
(
rad_direction
);
movement
.
move
=
true
;
}
}
}
}
\ No newline at end of file
src/gameplay/enemy_system.hpp
View file @
b9008682
...
...
@@ -5,6 +5,7 @@
#include
"fixed_path_comp.hpp"
#include
"follow_target_comp.hpp"
#include
"continuous_path_comp.hpp"
namespace
phase_shifter
::
gameplay
{
...
...
src/meta_system.cpp
View file @
b9008682
...
...
@@ -139,6 +139,11 @@ namespace phase_shifter {
entity
.
process
([
=
](
gameplay
::
Follow_target_comp
&
target
)
{
target
.
target
=
playerhandle
;
});
})
.
create
();
entities
()
.
entity_builder
(
"bullet"
)
.
position
({
8
,
0
,
3
})
.
create
();
}
Meta_system
::~
Meta_system
()
...
...
Write
Preview
Supports
Markdown
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