Commit f478fc1d authored by Ушкова Диана Петровна's avatar Ушкова Диана Петровна
Browse files

created menu

1 merge request!1created menu
Showing with 24 additions and 66 deletions
+24 -66
...@@ -5,17 +5,17 @@ include(FetchContent) ...@@ -5,17 +5,17 @@ include(FetchContent)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
FetchContent_Declare(SFML GIT_REPOSITORY https://github.com/SFML/SFML.git GIT_TAG 2.6.1) FetchContent_Declare(SFML GIT_REPOSITORY https://github.com/SFML/SFML.git GIT_TAG 2.6.1)
FetchContent_MakeAvailable(SFML) FetchContent_MakeAvailable(SFML)
#file(GLOB_RECURSE SOURCE_CPP source/*.cpp) file(GLOB_RECURSE SOURCE_CPP source/*.cpp)
#add_executable(pacman ${SOURCE_CPP}) add_executable(pacman ${SOURCE_CPP})
add_executable(pacman source/main.cpp #add_executable(pacman source/main.cpp
source/application/app/app.cpp # source/application/app/app.cpp
source/application/Drawable/SelectCommand/ISelectCommand.cpp # source/application/Drawable/SelectCommand/ISelectCommand.cpp
source/application/Drawable/idrawable.cpp # source/application/Drawable/idrawable.cpp
source/application/Drawable/Button/button.cpp # source/application/Drawable/Button/button.cpp
source/application/Drawable/Font/font.cpp # source/application/Drawable/Font/font.cpp
source/application/Event/IWindowKeeper.cpp # source/application/Event/IWindowKeeper.cpp
source/application/State/IState.cpp # source/application/State/IState.cpp
source/application/Drawable/Menu/menu.cpp) # source/application/Drawable/Menu/menu.cpp)
target_link_libraries(pacman PRIVATE sfml-window sfml-graphics sfml-system) target_link_libraries(pacman PRIVATE sfml-window sfml-graphics sfml-system)
target_compile_definitions(pacman PRIVATE ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets/") target_compile_definitions(pacman PRIVATE ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets/")
......
...@@ -2,41 +2,7 @@ ...@@ -2,41 +2,7 @@
#include "../../../config/config.h" #include "../../../config/config.h"
SelectState::SelectState(IStateManager& state_manager, //GameState::GameState(IStateManager& state_manager,
const sf::VideoMode& video_mode, // const sf::VideoMode& video_mode,
const std::string& window_title) : // const std::string& window_title) :
IState(state_manager), IWindowKeeper(video_mode, window_title) {} // IState(state_manager), IWindowKeeper(video_mode, window_title) {}
void SelectState::event_handling() {
sf::Event event;
while (m_window.pollEvent(event)) {
if (event.type == sf::Event::Closed) { m_window.close();}
}
}
void SelectState::update() {
const sf::Vector2f pos = m_window.mapPixelToCoords(sf::Mouse::getPosition(m_window));
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
m_menu.process_mouse(pos, true);
return;
}
m_menu.process_mouse(pos, false);
}
void SelectState::render() {
m_window.clear(config::SELECT_LEVEL_BACKGROUND_COLOR);
m_menu.draw_into(m_window);
m_window.display();
}
bool SelectState::do_step() {
event_handling();
update();
render();
return true;
}
GameState::GameState(IStateManager& state_manager,
const sf::VideoMode& video_mode,
const std::string& window_title) :
IState(state_manager), IWindowKeeper(video_mode, window_title) {}
#pragma once #pragma once
#include "../Event/IWindowKeeper.h" #include "../Event/IWindowKeeper.h"
#include "../Drawable/Menu/menu.h"
#include <memory> #include <memory>
#include <iostream> #include <iostream>
...@@ -17,23 +16,15 @@ protected: ...@@ -17,23 +16,15 @@ protected:
IStateManager& m_state_manager; IStateManager& m_state_manager;
}; };
struct SelectState: public IState, public IWindowKeeper {
SelectState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title);
void event_handling() override;
void update() override;
void render() override;
bool do_step() override;
private:
Menu m_menu;
};
struct GameState: IState, IWindowKeeper {
GameState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title); //struct GameState: IState, IWindowKeeper {
void event_handling() override; // GameState(IStateManager& state_manager, const sf::VideoMode& video_mode, const std::string& window_title);
void update() override; // void event_handling() override;
void render() override; // void update() override;
bool do_step() override; // void render() override;
}; // bool do_step() override;
//};
struct ExitState: IState { struct ExitState: IState {
ExitState(IStateManager& state_manager) : IState(state_manager) {} ExitState(IStateManager& state_manager) : IState(state_manager) {}
......
#pragma once #pragma once
#include "../State/IState.h" #include "../State/IState.h"
#include "../State/SelectState.h"
#include <iostream> #include <iostream>
#include <memory> #include <memory>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment