Skip to content

Commit

Permalink
create indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
onon1101 committed Apr 25, 2024
1 parent 5bce29a commit 661f571
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
26 changes: 26 additions & 0 deletions include/Display/BeatIndicator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef I_LOVE_PTSD_BEATINDICATOR_H
#define I_LOVE_PTSD_BEATINDICATOR_H

#include <memory>

#include "GameElement.h"

namespace Display {
class BeatIndicator {
public:
static void Init();

static std::shared_ptr<GameElement> GetGameElement();

static void Update();

private:
static std::string m_IndicatorImagePath;
static glm::vec2 m_Position;
static glm::vec2 m_Scale;
static float m_ZIndex;
static std::shared_ptr<GameElement> m_GameElement;
};
} // namespace Display

#endif // I_LOVE_PTSD_BEATINDICATOR_H
6 changes: 4 additions & 2 deletions include/Music/Tempo.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Tempo {
[[nodiscard]]
static bool IsTempoInRange(
const std::size_t triggerRange,
const float time
const float time,
const std::size_t MusicLoopCounter
);

[[nodiscard]]
Expand All @@ -39,7 +40,8 @@ class Tempo {

static void Update(
const float musicPlaytTime,
const std::size_t triggerOffset
const std::size_t triggerOffset,
const std::size_t MusicLoopCounter
);

static std::size_t m_BeatListLen;
Expand Down
8 changes: 6 additions & 2 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ void App::Update() {
|| Util::Input::IsKeyDown(Util::Keycode::D)
|| Util::Input::IsKeyDown(Util::Keycode::S)
|| Util::Input::IsKeyDown(Util::Keycode::A))
&& Music::Tempo::IsTempoInRange(500, Util::Time::GetElapsedTimeMs())) {
&& Music::Tempo::IsTempoInRange(
500,
Util::Time::GetElapsedTimeMs(),
Music::Player::LoopCounter()
)) {
glm::vec2 playerDestination = m_MainCharacter->GetGamePosition();

if (m_PlayerMoveDirect != Player::NONE) {
Expand Down Expand Up @@ -235,7 +239,7 @@ void App::Update() {
auto musicTime = Music::Player::GetMusicTime() * 1000;

Display::BeatHeart::Update();
Music::Tempo::Update(musicTime, 0u);
Music::Tempo::Update(musicTime, 0u, Music::Player::LoopCounter());

m_MainCharacter->Update();
m_Camera->Update();
Expand Down
3 changes: 3 additions & 0 deletions src/Display/BeatIndicator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// #include "Display/BeatIndicator.h"

// Display::BeatIndicator::Init() {}
15 changes: 9 additions & 6 deletions src/Music/Tempo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ void Music::Tempo::ReadTempoFile(const std::string& path) {

bool Music::Tempo::IsTempoInRange(
const std::size_t triggerRange,
const float time
const float time,
const std::size_t MusicLoopCounter
) {
if (m_CurrentBeatLopTimes != Music::Player::LoopCounter()) {
m_CurrentBeatLopTimes = Music::Player::LoopCounter();
// TODO: //
if (m_CurrentBeatLopTimes != MusicLoopCounter) {
m_CurrentBeatLopTimes = MusicLoopCounter;
LopReset();
}

Expand Down Expand Up @@ -121,10 +123,11 @@ void Music::Tempo::LopReset() {

void Music::Tempo::Update(
const float musicPlaytTime,
const std::size_t triggerOffset
const std::size_t triggerOffset,
const std::size_t MusicLoopCounter
) {
if (m_CurrentBeatLopTimes != Music::Player::LoopCounter()) {
m_CurrentBeatLopTimes = Music::Player::LoopCounter();
if (m_CurrentBeatLopTimes != MusicLoopCounter) {
m_CurrentBeatLopTimes = MusicLoopCounter;
LopReset();
}

Expand Down

0 comments on commit 661f571

Please sign in to comment.