wavelength 1.0.0
Loading...
Searching...
No Matches
freestyletrack.h
Go to the documentation of this file.
1#pragma once
2
3#include "game/player.h"
4#include "game/playmap.h"
6#include "game/track.h"
7#include "os/command.h"
8#include "os/ptr.h"
9#include "os/timer.h"
10
19class FreestyleTrack : public Track {
20public:
34 PlayMap *pPlayMap,
35 const float *pfMsPerTick,
36 int nIndex,
37 int nNumBars,
38 int nTicksPerBar);
39
46 ~FreestyleTrack() override;
47
54 void Stop() override;
55
64 void SetPlayer(Player *pPlayer) override;
65
67
76 void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override;
77
86 void HandleInput([[maybe_unused]] Player *pPlayer,
87 [[maybe_unused]] const BtnEvent<8> &event) override {
88 }
89
98 void HandleInput(Player *pPlayer, const StickEvent<2> &event) override;
99
108 void HandleInput(Player *pPlayer, const StickEvent<6> &event) override;
109
115 virtual bool IsActive() = 0;
116
118 virtual void Refresh() = 0;
119
128 int WrapTick(int nTick);
129
140 int SpanEnd(int nTick, int nStart, int nEnd);
141
152
162 void StartBar(bool bSchedule);
163
176 void SendUpdate(Player *pPlayer, float fX, float fY);
177
179 int GetTickOffset() const {
180 return mTickOffset;
181 }
182
184 void SetTickOffset(int nTickOffset) {
185 mTickOffset = nTickOffset;
186 }
187
188protected:
190
191private:
192 const SectionBoundaries *mSections;
193 PlayMap *mPlayMap;
194 const float *mMsPerTick;
195 int mNumBars;
196 int mTicksPerBar;
197 int mButton;
198 float mLastSendMs;
199 Timer mNoteTimer;
200 Ptr<Command> mBarCommand;
201 Ptr<Command> mPointsCommand;
202};
Input event of a button press that names only the player.
Definition btnevent.h:15
void StartBar(bool bSchedule)
Commit the pending points of the bar that ends and restart the timing of the active note.
void HandleInput(Player *pPlayer, const StickEvent< 2 > &event) override
Pass a stick position of the track's player to the graphics and the other consoles.
int mTickOffset
Definition freestyletrack.h:189
void UpdatePoints()
Award the player pending points for the time the active note sounded in the bar, and run again a twen...
void Stop() override
Stop the track with the song.
FreestyleTrack(const SectionBoundaries *pSections, PlayMap *pPlayMap, const float *pfMsPerTick, int nIndex, int nNumBars, int nTicksPerBar)
Construct a track.
void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override
Send a note the track's player played, and start or stop the scoring of the time it sounds.
void SetPlayer(Player *pPlayer) override
Commit the points of the player that leaves, assign the player, and start the bars of the player that...
~FreestyleTrack() override
Release the track.
void HandleInput(Player *pPlayer, const BtnEvent< 8 > &event) override
Ignore the event.
Definition freestyletrack.h:86
int SpanEnd(int nTick, int nStart, int nEnd)
Report the tick at which the span that starts at a tick ends.
int WrapTick(int nTick)
Wrap a tick into the repeat period of the track.
virtual bool IsActive()=0
Report whether the track has an active note.
void SetTickOffset(int nTickOffset)
Definition freestyletrack.h:184
void SendUpdate(Player *pPlayer, float fX, float fY)
Send the button and a stick position of a local player to the other consoles, at most once every 150 ...
void HandleInput(Player *pPlayer, const StickEvent< 6 > &event) override
Pass a stick position of the track's player to the graphics.
int GetTickOffset() const
Definition freestyletrack.h:179
virtual void Refresh()=0
Rebuild what the track plays from the song position.
Map from the bars a song plays to the bars of the song as written, with the loops that repeat stretch...
Definition playmap.h:11
Input event that plays a note on one of the three gem buttons.
Definition playnoteevent.h:10
One participant in a song: the track the participant plays, the score, and the streak.
Definition player.h:19
Owner of one reference to an Attachment.
Definition ptr.h:16
Ascending list of the measures at which the sections of a song end.
Definition sectionboundaries.h:12
Input event of an analog stick position.
Definition stickevent.h:15
Stopwatch on the EE cycle counter.
Definition timer.h:16
Track(int nIndex)
Construct a track with no player.
virtual void HandleInput(Player *pPlayer, const PlayNoteEvent &event)=0
Act on a note a player played on this track.