Commit c6255c31 authored by Florian Oetke's avatar Florian Oetke
Browse files

beat api [fix #1]

parent 100de4dd
Pipeline #3214 passed with stage
in 7 minutes and 36 seconds
#include "beat_system.hpp"
namespace phase_shifter::gameplay {
namespace {
constexpr auto beat_time = 1.f;
}
void Beat_system::update(mirrage::util::Time dt)
{
_acc += dt.value();
auto beat = _acc >= beat_time;
if(beat)
_acc = 0;
_state = {beat, beat_time - _acc, beat_time - _acc};
}
} // namespace phase_shifter::gameplay
#pragma once
#include <mirrage/utils/units.hpp>
namespace phase_shifter::gameplay {
struct Beat_state {
bool beat = false;
float time_since_beat = 0.f;
float time_to_beat = 0.f;
};
// TODO: replace placeholder logic with actual beat detection
class Beat_system {
public:
Beat_system() = default;
void update(mirrage::util::Time);
auto beat_state() const { return _state; }
private:
Beat_state _state;
float _acc = 0.f;
};
} // namespace phase_shifter::gameplay
......@@ -2,6 +2,7 @@
#include "audio/audio_asset.hpp"
#include "game_engine.hpp"
#include "gameplay/beat_system.hpp"
#include "helper/attachment_system.hpp"
#include "ui/hud_system.hpp"
......@@ -23,6 +24,7 @@ namespace phase_shifter {
, _audio()
, _renderer(engine.renderer_factory().create_renderer(_entities, engine.render_pass_mask()))
, _model_loading(std::make_unique<renderer::Loading_system>(_entities, engine.assets()))
, _beat_system(std::make_unique<gameplay::Beat_system>())
, _attachment_system(std::make_unique<helper::Attachment_system>(_entities))
, _hud_system(std::make_unique<ui::Hud_system>(engine.gui(), _entities))
{
......@@ -118,6 +120,8 @@ namespace phase_shifter {
{
_entities.process_queued_actions();
_beat_system->update(dt);
_attachment_system->update(dt);
_hud_system->update(dt);
......
......@@ -19,6 +19,9 @@ namespace mirrage {
namespace phase_shifter {
class Game_engine;
namespace gameplay {
class Beat_system;
}
namespace helper {
class Attachment_system;
}
......@@ -48,10 +51,11 @@ namespace phase_shifter {
std::unique_ptr<mirrage::renderer::Deferred_renderer> _renderer;
std::unique_ptr<mirrage::renderer::Loading_system> _model_loading;
std::unique_ptr<gameplay::Beat_system> _beat_system;
std::unique_ptr<helper::Attachment_system> _attachment_system;
std::unique_ptr<ui::Hud_system> _hud_system;
// TODO: add systems here
mirrage::util::Console_command_container _commands;
};
} // namespace seapp
} // namespace phase_shifter
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment