diff --git a/src/Screens/Gameplay.hpp b/src/Screens/Gameplay.hpp deleted file mode 100644 index 20c471b..0000000 --- a/src/Screens/Gameplay.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "../Data/Chart.hpp" -#include "../Data/Score.hpp" - -namespace Screen { - class Gameplay { - const Data::Chart& chart; - public: - explicit Gameplay(const Data::Chart& selected_chart); - Score play_chart(sf::Window& window) const; - }; -}; - diff --git a/src/Screens/Gameplay/Gameplay.cpp b/src/Screens/Gameplay/Gameplay.cpp new file mode 100644 index 0000000..4a694ea --- /dev/null +++ b/src/Screens/Gameplay/Gameplay.cpp @@ -0,0 +1,50 @@ +#include "Gameplay.hpp" + +#include +#include + +namespace Gameplay { + Screen::Screen(const Data::SongDifficulty& t_song_selection) : + song_selection(t_song_selection), + chart(*t_song_selection.song.get_chart(t_song_selection.difficulty)) + { + + } + + Data::Score Screen::play_chart(sf::RenderWindow& window) { + window.setFramerateLimit(60); + ImGui::SFML::Init(window); + sf::Clock imguiClock; + sf::Music song; + if (song_selection.song.full_audio_path()) + while ((not song_finished) and window.isOpen()) { + sf::Event event; + while (window.pollEvent(event)) { + ImGui::SFML::ProcessEvent(event); + switch (event.type) { + case sf::Event::KeyPressed: + break; + case sf::Event::MouseButtonPressed: + break; + case sf::Event::Closed: + window.close(); + break; + case sf::Event::Resized: + // update the view to the new size of the window + window.setView(sf::View({0, 0, static_cast(event.size.width), static_cast(event.size.height)})); + // resources.preferences.screen.height = event.size.height; + // resources.preferences.screen.width = event.size.width; + break; + default: + break; + } + } + ImGui::SFML::Update(window, imguiClock.restart()); + window.clear(sf::Color(7, 23, 53)); + draw_debug(); + ImGui::SFML::Render(window); + window.display(); + } + ImGui::SFML::Shutdown(); + } +} diff --git a/src/Screens/Gameplay/Gameplay.hpp b/src/Screens/Gameplay/Gameplay.hpp new file mode 100644 index 0000000..a628d29 --- /dev/null +++ b/src/Screens/Gameplay/Gameplay.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include "../../Data/Chart.hpp" +#include "../../Data/Song.hpp" +#include "../../Data/Score.hpp" +#include "../../Toolkit/Debuggable.hpp" + +namespace Gameplay { + class Screen : public Toolkit::Debuggable { + public: + explicit Screen(const Data::SongDifficulty& song_selection); + Data::Score play_chart(sf::RenderWindow& window); + private: + const Data::SongDifficulty& song_selection; + const Data::Chart chart; + Data::Score score; + bool song_finished = false; + }; +}; +