Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GameDevWeek
S
Sommersemester 2019
Cpp
PhaseShifter
Commits
ac4d5d15
Commit
ac4d5d15
authored
Sep 19, 2019
by
Florian Oetke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basis for particle/ui/sound effects
parent
b25a522a
Pipeline
#3303
passed with stage
in 8 minutes and 16 seconds
Changes
13
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
106 additions
and
11 deletions
+106
-11
assets/game_assets/blueprints/bullet.json
assets/game_assets/blueprints/bullet.json
+1
-0
assets/game_assets/blueprints/player.json
assets/game_assets/blueprints/player.json
+2
-2
src/gameplay/combat_system.cpp
src/gameplay/combat_system.cpp
+9
-0
src/gameplay/dash_system.cpp
src/gameplay/dash_system.cpp
+6
-1
src/gameplay/dash_system.hpp
src/gameplay/dash_system.hpp
+4
-2
src/gameplay/fragile_comp.cpp
src/gameplay/fragile_comp.cpp
+1
-0
src/gameplay/fragile_comp.hpp
src/gameplay/fragile_comp.hpp
+15
-0
src/gameplay/movement_system.cpp
src/gameplay/movement_system.cpp
+2
-2
src/messages.hpp
src/messages.hpp
+8
-1
src/meta_system.cpp
src/meta_system.cpp
+4
-1
src/meta_system.hpp
src/meta_system.hpp
+3
-2
src/ui/effect_system.cpp
src/ui/effect_system.cpp
+26
-0
src/ui/effect_system.hpp
src/ui/effect_system.hpp
+25
-0
No files found.
assets/game_assets/blueprints/bullet.json
View file @
ac4d5d15
...
...
@@ -17,6 +17,7 @@
"step_time_percentage"
:
0.2
,
"off_beat_threshold"
:
0.0
},
"Fragile"
:
{},
"ContinuousPath"
:
{
"direction"
:
270
,
"curvature"
:
0
...
...
assets/game_assets/blueprints/player.json
View file @
ac4d5d15
...
...
@@ -13,9 +13,9 @@
"Movement"
:
{
"beats_per_step"
:
1
,
"distance_per_step"
:
5
,
"step_time_percentage"
:
0.
3
,
"step_time_percentage"
:
0.
5
,
"off_beat_threshold"
:
0.2
,
"overshoot"
:
4
"overshoot"
:
3
},
"Input_controller"
:
{},
"Player"
:
{},
...
...
src/gameplay/combat_system.cpp
View file @
ac4d5d15
#include "combat_system.hpp"
#include "fragile_comp.hpp"
#include "goal_comp.hpp"
#include "player_comp.hpp"
...
...
@@ -24,12 +25,20 @@ namespace phase_shifter::gameplay {
{
_ecs
.
register_component_type
<
Player_comp
>
();
_ecs
.
register_component_type
<
Goal_comp
>
();
_ecs
.
register_component_type
<
Fragile_comp
>
();
_mailbox
.
subscribe_to
([
&
](
Damaged_msg
&
e
)
{
_ecs
.
get
(
e
.
entity
).
process
([
&
](
auto
&
entity
)
{
entity
.
process
([
&
](
Player_comp
&
)
{
_beat_system
.
decrease_beats_left
(
damage_beat_penalty
);
});
});
});
_mailbox
.
subscribe_to
([
&
](
Entity_hit_wall_msg
&
e
)
{
_ecs
.
get
(
e
.
entity
).
process
([
&
](
mirrage
::
ecs
::
Entity_facet
entity
)
{
if
(
entity
.
has
<
Fragile_comp
>
())
_ecs
.
erase
(
entity
);
});
});
}
void
Combat_system
::
update
(
mirrage
::
util
::
Time
)
...
...
src/gameplay/dash_system.cpp
View file @
ac4d5d15
...
...
@@ -3,6 +3,8 @@
#include "killable_comp.hpp"
#include "movement_comp.hpp"
#include "../messages.hpp"
#include <mirrage/ecs/components/transform_comp.hpp>
#include <mirrage/ecs/ecs.hpp>
#include <mirrage/ecs/entity_set_view.hpp>
...
...
@@ -48,7 +50,8 @@ namespace phase_shifter::gameplay {
using
mirrage
::
ecs
::
Entity_handle
;
using
mirrage
::
ecs
::
components
::
Transform_comp
;
Dash_system
::
Dash_system
(
mirrage
::
ecs
::
Entity_manager
&
ecs
)
:
_ecs
(
ecs
)
Dash_system
::
Dash_system
(
mirrage
::
util
::
Message_bus
&
bus
,
mirrage
::
ecs
::
Entity_manager
&
ecs
)
:
_bus
(
bus
),
_ecs
(
ecs
)
{
_ecs
.
register_component_type
<
Dash_comp
>
();
_ecs
.
register_component_type
<
Killable_comp
>
();
...
...
@@ -75,6 +78,8 @@ namespace phase_shifter::gameplay {
_ecs
.
list
<
Entity_handle
,
Transform_comp
,
Killable_comp
>
())
{
auto
circle
=
rotate_point
({
k_transform
.
position
.
x
,
k_transform
.
position
.
z
},
angle
);
if
(
rect_circle_intersects
(
topleft
.
x
,
topleft
.
y
,
width
,
height
,
circle
.
x
,
circle
.
y
,
1
))
{
_bus
.
send
<
Enemy_killed_msg
>
(
k_transform
.
position
,
k_transform
.
position
-
transform
.
position
);
_ecs
.
erase
(
entity
);
}
}
...
...
src/gameplay/dash_system.hpp
View file @
ac4d5d15
#pragma once
#include <mirrage/utils/messagebus.hpp>
#include <mirrage/utils/units.hpp>
namespace
mirrage
::
ecs
{
...
...
@@ -10,14 +11,15 @@ namespace phase_shifter::gameplay {
class
Dash_system
{
public:
Dash_system
(
mirrage
::
ecs
::
Entity_manager
&
);
Dash_system
(
mirrage
::
util
::
Message_bus
&
,
mirrage
::
ecs
::
Entity_manager
&
);
void
update
(
mirrage
::
util
::
Time
);
private:
mirrage
::
util
::
Message_bus
&
_bus
;
mirrage
::
ecs
::
Entity_manager
&
_ecs
;
bool
_was_move
=
false
;
glm
::
vec2
_start_position
;
};
}
\ No newline at end of file
}
// namespace phase_shifter::gameplay
src/gameplay/fragile_comp.cpp
0 → 100644
View file @
ac4d5d15
#include "fragile_comp.hpp"
src/gameplay/fragile_comp.hpp
0 → 100644
View file @
ac4d5d15
#pragma once
#include <mirrage/ecs/ecs.hpp>
#include <mirrage/utils/sf2_glm.hpp>
#include <mirrage/utils/units.hpp>
namespace
phase_shifter
::
gameplay
{
struct
Fragile_comp
:
public
mirrage
::
ecs
::
Stateless_tag_component
<
Fragile_comp
>
{
static
constexpr
const
char
*
name
()
{
return
"Fragile"
;
}
using
Stateless_tag_component
::
Stateless_tag_component
;
};
}
// namespace phase_shifter::gameplay
src/gameplay/movement_system.cpp
View file @
ac4d5d15
...
...
@@ -92,10 +92,10 @@ namespace phase_shifter::gameplay {
_level_system
.
check_contacts
(
pos
+
offset
,
body
.
radius
,
[
&
](
util
::
Contact
contact
)
{
if
(
contact
.
distance2
<=
0.0001
f
)
{
offset
=
glm
::
vec2
(
0
,
0
);
_bus
.
send
<
Entity_hit_wall
>
(
entity_handle
);
_bus
.
send
<
Entity_hit_wall
_msg
>
(
entity_handle
);
}
else
if
(
auto
normal_vel
=
glm
::
dot
(
offset
,
contact
.
normal
);
normal_vel
>
0
)
{
offset
-=
normal_vel
*
contact
.
normal
;
_bus
.
send
<
Entity_hit_wall
>
(
entity_handle
);
_bus
.
send
<
Entity_hit_wall
_msg
>
(
entity_handle
);
}
});
});
...
...
src/messages.hpp
View file @
ac4d5d15
...
...
@@ -2,6 +2,9 @@
#include <mirrage/ecs/types.hpp>
#include <glm/vec3.hpp>
namespace
phase_shifter
{
struct
Win_msg
{
...
...
@@ -9,8 +12,12 @@ namespace phase_shifter {
struct
Lose_msg
{
};
struct
Entity_hit_wall
{
struct
Entity_hit_wall
_msg
{
mirrage
::
ecs
::
Entity_handle
entity
;
};
struct
Enemy_killed_msg
{
glm
::
vec3
position
;
glm
::
vec3
attack_direction
;
};
}
// namespace phase_shifter
src/meta_system.cpp
View file @
ac4d5d15
...
...
@@ -12,6 +12,7 @@
#include "helper/attachment_system.hpp"
#include "input/input_system.hpp"
#include "level/level_system.hpp"
#include "ui/effect_system.hpp"
#include "ui/hud_system.hpp"
#include <context.hpp>
...
...
@@ -42,7 +43,8 @@ namespace phase_shifter {
,
_hud_system
(
std
::
make_unique
<
ui
::
Hud_system
>
(
engine
.
gui
(),
_entities
,
*
_beat_system
))
,
_camera_system
(
std
::
make_unique
<
gameplay
::
Camera_system
>
(
_entities
))
,
_enemy_system
(
std
::
make_unique
<
gameplay
::
Enemy_system
>
(
_entities
))
,
_dash_system
(
std
::
make_unique
<
gameplay
::
Dash_system
>
(
_entities
))
,
_dash_system
(
std
::
make_unique
<
gameplay
::
Dash_system
>
(
engine
.
bus
(),
_entities
))
,
_effect_system
(
std
::
make_unique
<
ui
::
Effect_system
>
(
engine
.
bus
(),
_entities
))
{
_entities
.
register_component_type
<
ecs
::
components
::
Transform_comp
>
();
...
...
@@ -109,6 +111,7 @@ namespace phase_shifter {
_attachment_system
->
update
(
dt
);
_effect_system
->
update
(
dt
);
_hud_system
->
update
(
dt
);
_model_loading
->
update
(
dt
);
...
...
src/meta_system.hpp
View file @
ac4d5d15
...
...
@@ -34,8 +34,9 @@ namespace phase_shifter {
class
Input_system
;
}
namespace
ui
{
class
Effect_system
;
class
Hud_system
;
}
}
// namespace ui
namespace
level
{
class
Level_system
;
}
...
...
@@ -73,7 +74,7 @@ namespace phase_shifter {
std
::
unique_ptr
<
gameplay
::
Camera_system
>
_camera_system
;
std
::
unique_ptr
<
gameplay
::
Enemy_system
>
_enemy_system
;
std
::
unique_ptr
<
gameplay
::
Dash_system
>
_dash_system
;
// TODO: add systems here
std
::
unique_ptr
<
ui
::
Effect_system
>
_effect_system
;
mirrage
::
util
::
Console_command_container
_commands
;
};
...
...
src/ui/effect_system.cpp
0 → 100644
View file @
ac4d5d15
#include "effect_system.hpp"
#include "../messages.hpp"
namespace
phase_shifter
::
ui
{
Effect_system
::
Effect_system
(
mirrage
::
util
::
Message_bus
&
bus
,
mirrage
::
ecs
::
Entity_manager
&
ecs
)
:
_bus
(
bus
),
_mailbox
(
bus
),
_ecs
(
ecs
)
{
_mailbox
.
subscribe_to
([
&
](
Enemy_killed_msg
&
e
)
{
// TODO
});
_mailbox
.
subscribe_to
([
&
](
Win_msg
&
e
)
{
// TODO
});
_mailbox
.
subscribe_to
([
&
](
Lose_msg
&
e
)
{
// TODO
});
}
void
Effect_system
::
update
(
mirrage
::
util
::
Time
)
{
_mailbox
.
update_subscriptions
();
}
}
// namespace phase_shifter::ui
src/ui/effect_system.hpp
0 → 100644
View file @
ac4d5d15
#pragma once
#include <mirrage/utils/messagebus.hpp>
#include <mirrage/utils/units.hpp>
#include <vector>
namespace
mirrage
::
ecs
{
class
Entity_manager
;
}
namespace
phase_shifter
::
ui
{
class
Effect_system
{
public:
Effect_system
(
mirrage
::
util
::
Message_bus
&
,
mirrage
::
ecs
::
Entity_manager
&
);
void
update
(
mirrage
::
util
::
Time
);
private:
mirrage
::
util
::
Message_bus
&
_bus
;
mirrage
::
util
::
Mailbox_collection
_mailbox
;
mirrage
::
ecs
::
Entity_manager
&
_ecs
;
};
}
// namespace phase_shifter::ui
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