Delete roundtarget
This commit is contained in:
parent
05f8b11dec
commit
dbb296ff5d
5 changed files with 2 additions and 74 deletions
|
@ -52,24 +52,18 @@ void Game::run() {
|
|||
|
||||
void Game::processEvents(AudioEmitter &audioEmitter) {
|
||||
while (const std::optional event = mWindow.pollEvent()) {
|
||||
if (const auto *keyPressed = event->getIf<sf::Event::KeyPressed>()) {
|
||||
mTarget.handlePlayerInput(keyPressed->code, true);
|
||||
} else if (const auto *keyReleased =
|
||||
event->getIf<sf::Event::KeyReleased>()) {
|
||||
mTarget.handlePlayerInput(keyReleased->code, false);
|
||||
} else if (event->is<sf::Event::Closed>()) {
|
||||
if (event->is<sf::Event::Closed>()) {
|
||||
audioEmitter.audioEnd();
|
||||
mWindow.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Game::update(const sf::Time elapsedTime) { mTarget.update(elapsedTime); }
|
||||
void Game::update(const sf::Time elapsedTime) {}
|
||||
|
||||
void Game::render() {
|
||||
mWindow.clear(sf::Color::Yellow);
|
||||
NoteTile::update(1.0 / 60, mWindow);
|
||||
mTarget.drawCurrent(mWindow);
|
||||
mWindow.draw(mStatisticsText);
|
||||
mWindow.display();
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#include "RoundTarget.hpp"
|
||||
|
||||
RoundTarget::RoundTarget(const float radius, const sf::Color color, float x,
|
||||
float y) {
|
||||
mShape.setRadius(radius);
|
||||
mShape.setFillColor(color);
|
||||
mShape.setPosition({x, y});
|
||||
}
|
||||
|
||||
void RoundTarget::drawCurrent(sf::RenderWindow &window) const {
|
||||
/*printf("sphere pos (%f, %f)\n", mShape.getPosition().x,*/
|
||||
/* mShape.getPosition().y);*/
|
||||
window.draw(mShape);
|
||||
}
|
||||
|
||||
void RoundTarget::handlePlayerInput(const sf::Keyboard::Key &key,
|
||||
const bool &isPressed) {
|
||||
using enum sf::Keyboard::Key;
|
||||
if (key == Z)
|
||||
mIsMovingUp = isPressed;
|
||||
else if (key == S)
|
||||
mIsMovingDown = isPressed;
|
||||
else if (key == Q)
|
||||
mIsMovingLeft = isPressed;
|
||||
else if (key == D)
|
||||
mIsMovingRight = isPressed;
|
||||
}
|
||||
|
||||
void RoundTarget::update(const sf::Time &elapsedTime) {
|
||||
sf::Vector2f movement{0.f, 0.f};
|
||||
if (mIsMovingUp)
|
||||
movement.y -= TargetSpeed;
|
||||
if (mIsMovingDown)
|
||||
movement.y += TargetSpeed;
|
||||
if (mIsMovingLeft)
|
||||
movement.x -= TargetSpeed;
|
||||
if (mIsMovingRight)
|
||||
movement.x += TargetSpeed;
|
||||
|
||||
mShape.move(movement * elapsedTime.asSeconds());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue