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
13e5455c
Commit
13e5455c
authored
Sep 19, 2019
by
Kevin Balz
Browse files
fix beat decrease
parent
4c5fe467
Pipeline
#3314
passed with stage
in 8 minutes and 1 second
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/gameplay/beat_system.cpp
View file @
13e5455c
...
...
@@ -26,6 +26,7 @@ namespace phase_shifter::gameplay {
i
++
;
}
_state
.
beats_left
=
static_cast
<
int
>
(
_time_stamps
.
size
());
_state
.
avg_beat_time
=
static_cast
<
float
>
(
_time_stamps
[
_time_stamps
.
size
()
-
1
])
/
_time_stamps
.
size
();
}
...
...
@@ -35,11 +36,13 @@ namespace phase_shifter::gameplay {
_acc
+=
dt
.
value
();
int
size
=
static_cast
<
int
>
(
_time_stamps
.
size
());
auto
beat
=
_beat_index
+
1
<
size
&&
_acc
>=
_time_stamps
[
_beat_index
+
1
];
int
beats_left
=
_state
.
beats_left
;
if
(
beat
)
{
_beat_index
++
;
LOG
(
plog
::
debug
)
<<
"beat"
;
if
(
_beat_index
+
1
>=
size
)
{
beats_left
=
size
-
1
-
_beat_index
-
_beat_offset
;
if
(
beats_left
<=
0
)
{
_bus
.
send
<
Lose_msg
>
();
}
}
...
...
@@ -48,7 +51,7 @@ namespace phase_shifter::gameplay {
_beat_index
>=
0
?
_acc
-
_time_stamps
[
_beat_index
]
:
_acc
,
_beat_index
+
1
<
size
?
_time_stamps
[
_beat_index
+
1
]
-
_acc
:
999
,
_state
.
avg_beat_time
,
size
-
1
-
_beat_index
};
beats_left
};
}
auto
Beat_system
::
graphic_time_scale
()
const
->
float
...
...
@@ -67,6 +70,7 @@ namespace phase_shifter::gameplay {
void
Beat_system
::
decrease_beats_left
(
int
count
)
{
_beat_offset
-=
count
;
if
(
_state
.
beats_left
>
0
)
{
_state
.
beats_left
-=
count
;
...
...
src/gameplay/beat_system.hpp
View file @
13e5455c
...
...
@@ -39,6 +39,7 @@ namespace phase_shifter::gameplay {
float
_acc
=
0.
f
;
std
::
vector
<
float
>
_time_stamps
;
int
_beat_index
=
-
1
;
int
_beat_offset
=
0
;
};
}
// 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