project-kyoku/src/modes/classicmode/game/classicgame.cpp

69 lines
1.6 KiB
C++
Raw Normal View History

2021-12-29 15:59:18 +01:00
#include "classicgame.h"
2022-02-10 00:30:49 +01:00
#include "classicmode/classicnote.h"
2021-12-29 15:59:18 +01:00
#include "classicmapcreator.h"
#include "gamecontext.h"
2021-12-29 15:59:18 +01:00
#include "holdmanager.h"
ClassicGame::ClassicGame(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
const std::shared_ptr<GameContext>& context) :
2021-12-29 15:59:18 +01:00
_timeline(timeline),
_context(context)
2021-12-29 15:59:18 +01:00
{}
ClassicGame::~ClassicGame()
{}
void ClassicGame::run()
{
auto beatmap = classic::createBeatmap("aa", _context);
2021-12-29 15:59:18 +01:00
_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);
2021-12-29 15:59:18 +01:00
}
break;
}
}
void ClassicGame::update(kku::UpdateData&& updatedata)
{
// UNCOMMENT TO TEST AUTOPLAY
2022-01-11 21:15:24 +01:00
/*auto note_it = _timeline->getActiveNote(updatedata.timestamp);
2021-12-29 15:59:18 +01:00
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{}}});
2022-01-11 21:15:24 +01:00
}*/
2021-12-29 15:59:18 +01:00
_timeline->update(updatedata.timestamp);
}
void ClassicGame::display() const
{
2022-05-17 06:22:18 +02:00
_context->display();
2021-12-29 15:59:18 +01:00
}