aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile17
-rw-r--r--include/bmpimage.hpp4
-rw-r--r--include/components.hpp16
-rw-r--r--include/engine.hpp2
-rw-r--r--include/thread.hpp36
-rw-r--r--include/world.hpp2
-rw-r--r--main.cpp25
-rw-r--r--src/common.cpp5
-rw-r--r--src/components.cpp2
-rw-r--r--src/player.cpp4
-rw-r--r--src/texture.cpp1
-rw-r--r--src/ui.cpp2
12 files changed, 65 insertions, 51 deletions
diff --git a/Makefile b/Makefile
index 471a11a..996c555 100644
--- a/Makefile
+++ b/Makefile
@@ -23,21 +23,18 @@ CXXOBJ = $(patsubst $(CXXSRCDIR)/%.cpp, $(CXXOUTDIR)/%.o, $(CXXSRC))
EXEC = main
-all: $(EXEC)
+all: SPECIAL:=-ggdb game
-dirty:
- rm -rf out/world.o
+release: SPECIAL = -static
+release: LIBS += -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid
+release: game
+
+game: $(EXEC)
clean:
rm -f $(EXEC)
rm -f out/*.o
-cleandata:
- rm -rf xml/*.dat
- rm -rf storyXML/*.dat
- rm brice.dat
- touch brice.dat
-
$(EXEC): $(CXXOUTDIR)/$(CXXOBJ) main.cpp
g++ -I. -std=c++11 -c entityx/help/Pool.cc -o out/Pool.o
g++ -I. -std=c++11 -c entityx/help/Timer.cc -o out/Timer.o
@@ -46,7 +43,7 @@ $(EXEC): $(CXXOUTDIR)/$(CXXOBJ) main.cpp
g++ -I. -std=c++11 -c entityx/System.cc -o out/System.o
@echo " CXX/LD main"
- @$(CXX) $(CXXFLAGS) $(CXXINC) $(CXXWARN) -o $(EXEC) main.cpp out/*.o $(LIBS)
+ @$(CXX) $(SPECIAL) $(CXXFLAGS) $(CXXINC) $(CXXWARN) -o $(EXEC) main.cpp out/*.o $(LIBS)
@rm -rf xml/*.dat
@rm -rf storyXML/*.dat
diff --git a/include/bmpimage.hpp b/include/bmpimage.hpp
index 69b78ac..5e056fe 100644
--- a/include/bmpimage.hpp
+++ b/include/bmpimage.hpp
@@ -1,3 +1,5 @@
+#ifndef __WIN32__
+
#ifndef BMP_IMAGE_HPP
#define BMP_IMAGE_HPP
@@ -32,3 +34,5 @@ typedef struct {
} __attribute__((packed)) BITMAPINFOHEADER;
#endif // BMP_IMAGE_HPP
+
+#endif // __WIN32__ \ No newline at end of file
diff --git a/include/components.hpp b/include/components.hpp
index 5292fb2..14cff81 100644
--- a/include/components.hpp
+++ b/include/components.hpp
@@ -319,11 +319,11 @@ struct Limb {
float updateRate; /**< How often we will change each frame. */
float updateCurrent; /**< How much has been updated in the current frame. */
- uint updateType; /**< What the updateRate will base it's updates off of.
+ unsigned int updateType; /**< What the updateRate will base it's updates off of.
ie: Movement, attacking, jumping. */
- uint limbID; /**< The id of the limb we will be updating */
+ unsigned int limbID; /**< The id of the limb we will be updating */
- uint index = 0; /**< The current sprite being used for the limb. */
+ unsigned int index = 0; /**< The current sprite being used for the limb. */
std::vector<Frame> frame; /**< The multiple frames of each limb. */
};
@@ -333,7 +333,7 @@ struct Animate {
// COMMENT
std::vector<Limb> limb;
// COMMENT
- uint index;
+ unsigned int index;
Animate(){
index = 0;
@@ -341,8 +341,8 @@ struct Animate {
// COMMENT
- void firstFrame(uint updateType, Frame &sprite) {
- uint upid = updateType; //^see todo
+ void firstFrame(unsigned int updateType, Frame &sprite) {
+ unsigned int upid = updateType; //^see todo
for (auto &l : limb) {
if (l.updateType == upid) {
l.firstFrame(sprite);
@@ -350,8 +350,8 @@ struct Animate {
}
}
//TODO make updateType an enum
- void updateAnimation(uint updateType, Frame& sprite, float dt) {
- uint upid = updateType; //^see todo
+ void updateAnimation(unsigned int updateType, Frame& sprite, float dt) {
+ unsigned int upid = updateType; //^see todo
for (auto &l : limb) {
if (l.updateType == upid) {
l.nextFrame(sprite, dt);
diff --git a/include/engine.hpp b/include/engine.hpp
index fda9980..112fd3c 100644
--- a/include/engine.hpp
+++ b/include/engine.hpp
@@ -8,7 +8,7 @@
#include <atomic>
#include <chrono>
-#include <thread>
+#include <thread.hpp>
#include <entityx/entityx.h>
diff --git a/include/thread.hpp b/include/thread.hpp
new file mode 100644
index 0000000..3adc43d
--- /dev/null
+++ b/include/thread.hpp
@@ -0,0 +1,36 @@
+#ifndef THREAD_HPP_
+#define THREAD_HPP_
+
+#ifndef __WIN32__
+#include <thread>
+#else
+#include <win32thread.hpp>
+#endif // __WIN32__
+
+#include <atomic>
+#include <entityx/entityx.h>
+
+class GameThread : public entityx::Receiver<GameThread> {
+private:
+ std::atomic_bool die;
+ std::thread thread;
+
+public:
+ GameThread(std::function<void(void)> func) {
+ die.store(false);
+ thread = std::thread([&](std::function<void(void)> f) {
+ while (!die.load())
+ f();
+ }, func);
+ }
+
+ ~GameThread(void) {
+ thread.join();
+ }
+
+ inline void stop(void) {
+ die.store(true);
+ }
+};
+
+#endif // THREAD_HPP_ \ No newline at end of file
diff --git a/include/world.hpp b/include/world.hpp
index fe7d819..b4986e1 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -6,7 +6,6 @@
#define WORLD_HPP_
#include <string>
-#include <thread>
#include <vector>
#include <SDL2/SDL_mixer.h>
@@ -18,6 +17,7 @@ using namespace tinyxml2;
#include <components.hpp>
#include <events.hpp>
#include <texture.hpp>
+#include <thread.hpp>
#include <vector2.hpp>
/**
diff --git a/main.cpp b/main.cpp
index dd84788..34d3367 100644
--- a/main.cpp
+++ b/main.cpp
@@ -24,30 +24,6 @@ using namespace std::literals::chrono_literals;
#include <ui.hpp>
#include <inventory.hpp>
-class GameThread : public entityx::Receiver<GameThread> {
-private:
- std::atomic_bool die;
- std::thread thread;
-
-public:
- template<typename F>
- GameThread(F&& func) {
- die.store(false);
- thread = std::thread([this](F&& f) {
- while (!die.load())
- f();
- }, std::forward<F>(func));
- }
-
- ~GameThread(void) {
- thread.join();
- }
-
- void stop(void) {
- die.store(true);
- }
-};
-
/**
* The currently used folder to look for XML files in.
*/
@@ -188,6 +164,7 @@ int main(int argc, char *argv[])
// on game end, get back together
gtMain.stop();
gtDebug.stop();
+ gtFade.stop();
//game::engine.getSystem<WorldSystem>()->thAmbient.join(); // segfault or something
}
diff --git a/src/common.cpp b/src/common.cpp
index 37f5c78..8c63800 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -8,17 +8,16 @@
#include <iostream>
#include <list>
#include <sstream>
+#include <vector>
#include <error.hpp>
+#include <texture.hpp>
#ifndef __WIN32__
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
-#include <vector>
-
-#include <texture.hpp>
#endif // __WIN32__
diff --git a/src/components.cpp b/src/components.cpp
index d8321f4..7cb533c 100644
--- a/src/components.cpp
+++ b/src/components.cpp
@@ -297,7 +297,7 @@ std::vector<Frame> developFrame(XMLElement* xml)
std::vector<Frame> tmp;
SpriteData* sd;
- uint limb = 0;
+ unsigned int limb = 0;
vec2 foffset;
vec2 fsize;
diff --git a/src/player.cpp b/src/player.cpp
index 78c0b8e..da71914 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -91,9 +91,9 @@ void PlayerSystem::create(void)
auto entan = player.assign<Animate>();
auto animx = xmld.FirstChildElement()->FirstChildElement();
- uint limbid = 0;
+ unsigned int limbid = 0;
float limbupdate = 0;
- uint limbupdatetype = 0;
+ unsigned int limbupdatetype = 0;
while (animx) {
std::string animType = animx->Name();
diff --git a/src/texture.cpp b/src/texture.cpp
index ad06967..5723bd8 100644
--- a/src/texture.cpp
+++ b/src/texture.cpp
@@ -2,6 +2,7 @@
#include <algorithm>
#include <string>
+#include <stdexcept>
#include <SDL2/SDL_image.h>
diff --git a/src/ui.cpp b/src/ui.cpp
index 7a81bd5..b14ea2c 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -1107,7 +1107,7 @@ namespace ui {
std::vector<GLubyte> bgr (SCREEN_WIDTH * SCREEN_HEIGHT * 3, 0);
- for(uint x = 0; x < SCREEN_WIDTH*SCREEN_HEIGHT*3; x+=3) {
+ for(unsigned int x = 0; x < SCREEN_WIDTH*SCREEN_HEIGHT*3; x+=3) {
bgr[x] = pixels[x+2];
bgr[x+1] = pixels[x+1];
bgr[x+2] = pixels[x];