|
|
@ -2,14 +2,10 @@
|
|
|
|
#include "classicnote.h"
|
|
|
|
#include "classicnote.h"
|
|
|
|
#include "classicmapcreator.h"
|
|
|
|
#include "classicmapcreator.h"
|
|
|
|
#include "holdmanager.h"
|
|
|
|
#include "holdmanager.h"
|
|
|
|
#include "context.h"
|
|
|
|
|
|
|
|
#include "tools/music.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ClassicGame::ClassicGame(std::shared_ptr<ClassicGraphicsManager>&& manager, std::unique_ptr<Music>&& music) :
|
|
|
|
ClassicGame::ClassicGame(std::shared_ptr<ClassicGraphicsManager>&& manager) :
|
|
|
|
_graphics_manager(std::move(manager)),
|
|
|
|
_graphics_manager(std::move(manager)),
|
|
|
|
_hold_manager(std::make_shared<HoldManager>(_graphics_manager)),
|
|
|
|
_hold_manager(std::make_unique<HoldManager>(_graphics_manager))
|
|
|
|
_music(std::move(music)),
|
|
|
|
|
|
|
|
_is_paused(false)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_slap_buffer.loadFromFile("Tick.ogg");
|
|
|
|
_slap_buffer.loadFromFile("Tick.ogg");
|
|
|
|
_slap.setBuffer(_slap_buffer);
|
|
|
|
_slap.setBuffer(_slap_buffer);
|
|
|
@ -59,19 +55,19 @@ ClassicGame::~ClassicGame()
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGame::run()
|
|
|
|
void ClassicGame::run()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const auto context = std::make_shared<Context>(Context{_graphics_manager, _hold_manager});
|
|
|
|
_context.hold_manager = _hold_manager;
|
|
|
|
|
|
|
|
_context.graphics_manager = _graphics_manager;
|
|
|
|
|
|
|
|
|
|
|
|
ClassicMapCreator creator(context);
|
|
|
|
auto beatmap = classic::createBeatmap("aa", _context);
|
|
|
|
auto beatmap = creator.createBeatmap("aa");
|
|
|
|
_music.openFromFile("METEOR.flac");
|
|
|
|
_music->openFromFile("METEOR.flac");
|
|
|
|
_music.setVolume(10);
|
|
|
|
_music->setVolume(10);
|
|
|
|
_music.play();
|
|
|
|
_music->play();
|
|
|
|
|
|
|
|
_timeline.setNotes(beatmap.notes, beatmap.visibility_offset);
|
|
|
|
_timeline.setNotes(beatmap.notes, beatmap.visibility_offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGame::input(PlayerInput&& inputdata)
|
|
|
|
void ClassicGame::input(PlayerInput&& inputdata)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
inputdata.timestamp = _music->fetchOffset();
|
|
|
|
inputdata.timestamp = _music.fetchOffset();
|
|
|
|
|
|
|
|
|
|
|
|
switch (inputdata.event.type)
|
|
|
|
switch (inputdata.event.type)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -83,16 +79,14 @@ void ClassicGame::input(PlayerInput&& inputdata)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (inputdata.event.key.code == sf::Keyboard::Space)
|
|
|
|
if (inputdata.event.key.code == sf::Keyboard::Space)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!_is_paused)
|
|
|
|
if (_music.isPaused())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_is_paused = true;
|
|
|
|
_music.play();
|
|
|
|
_music->pause();
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_is_paused = false;
|
|
|
|
_music.pause();
|
|
|
|
_music->play();
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -119,7 +113,7 @@ void ClassicGame::input(PlayerInput&& inputdata)
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGame::update()
|
|
|
|
void ClassicGame::update()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_timeline.update(_music->fetchOffset());
|
|
|
|
_timeline.update(_music.fetchOffset());
|
|
|
|
_timeline.fetchVisibleNotes();
|
|
|
|
_timeline.fetchVisibleNotes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|