forked from NaiJi/project-kyoku
Implement basic ClassicNote
parent
3c733cd490
commit
f66951bcec
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <SFML/System/Clock.hpp>
|
||||
|
||||
using microsec = sf::Int64;
|
||||
|
||||
class Note
|
||||
{
|
||||
public:
|
||||
explicit Note(microsec perfect_offset) :
|
||||
_perfect_offset(perfect_offset) {}
|
||||
virtual ~Note() = 0;
|
||||
|
||||
protected:
|
||||
microsec _perfect_offset;
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
#ifndef NOTEGRAPHICSENTITY_H
|
||||
#define NOTEGRAPHICSENTITY_H
|
||||
|
||||
#include <SFML/Graphics/Drawable.hpp>
|
||||
#include <SFML/Graphics/Transformable.hpp>
|
||||
|
||||
class NoteGraphicsEntity : public sf::Drawable, public sf::Transformable
|
||||
{
|
||||
public:
|
||||
explicit NoteGraphicsEntity();
|
||||
virtual ~NoteGraphicsEntity() = 0;
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
virtual void attach() noexcept final;
|
||||
virtual void detach() noexcept final;
|
||||
|
||||
virtual void onKeyPressed() = 0;
|
||||
virtual void onKeyReleased() = 0;
|
||||
|
||||
virtual void show() = 0;
|
||||
virtual void killAsExpired() = 0;
|
||||
virtual void reset() = 0;
|
||||
|
||||
virtual bool isActive() const = 0;
|
||||
|
||||
protected:
|
||||
bool _attached;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
class Sprite
|
||||
{
|
||||
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
#include "classicnote.h"
|
||||
|
||||
ClassicNote::ClassicNote(const std::vector<microsec>& intervals, microsec perfect_offset) :
|
||||
Note(perfect_offset),
|
||||
_evaluator(intervals, _perfect_offset)
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "note.h"
|
||||
#include "precisionevaluator.h"
|
||||
|
||||
class ClassicNote : public Note
|
||||
{
|
||||
public:
|
||||
|
||||
enum class GRADE
|
||||
{
|
||||
PERFECT,
|
||||
GOOD,
|
||||
BAD
|
||||
};
|
||||
|
||||
explicit ClassicNote(const std::vector<microsec>& intervals, microsec perfect_offset);
|
||||
virtual ~ClassicNote() = default;
|
||||
|
||||
private:
|
||||
PrecisionEvaluator<GRADE> _evaluator;
|
||||
};
|
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "timeline.h"
|
||||
|
||||
class Note;
|
||||
|
||||
class ClassicTimeline : public Timeline
|
||||
{
|
||||
public:
|
||||
explicit ClassicTimeline();
|
||||
virtual void update(const microsec& music_offset) override;
|
||||
virtual void init() override;
|
||||
virtual void clear() override;
|
||||
|
||||
Note *getActiveNote(const microsec &music_offset) noexcept;
|
||||
|
||||
private:
|
||||
std::vector<Note*> _timeline;
|
||||
std::vector<Note*>::const_iterator _top_note;
|
||||
Note* _active_note;
|
||||
|
||||
std::vector<Note*>::const_iterator _last_visible_note;
|
||||
microsec _visibility_offset;
|
||||
|
||||
void checkCurrentActiveNote(const microsec &music_offset);
|
||||
void checkForNextActiveNote(const microsec &music_offset);
|
||||
void prepareNotesToDraw(const microsec &music_offset);
|
||||
|
||||
/* Difference between top and active note is that
|
||||
* top note is the note handling input right now
|
||||
* OR it's the closest note from current music offset
|
||||
* position, not necessarily active. A note stops being top only
|
||||
* after dying or being tapped by player, even if it's already
|
||||
* past her perfect offset.
|
||||
*
|
||||
* Meanwhile active note is the note which is currently handling
|
||||
* player input for grade.
|
||||
*
|
||||
* An active note is always top note but a top note
|
||||
* is not always active note.
|
||||
* */
|
||||
};
|
@ -1,15 +0,0 @@
|
||||
#include "notegraphicsentity.h"
|
||||
|
||||
NoteGraphicsEntity::NoteGraphicsEntity() :
|
||||
_attached(false)
|
||||
{}
|
||||
|
||||
void NoteGraphicsEntity::attach() noexcept
|
||||
{
|
||||
_attached = true;
|
||||
}
|
||||
|
||||
void NoteGraphicsEntity::detach() noexcept
|
||||
{
|
||||
_attached = false;
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
#include "timelineviewmanager.h"
|
||||
|
||||
TimelineViewManager::TimelineViewManager()
|
||||
{}
|
Loading…
Reference in New Issue