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
492648c1
Commit
492648c1
authored
Sep 20, 2019
by
Florian Oetke
Browse files
fixed gcc/clang compilation errors
parent
042663dc
Pipeline
#3336
failed with stage
in 3 minutes and 57 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/gameplay/enemy_system.cpp
View file @
492648c1
...
...
@@ -205,13 +205,14 @@ namespace phase_shifter::gameplay {
glm
::
vec2
last_bullet_pos
=
bullet_movement
.
last_position
;
glm
::
vec2
player_pos
{
player_transform
.
position
.
x
,
player_transform
.
position
.
z
};
glm
::
vec2
last_player_pos
=
player_movement
.
last_position
;
if
(
!
bullet_movement
.
moved
)
{
if
(
!
bullet_movement
.
moved
)
{
last_bullet_pos
=
bullet_pos
;
}
if
(
!
player_movement
.
moved
)
{
if
(
!
player_movement
.
moved
)
{
last_player_pos
=
player_pos
;
}
if
(
intersect
(
Stadium
{
last_bullet_pos
,
bullet_pos
,
bullet_body
.
radius
},
Stadium
{
last_player_pos
,
player_pos
,
player_body
.
radius
}))
{
if
(
intersect
(
Stadium
{
last_bullet_pos
,
bullet_pos
,
bullet_body
.
radius
},
Stadium
{
last_player_pos
,
player_pos
,
player_body
.
radius
}))
{
_entity_manager
.
erase
(
bullet_handle
);
_bus
.
send
<
Damaged_msg
>
(
player_handle
);
}
...
...
@@ -219,17 +220,17 @@ namespace phase_shifter::gameplay {
}
}
bool
Enemy_system
::
intersect
(
Stadium
&
stad1
,
Stadium
&
stad2
)
bool
Enemy_system
::
intersect
(
const
Stadium
&
stad1
,
const
Stadium
&
stad2
)
{
glm
::
vec2
direction1
=
stad1
.
point2
-
stad1
.
point1
;
glm
::
vec2
direction2
=
stad2
.
point2
-
stad2
.
point1
;
glm
::
vec2
eliminator
{
-
direction1
.
y
,
direction1
.
x
};
float
temp
=
glm
::
dot
(
direction2
,
eliminator
);
float
temp
=
glm
::
dot
(
direction2
,
eliminator
);
if
(
temp
!=
0
)
{
float
lambda
=
glm
::
dot
((
stad1
.
point1
-
stad2
.
point1
),
eliminator
)
/
temp
;
if
(
lambda
>=
0
&&
lambda
<=
1
)
{
if
(
lambda
>=
0
&&
lambda
<=
1
)
{
return
true
;
}
}
...
...
@@ -237,8 +238,9 @@ namespace phase_shifter::gameplay {
float
comb_radius
=
stad1
.
radius
+
stad2
.
radius
;
float
length2
=
glm
::
length2
(
direction1
);
if
(
length2
<=
0.001
f
)
{
if
(
glm
::
distance
(
stad2
.
point1
,
stad1
.
point1
)
<
comb_radius
||
glm
::
distance
(
stad2
.
point2
,
stad1
.
point1
)
<
comb_radius
)
{
if
(
length2
<=
0.001
f
)
{
if
(
glm
::
distance
(
stad2
.
point1
,
stad1
.
point1
)
<
comb_radius
||
glm
::
distance
(
stad2
.
point2
,
stad1
.
point1
)
<
comb_radius
)
{
return
true
;
}
}
...
...
@@ -253,7 +255,8 @@ namespace phase_shifter::gameplay {
length2
=
glm
::
length2
(
direction2
);
if
(
length2
<=
0.001
f
)
{
if
(
glm
::
distance
(
stad1
.
point1
,
stad2
.
point1
)
<
comb_radius
||
glm
::
distance
(
stad1
.
point2
,
stad2
.
point1
)
<
comb_radius
)
{
if
(
glm
::
distance
(
stad1
.
point1
,
stad2
.
point1
)
<
comb_radius
||
glm
::
distance
(
stad1
.
point2
,
stad2
.
point1
)
<
comb_radius
)
{
return
true
;
}
}
...
...
@@ -269,5 +272,5 @@ namespace phase_shifter::gameplay {
return
false
;
}
float
Enemy_system
::
dot
(
glm
::
vec2
&
a
,
glm
::
vec2
&
b
)
{
return
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
;
}
}
// namespace phase_shifter::gameplay
\ No newline at end of file
float
Enemy_system
::
dot
(
const
glm
::
vec2
&
a
,
const
glm
::
vec2
&
b
)
{
return
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
;
}
}
// namespace phase_shifter::gameplay
src/gameplay/enemy_system.hpp
View file @
492648c1
#pragma once
#include
<mirrage/utils/units.hpp>
#include
<mirrage/ecs/entity_manager.hpp>
#include
<mirrage/utils/units.hpp>
#include
"bullet_comp.hpp"
#include
"continuous_path_comp.hpp"
#include
"fixed_path_comp.hpp"
#include
"follow_target_comp.hpp"
#include
"continuous_path_comp.hpp"
#include
"shooting_comp.hpp"
#include
"target_comp.hpp"
#include
"bullet_comp.hpp"
#include
"beat_system.hpp"
namespace
phase_shifter
::
gameplay
{
struct
Stadium
{
glm
::
vec2
point1
;
glm
::
vec2
point2
;
...
...
@@ -39,7 +39,7 @@ namespace phase_shifter::gameplay {
void
do_shooting
(
Beat_state
&
beat
);
void
do_bullet_hit_detection
();
bool
intersect
(
Stadium
&
stad1
,
Stadium
&
stad2
);
float
dot
(
glm
::
vec2
&
a
,
glm
::
vec2
&
b
);
bool
intersect
(
const
Stadium
&
stad1
,
const
Stadium
&
stad2
);
float
dot
(
const
glm
::
vec2
&
a
,
const
glm
::
vec2
&
b
);
};
}
\ No newline at end of file
}
// namespace phase_shifter::gameplay
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