aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt36
-rw-r--r--Makefile2
-rw-r--r--src/main/cpp/Widget.cpp8
-rw-r--r--src/main/cpp/WorldScene.cpp2
-rw-r--r--src/main/headers/Scene.hpp5
-rw-r--r--src/main/headers/Widget.hpp23
-rw-r--r--src/main/headers/WorldScene.hpp5
-rw-r--r--src/main/headers/config.h0
-rw-r--r--src/main/headers/config.h.in0
9 files changed, 76 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..6b81e25
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,36 @@
+cmake_minimum_required(VERSION 2.6)
+
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
+endif()
+
+project(subconscious)
+
+# Configuration headers
+set(subconscious_VERSION_MAJOR 0)
+set(subconscious_VERSION_MINOR 1)
+configure_file(
+ "${PROJECT_SOURCE_DIR}/src/main/headers/config.h.in"
+ "${PROJECT_SOURCE_DIR}/src/main/headers/config.h"
+)
+
+# include directories
+include_directories("${PROJECT_SOURCE_DIR}/src/main/headers")
+
+# sources
+file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "src/main/cpp/*.cpp")
+
+# executable
+set(EXECUTABLE_NAME "subconscious")
+add_executable(${EXECUTABLE_NAME} ${SOURCES})
+
+# SFML library
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
+find_package(SFML 2 REQUIRED network audio graphics window system)
+if (SFML_FOUND)
+ include_directories(${SFML_INCLUDE_DIR})
+ target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
+endif ()
+
+# install target
+install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)
diff --git a/Makefile b/Makefile
index c831b2b..7540484 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ runjava: java
cpp:
- gradle mainExecutable
+ cmake --build build
runcpp: cpp
./build/exe/main/main
diff --git a/src/main/cpp/Widget.cpp b/src/main/cpp/Widget.cpp
new file mode 100644
index 0000000..82773bc
--- /dev/null
+++ b/src/main/cpp/Widget.cpp
@@ -0,0 +1,8 @@
+#include "Widget.hpp"
+
+#include <SFML/Graphics.hpp>
+
+void Widget::render()
+{
+ sf::RectangleShape rect;
+}
diff --git a/src/main/cpp/WorldScene.cpp b/src/main/cpp/WorldScene.cpp
index 8887f6f..4b7d940 100644
--- a/src/main/cpp/WorldScene.cpp
+++ b/src/main/cpp/WorldScene.cpp
@@ -16,7 +16,7 @@ void WorldScene::render()
rect.setOutlineThickness(-.5);
rect.setOutlineColor(sf::Color::Black);
- for (const Tile &tile : map.tiles()) {
+ for (const Tile &tile : _map.tiles()) {
rect.setPosition(tile.x * _tileSize, tile.y * _tileSize);
_window.draw(rect);
}
diff --git a/src/main/headers/Scene.hpp b/src/main/headers/Scene.hpp
index 2d720a9..0e121e9 100644
--- a/src/main/headers/Scene.hpp
+++ b/src/main/headers/Scene.hpp
@@ -1,7 +1,10 @@
#ifndef SCENE_HPP
#define SCENE_HPP
+#include "Widget.hpp"
+
#include <SFML/Graphics.hpp>
+#include <vector>
class Scene
{
@@ -15,7 +18,7 @@ public:
virtual void keyPress(const sf::Event::KeyEvent &event) {}
protected:
- float _zoom = 1;
+ std::vector<Widget> widgets;
sf::RenderWindow &_window;
Scene(sf::RenderWindow &window) : _window(window) {}
diff --git a/src/main/headers/Widget.hpp b/src/main/headers/Widget.hpp
new file mode 100644
index 0000000..53543fc
--- /dev/null
+++ b/src/main/headers/Widget.hpp
@@ -0,0 +1,23 @@
+#ifndef WIDGET_HPP
+#define WIDGET_HPP
+
+#include <SFML/Graphics.hpp>
+
+struct Widget
+{
+public:
+ int x;
+ int y;
+ unsigned width;
+ unsigned height;
+
+ Widget() = delete;
+ virtual void render();
+
+protected:
+ sf::RenderWindow &_window;
+
+ Widget(sf::RenderWindow &window) : _window(window) {}
+};
+
+#endif
diff --git a/src/main/headers/WorldScene.hpp b/src/main/headers/WorldScene.hpp
index d21d885..2835842 100644
--- a/src/main/headers/WorldScene.hpp
+++ b/src/main/headers/WorldScene.hpp
@@ -23,9 +23,10 @@ public:
virtual void pan(int dx, int dy);
private:
- Map map;
-
+ float _zoom = 1;
unsigned _tileSize;
+
+ Map _map;
};
#endif
diff --git a/src/main/headers/config.h b/src/main/headers/config.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/main/headers/config.h
diff --git a/src/main/headers/config.h.in b/src/main/headers/config.h.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/main/headers/config.h.in