summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/Controllers/CMakeLists.txt1
-rw-r--r--src/Controllers/SFMLController/CMakeLists.txt3
-rw-r--r--src/Controllers/SFMLController/SFMLController.cpp37
-rw-r--r--src/Controllers/SFMLController/SFMLController.hpp21
-rw-r--r--src/View/CMakeLists.txt2
-rw-r--r--src/View/MainWindow.cpp25
-rw-r--r--src/View/MainWindow.hpp20
-rw-r--r--src/main.cpp4
9 files changed, 113 insertions, 3 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index da444d2..e7b7f73 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,7 +12,8 @@ set_property(GLOBAL PROPERTY SFML_INCLUDE_DIR "${SFML_INCLUDE_DIR}")
#Include "Includes" and "Libraries"
include_directories(${SFML_INCLUDE_DIR})
-target_link_libraries(2P11 ${SFML_LIBRARIES} Model ConsoleController)
+target_link_libraries(2P11 ${SFML_LIBRARIES} Model ConsoleController View SFMLController)
add_subdirectory(./Model)
add_subdirectory(./Controllers/)
+add_subdirectory(./View/)
diff --git a/src/Controllers/CMakeLists.txt b/src/Controllers/CMakeLists.txt
index 7ebeb19..13b1c20 100644
--- a/src/Controllers/CMakeLists.txt
+++ b/src/Controllers/CMakeLists.txt
@@ -1 +1,2 @@
add_subdirectory(./ConsoleController/)
+add_subdirectory(./SFMLController/)
diff --git a/src/Controllers/SFMLController/CMakeLists.txt b/src/Controllers/SFMLController/CMakeLists.txt
new file mode 100644
index 0000000..e3e60c4
--- /dev/null
+++ b/src/Controllers/SFMLController/CMakeLists.txt
@@ -0,0 +1,3 @@
+#Make Model lib
+add_library(SFMLController ./SFMLController.cpp)
+target_link_libraries(SFMLController Model View)
diff --git a/src/Controllers/SFMLController/SFMLController.cpp b/src/Controllers/SFMLController/SFMLController.cpp
new file mode 100644
index 0000000..09a3c25
--- /dev/null
+++ b/src/Controllers/SFMLController/SFMLController.cpp
@@ -0,0 +1,37 @@
+#include "SFMLController.hpp"
+
+
+
+
+
+
+SFMLController::SFMLController() : m_MainWindow(800,800, "2P11"){
+
+}
+
+
+SFMLController::~SFMLController(){
+
+}
+
+
+
+
+void SFMLController::run(){
+
+ while(m_MainWindow.isOpen()){
+
+
+ sf::Event event;
+ while (m_MainWindow.pollEvent(event))
+ {
+ // évènement "fermeture demandée" : on ferme la fenêtre
+ if (event.type == sf::Event::Closed)
+ m_MainWindow.close();
+ }
+ m_MainWindow.clearMW();
+ m_MainWindow.display();
+ }
+
+
+}
diff --git a/src/Controllers/SFMLController/SFMLController.hpp b/src/Controllers/SFMLController/SFMLController.hpp
new file mode 100644
index 0000000..94a22e3
--- /dev/null
+++ b/src/Controllers/SFMLController/SFMLController.hpp
@@ -0,0 +1,21 @@
+
+
+
+#include <iostream>
+#include <string>
+#include <SFML/Window.hpp>
+#include "../../View/MainWindow.hpp"
+
+class SFMLController{
+
+ private:
+ MainWindow m_MainWindow;
+
+
+ public:
+ SFMLController();
+ ~SFMLController();
+
+ void run();
+
+};
diff --git a/src/View/CMakeLists.txt b/src/View/CMakeLists.txt
new file mode 100644
index 0000000..9a13671
--- /dev/null
+++ b/src/View/CMakeLists.txt
@@ -0,0 +1,2 @@
+#Make Model lib
+add_library(View ./MainWindow.cpp)
diff --git a/src/View/MainWindow.cpp b/src/View/MainWindow.cpp
new file mode 100644
index 0000000..274fc8e
--- /dev/null
+++ b/src/View/MainWindow.cpp
@@ -0,0 +1,25 @@
+#include "MainWindow.hpp"
+
+
+
+
+
+
+MainWindow::MainWindow(int width, int height, std::string title):
+ RenderWindow(sf::VideoMode(width,height), title),
+ skin()
+{
+
+ //Define skin:
+ skin.push_back(sf::Color(250,248,239));
+
+
+}
+
+
+MainWindow::~MainWindow(){
+}
+
+void MainWindow::clearMW(){
+ RenderWindow::clear(skin.at(0));
+}
diff --git a/src/View/MainWindow.hpp b/src/View/MainWindow.hpp
new file mode 100644
index 0000000..a0e7c58
--- /dev/null
+++ b/src/View/MainWindow.hpp
@@ -0,0 +1,20 @@
+
+
+
+#include <iostream>
+#include <vector>
+#include <SFML/Window.hpp>
+#include <SFML/Graphics.hpp>
+
+
+class MainWindow : public sf::RenderWindow{
+
+ private:
+ std::vector<sf::Color> skin;
+ public:
+ MainWindow(int width, int height, std::string title);
+ ~MainWindow();
+
+ void clearMW();
+
+};
diff --git a/src/main.cpp b/src/main.cpp
index 48c1766..70f3a6b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,7 +6,7 @@
//----------------------
//----- Personnal include -----
-#include "./Controllers/ConsoleController/ConsoleController.hpp"
+#include "./Controllers/SFMLController/SFMLController.hpp"
//-----------------------------
@@ -20,7 +20,7 @@ int main()
srand(time(NULL));
//Init controller
- ConsoleController controller;
+ SFMLController controller;
//Run the game
controller.run();