102 lines
2.3 KiB
C++
102 lines
2.3 KiB
C++
#include "classicgame.h"
|
|
#include "classicnote.h"
|
|
#include "classicmapcreator.h"
|
|
#include "game/classicgraphicsmanager.h"
|
|
#include "holdmanager.h"
|
|
|
|
ClassicGame::ClassicGame() :
|
|
_hold_manager(std::make_unique<HoldManager>())
|
|
{
|
|
_slap_buffer.loadFromFile("Tick.ogg");
|
|
_slap.setBuffer(_slap_buffer);
|
|
_slap.setVolume(50);
|
|
|
|
_keys_to_buttons =
|
|
{
|
|
{sf::Keyboard::Up, Type::UP}, // Load from settings
|
|
{sf::Keyboard::Right, Type::RIGHT},
|
|
{sf::Keyboard::Down, Type::DOWN},
|
|
{sf::Keyboard::Left, Type::LEFT},
|
|
|
|
{sf::Keyboard::W, Type::UP},
|
|
{sf::Keyboard::D, Type::RIGHT},
|
|
{sf::Keyboard::S, Type::DOWN},
|
|
{sf::Keyboard::A, Type::LEFT},
|
|
|
|
{sf::Keyboard::E, Type::SLIDER_RIGHT},
|
|
{sf::Keyboard::Q, Type::SLIDER_LEFT}
|
|
};
|
|
|
|
_buttons_to_pressed_actions=
|
|
{
|
|
{Type::UP, Action::PRESS_UP},
|
|
{Type::RIGHT, Action::PRESS_RIGHT},
|
|
{Type::DOWN, Action::PRESS_DOWN},
|
|
{Type::LEFT, Action::PRESS_LEFT},
|
|
|
|
{Type::SLIDER_RIGHT, Action::PRESS_SLIDER_RIGHT},
|
|
{Type::SLIDER_LEFT, Action::PRESS_SLIDER_LEFT}
|
|
};
|
|
|
|
_buttons_to_released_actions=
|
|
{
|
|
{Type::UP, Action::RELEASE_UP},
|
|
{Type::RIGHT, Action::RELEASE_RIGHT},
|
|
{Type::DOWN, Action::RELEASE_DOWN},
|
|
{Type::LEFT, Action::RELEASE_LEFT},
|
|
|
|
{Type::SLIDER_RIGHT, Action::RELEASE_SLIDER_RIGHT},
|
|
{Type::SLIDER_LEFT, Action::RELEASE_SLIDER_LEFT}
|
|
};
|
|
}
|
|
|
|
ClassicGame::~ClassicGame()
|
|
{}
|
|
|
|
void ClassicGame::run()
|
|
{
|
|
_context.hold_manager = _hold_manager;
|
|
|
|
auto beatmap = classic::createBeatmap("aa", _context);
|
|
_timeline.setNotes(beatmap.notes);
|
|
}
|
|
|
|
void ClassicGame::input(PlayerInput&& inputdata)
|
|
{
|
|
switch (inputdata.event.type)
|
|
{
|
|
default:
|
|
return;
|
|
break;
|
|
|
|
case sf::Event::KeyPressed:
|
|
{
|
|
auto note_it = _timeline.getActiveNote(inputdata.timestamp);
|
|
|
|
if (!_timeline.isExpired(note_it))
|
|
{
|
|
auto note = (*note_it);
|
|
note->input(std::move(inputdata));
|
|
_slap.play();
|
|
}
|
|
}
|
|
break;
|
|
|
|
case sf::Event::KeyReleased:
|
|
{
|
|
_hold_manager->checkRelease(inputdata.event.key.code);
|
|
}
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
void ClassicGame::update(UpdateData&& updatedata)
|
|
{
|
|
_timeline.update(updatedata.timestamp);
|
|
}
|
|
|
|
void ClassicGame::draw() const
|
|
{
|
|
}
|