You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB
C++

#include "classicgame.h"
#include "classicmapcreator.h"
#include "classicmode/classicnote.h"
#include "gamecontext.h"
#include "graphics/classicgraphicsmanager.h"
#include "holdmanager.h"
ClassicGame::ClassicGame(
const std::shared_ptr<kku::Timeline<ClassicNote>> &timeline,
const std::shared_ptr<GameContext> &context)
: _timeline(timeline), _context(context)
{
}
void ClassicGame::run()
{
auto beatmap = classic::createBeatmap("aa", _context);
_timeline->setNotes(beatmap.notes);
}
void ClassicGame::input(kku::GameEvent &&input)
{
switch (input.event.type)
{
default:
return;
break;
case kku::SystemEvent::Type::KeyPress:
{
auto note_it = _timeline->getActiveNote(input.timestamp);
if (!_timeline->isExpired(note_it))
{
auto note = (*note_it);
note->input(std::move(input));
}
}
break;
case kku::SystemEvent::Type::KeyRelease:
{
_context->getHoldManager()->checkRelease(
std::get<kku::SystemEvent::Key>(input.event.data).view);
}
break;
}
}
void ClassicGame::update(kku::UpdateData &&updatedata)
{
// UNCOMMENT TO TEST AUTOPLAY
/*auto note_it = _timeline->getActiveNote(updatedata.timestamp);
if (!_timeline->isExpired(note_it) && updatedata.timestamp >=
(*note_it)->getPerfectOffset())
{
auto note = (*note_it);
note->input(kku::GameEvent{updatedata.timestamp,
kku::SystemEvent{kku::SystemEvent::Type::None, kku::SystemEvent::Key{}}});
}*/
_timeline->update(updatedata.timestamp);
_context->getGraphicsManager()->update(updatedata.timestamp);
}
void ClassicGame::display() const
{
_context->getGraphicsManager()->display();
}