Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
PhaseShifter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GameDevWeek
S
Sommersemester 2019
Cpp
PhaseShifter
Commits
3c39a57c
Commit
3c39a57c
authored
Sep 21, 2019
by
Tim Scheiber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
screen shake - the game
parent
ccb6e796
Pipeline
#3421
failed with stage
in 2 minutes and 33 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
63 additions
and
8 deletions
+63
-8
assets/game_assets/blueprints/camera.json
assets/game_assets/blueprints/camera.json
+2
-1
src/gameplay/beat_system.cpp
src/gameplay/beat_system.cpp
+1
-0
src/gameplay/camera_system.cpp
src/gameplay/camera_system.cpp
+22
-5
src/gameplay/camera_system.hpp
src/gameplay/camera_system.hpp
+6
-1
src/gameplay/dash_system.cpp
src/gameplay/dash_system.cpp
+1
-0
src/gameplay/enemy_system.cpp
src/gameplay/enemy_system.cpp
+1
-0
src/gameplay/enemy_system.hpp
src/gameplay/enemy_system.hpp
+2
-0
src/gameplay/shake_comp.hpp
src/gameplay/shake_comp.hpp
+16
-0
src/gameplay/spring_comp.hpp
src/gameplay/spring_comp.hpp
+1
-0
src/level/level_system.cpp
src/level/level_system.cpp
+5
-0
src/messages.hpp
src/messages.hpp
+5
-0
src/meta_system.cpp
src/meta_system.cpp
+1
-1
No files found.
assets/game_assets/blueprints/camera.json
View file @
3c39a57c
...
...
@@ -15,5 +15,6 @@
"Spring"
:
{
"spring_constant"
:
20.0
,
"mass"
:
1.0
}
},
"Shake"
:
{}
}
src/gameplay/beat_system.cpp
View file @
3c39a57c
...
...
@@ -40,6 +40,7 @@ namespace phase_shifter::gameplay {
if
(
beat
)
{
_beat_index
++
;
LOG
(
plog
::
debug
)
<<
"beat"
;
_bus
.
send
<
Screen_shake_msg
>
(
0.03
f
,
0.05
f
);
beats_left
=
size
-
1
-
_beat_index
+
_beat_offset
;
if
(
beats_left
<=
0
||
_beat_index
+
1
>=
size
)
{
...
...
src/gameplay/camera_system.cpp
View file @
3c39a57c
...
...
@@ -6,17 +6,28 @@ namespace phase_shifter::gameplay {
using
mirrage
::
ecs
::
components
::
Transform_comp
;
Camera_system
::
Camera_system
(
mirrage
::
ecs
::
Entity_manager
&
entity_manager
)
:
_entity_manager
(
entity_manager
)
Camera_system
::
Camera_system
(
mirrage
::
util
::
Message_bus
&
bus
,
mirrage
::
ecs
::
Entity_manager
&
entity_manager
)
:
_
mailbox
(
bus
),
_
entity_manager
(
entity_manager
)
{
_entity_manager
.
register_component_type
<
Viewtarget_comp
>
();
_entity_manager
.
register_component_type
<
Spring_comp
>
();
_entity_manager
.
register_component_type
<
Shake_comp
>
();
_mailbox
.
subscribe_to
([
&
](
Screen_shake_msg
&
e
)
{
for
(
auto
&
shake
:
_entity_manager
.
list
<
Shake_comp
>
())
{
shake
.
intesity
=
e
.
intensity
;
shake
.
duration
=
e
.
duration
;
shake
.
time_remaining
=
e
.
duration
;
}
});
}
void
Camera_system
::
update
(
mirrage
::
util
::
Time
dt
)
{
for
(
auto
&&
[
transform
,
viewtarget
,
spring
]
:
_entity_manager
.
list
<
Transform_comp
,
Viewtarget_comp
,
Spring_comp
>
())
{
_mailbox
.
update_subscriptions
();
for
(
auto
&&
[
transform
,
viewtarget
,
spring
,
shake
]
:
_entity_manager
.
list
<
Transform_comp
,
Viewtarget_comp
,
Spring_comp
,
Shake_comp
>
())
{
auto
target_facet
=
_entity_manager
.
get
(
viewtarget
.
target
);
if
(
target_facet
.
is_some
())
{
...
...
@@ -35,7 +46,13 @@ namespace phase_shifter::gameplay {
glm
::
vec3
spring_force
=
spring
.
spring_constant
*
(
dest_pos
-
transform
.
position
);
glm
::
vec3
acceleration
=
(
spring_force
+
damping_force
)
/
spring
.
mass
;
spring
.
velocity
+=
dt
.
value
()
*
acceleration
;
transform
.
position
+=
dt
.
value
()
*
spring
.
velocity
;
spring
.
position
+=
dt
.
value
()
*
spring
.
velocity
;
transform
.
position
=
spring
.
position
;
if
(
shake
.
time_remaining
>
0
)
{
glm
::
vec3
shake_direction
=
glm
::
normalize
(
glm
::
vec3
{
std
::
rand
(),
0
,
std
::
rand
()});
transform
.
position
+=
shake
.
intesity
*
(
shake
.
time_remaining
/
shake
.
duration
)
*
shake_direction
;
shake
.
time_remaining
-=
dt
.
value
();
}
transform
.
direction
(
-
offset
);
}
}
...
...
src/gameplay/camera_system.hpp
View file @
3c39a57c
...
...
@@ -2,18 +2,23 @@
#include <mirrage/utils/units.hpp>
#include <mirrage/ecs/entity_manager.hpp>
#include <mirrage/utils/messagebus.hpp>
#include "../messages.hpp"
#include "viewtarget_comp.hpp"
#include "spring_comp.hpp"
#include "shake_comp.hpp"
namespace
phase_shifter
::
gameplay
{
class
Camera_system
{
public:
Camera_system
(
mirrage
::
ecs
::
Entity_manager
&
entity_manager
);
Camera_system
(
mirrage
::
util
::
Message_bus
&
bus
,
mirrage
::
ecs
::
Entity_manager
&
entity_manager
);
void
update
(
mirrage
::
util
::
Time
dt
);
private:
mirrage
::
ecs
::
Entity_manager
&
_entity_manager
;
mirrage
::
util
::
Mailbox_collection
_mailbox
;
};
}
\ No newline at end of file
src/gameplay/dash_system.cpp
View file @
3c39a57c
...
...
@@ -115,6 +115,7 @@ namespace phase_shifter::gameplay {
_bus
.
send
<
Enemy_killed_msg
>
(
k_transform
.
position
,
glm
::
vec3
(
attack_direction
.
x
,
0.
f
,
attack_direction
.
y
));
_bus
.
send
<
Screen_shake_msg
>
(
0.5
f
,
0.3
f
);
_ecs
.
erase
(
entity
);
}
}
...
...
src/gameplay/enemy_system.cpp
View file @
3c39a57c
...
...
@@ -221,6 +221,7 @@ namespace phase_shifter::gameplay {
Stadium
{
last_player_pos
,
player_pos
,
player_body
.
radius
}))
{
_entity_manager
.
erase
(
bullet_handle
);
_bus
.
send
<
Damaged_msg
>
(
player_handle
);
_bus
.
send
<
Screen_shake_msg
>
(
0.3
f
,
0.3
f
);
}
}
}
...
...
src/gameplay/enemy_system.hpp
View file @
3c39a57c
...
...
@@ -12,6 +12,8 @@
#include "beat_system.hpp"
#include "../messages.hpp"
namespace
phase_shifter
::
gameplay
{
struct
Stadium
{
...
...
src/gameplay/shake_comp.hpp
0 → 100644
View file @
3c39a57c
#pragma once
#include <mirrage/ecs/ecs.hpp>
#include <mirrage/utils/sf2_glm.hpp>
namespace
phase_shifter
::
gameplay
{
struct
Shake_comp
:
public
mirrage
::
ecs
::
Component
<
Shake_comp
>
{
static
constexpr
const
char
*
name
()
{
return
"Shake"
;
}
using
Component
::
Component
;
float
intesity
=
0
;
float
duration
=
0
;
//duration in seconds
float
time_remaining
=
0
;
//remaining shake time in seconds
};
}
// namespace phase_shifter::gameplay
src/gameplay/spring_comp.hpp
View file @
3c39a57c
...
...
@@ -12,6 +12,7 @@ namespace phase_shifter::gameplay {
float
spring_constant
=
1.
f
;
float
mass
=
1.
f
;
glm
::
vec3
position
=
{
0.
f
,
0.
f
,
0.
f
};
glm
::
vec3
velocity
=
{
0.
f
,
0.
f
,
0.
f
};
};
...
...
src/level/level_system.cpp
View file @
3c39a57c
...
...
@@ -4,6 +4,7 @@
#include "../gameplay/player_comp.hpp"
#include "../gameplay/rigid_body_comp.hpp"
#include "../gameplay/viewtarget_comp.hpp"
#include "../gameplay/spring_comp.hpp"
#include "../helper/attachment_comp.hpp"
#include <mirrage/ecs/components/transform_comp.hpp>
...
...
@@ -66,6 +67,10 @@ namespace phase_shifter::level {
entity
.
process
([
=
](
gameplay
::
Viewtarget_comp
&
viewtarget
)
{
viewtarget
.
target
=
playerhandle
;
});
entity
.
process
(
[
=
](
gameplay
::
Spring_comp
&
spring
,
Transform_comp
&
transform
)
{
spring
.
position
=
transform
.
position
;
});
})
.
create
();
...
...
src/messages.hpp
View file @
3c39a57c
...
...
@@ -29,4 +29,9 @@ namespace phase_shifter {
mirrage
::
util
::
Str_id
id
;
};
struct
Screen_shake_msg
{
float
intensity
;
float
duration
;
//duration in seconds
};
}
// namespace phase_shifter
src/meta_system.cpp
View file @
3c39a57c
...
...
@@ -43,7 +43,7 @@ namespace phase_shifter {
,
_combat_system
(
std
::
make_unique
<
gameplay
::
Combat_system
>
(
engine
.
bus
(),
_entities
,
*
_beat_system
))
,
_attachment_system
(
std
::
make_unique
<
helper
::
Attachment_system
>
(
_entities
))
,
_hud_system
(
std
::
make_unique
<
ui
::
Hud_system
>
(
engine
.
gui
(),
_entities
,
*
_beat_system
))
,
_camera_system
(
std
::
make_unique
<
gameplay
::
Camera_system
>
(
_entities
))
,
_camera_system
(
std
::
make_unique
<
gameplay
::
Camera_system
>
(
engine
.
bus
(),
_entities
))
,
_enemy_system
(
std
::
make_unique
<
gameplay
::
Enemy_system
>
(
engine
.
bus
(),
_entities
,
*
_beat_system
))
,
_dash_system
(
std
::
make_unique
<
gameplay
::
Dash_system
>
(
engine
.
bus
(),
_entities
))
,
_stationary_attack_system
(
...
...
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