diff --git a/SimpleGame/src/CMakeLists.txt b/SimpleGame/src/CMakeLists.txt index 567fa91..bdb1e10 100644 --- a/SimpleGame/src/CMakeLists.txt +++ b/SimpleGame/src/CMakeLists.txt @@ -19,7 +19,6 @@ endif() add_executable(simpleGame Source/Game.cpp Include/Game.hpp Source/Main.cpp - Source/RoundTarget.cpp Include/RoundTarget.hpp Source/AudioEmitter.cpp Include/AudioEmitter.hpp Source/NoteSprite.cpp Include/NoteSprite.hpp Source/NoteTile.cpp Include/NoteTile.hpp Include/NotePlaceEnum.hpp diff --git a/SimpleGame/src/Include/Game.hpp b/SimpleGame/src/Include/Game.hpp index a3b8fbf..8e341d4 100644 --- a/SimpleGame/src/Include/Game.hpp +++ b/SimpleGame/src/Include/Game.hpp @@ -4,7 +4,6 @@ #define BOOK_GAME_HPP #include "AudioEmitter.hpp" -#include "RoundTarget.hpp" #include class Game { @@ -25,7 +24,6 @@ private: sf::RenderWindow mWindow{sf::VideoMode({640, 480}), "SFML Application"}; sf::Texture mTexture; - RoundTarget mTarget{35.f, sf::Color::Red, 320.f, 300.f}; sf::Font mFont; sf::Text mStatisticsText{mFont}; sf::Time mStatisticsUpdateTime; diff --git a/SimpleGame/src/Include/RoundTarget.hpp b/SimpleGame/src/Include/RoundTarget.hpp deleted file mode 100644 index 65618fa..0000000 --- a/SimpleGame/src/Include/RoundTarget.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SIMPLE_GAME_ROUND_TARGET_H -#define SIMPLE_GAME_ROUND_TARGET_H - -#include - -class RoundTarget { -public: - RoundTarget(float radius, sf::Color color, float x, float y); - void drawCurrent(sf::RenderWindow &window) const; - void handlePlayerInput(const sf::Keyboard::Key &key, const bool &isPressed); - void update(const sf::Time &elapsedTime); - -private: - static constexpr float TargetSpeed{100.f}; - bool mIsMovingUp{false}; - bool mIsMovingDown{false}; - bool mIsMovingRight{false}; - bool mIsMovingLeft{false}; - sf::CircleShape mShape; -}; - -#endif // SIMPLE_GAME_ROUND_TARGET_H diff --git a/SimpleGame/src/Source/Game.cpp b/SimpleGame/src/Source/Game.cpp index 2ec2684..b7cc4d3 100644 --- a/SimpleGame/src/Source/Game.cpp +++ b/SimpleGame/src/Source/Game.cpp @@ -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()) { - mTarget.handlePlayerInput(keyPressed->code, true); - } else if (const auto *keyReleased = - event->getIf()) { - mTarget.handlePlayerInput(keyReleased->code, false); - } else if (event->is()) { + if (event->is()) { 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(); } diff --git a/SimpleGame/src/Source/RoundTarget.cpp b/SimpleGame/src/Source/RoundTarget.cpp deleted file mode 100644 index 7e00841..0000000 --- a/SimpleGame/src/Source/RoundTarget.cpp +++ /dev/null @@ -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()); -}