]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
windows
authorClyne Sullivan <tullivan99@gmail.com>
Sun, 22 Jan 2017 17:03:22 +0000 (12:03 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Sun, 22 Jan 2017 17:03:22 +0000 (12:03 -0500)
12 files changed:
Makefile
include/bmpimage.hpp
include/components.hpp
include/engine.hpp
include/thread.hpp [new file with mode: 0644]
include/world.hpp
main.cpp
src/common.cpp
src/components.cpp
src/player.cpp
src/texture.cpp
src/ui.cpp

index 471a11a3635cef0562f8e2002bbda68bd1bbccea..996c5559995dfb1134bf6a1af2e8707fbe1c881a 100644 (file)
--- 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
 
index 69b78ac39b6ea78bd8e41b1381152e07b9f198af..5e056fe8d555c2efda6c126dc45b6076bfdb65b2 100644 (file)
@@ -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
index 5292fb286ebf9176d93f05b25d3aac7a346252b2..14cff813d1129d7c3157589cda6fb59e931419b4 100644 (file)
@@ -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);
index fda9980bc190c0b7a0d13dbaa422ddaf1b3cf065..112fd3c82805e16d4c4c1003beee73ad6cd46601 100644 (file)
@@ -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 (file)
index 0000000..3adc43d
--- /dev/null
@@ -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
index fe7d819b72b6f5b853d2b912c76df5f8e9e9232e..b4986e1c348186202d723309de16db15405aff53 100644 (file)
@@ -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>
 
 /**
index dd84788acc1c7521b32f3a6e47dfff5753732020..34d3367dcee2b3f67ce3d9273c972170f8cc6bae 100644 (file)
--- 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
        }
 
index 37f5c78fbe4c2c781a323ec709bcae74a5514ef9..8c63800a94c908284fd05b6bbfd5a006d31ca527 100644 (file)
@@ -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__
 
index d8321f4b5f767fa4745ef4883d39b3372b379d03..7cb533c9e9f8af0a6090d0ca1f2c495092bd622b 100644 (file)
@@ -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;
index 78c0b8e1e54acc710880cf08b7de58ae98ab5a3a..da719148daf9e28dc45dd5147d263e242ac0874a 100644 (file)
@@ -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();
index ad069678596f49d385e426fb5f8124b92d2c9e5c..5723bd8f9d59dad29b5018548c0ee0d70d7913fb 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <algorithm>
 #include <string>
+#include <stdexcept>
 
 #include <SDL2/SDL_image.h>
 
index 7a81bd525305347680e8c0e43900a8798f51ce3d..b14ea2cbd9284ce683c4f07a9cba4879812e552c 100644 (file)
@@ -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];