diff --git a/.gitignore b/.gitignore index dd654e5092197245df5f8e1b91c5173412e65a29..99b9f78428485e21031a787992ea44b4fe09d293 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ game bin/ +# Libraries +libs/ + # Build directory build/ @@ -32,6 +35,7 @@ build/ # Visual Studio Code specific files .vscode/ + # CMake files CMakeFiles/ CMakeCache.txt diff --git a/include/main.h b/include/main.h index efab70116a5388e1c74ba9649b6a8dede035f864..d402445bd0929ad316e5786de22327021465c581 100644 --- a/include/main.h +++ b/include/main.h @@ -4,6 +4,9 @@ #include <iostream> #include <cstdint> +#define SDL_MAIN_HANDLED +#include <SDL.h> + enum GenerationMethod { Random diff --git a/makefile b/makefile index 0a14e43d858f7c4514c37be19b272e5525cb0b1a..aef12b9e1fa5d81b44558cb423b0da76225725bd 100644 --- a/makefile +++ b/makefile @@ -21,6 +21,12 @@ TEST_DIR = test # Executable directory BIN_DIR = bin +# SDL Inclusions +SDL_INCLUDE = -IC:/dev/SDL2/x86_64-w64-mingw32/include/SDL2 +SDL_LIBRARY = -LC:/dev/SDL2/x86_64-w64-mingw32/lib +SDL_OPTIONS = -lSDL2main -lSDL2 +# SDL_OPTIONS = -lmingw32 -lSDL2main -lSDL2 + # Source files SRC_FILES = $(wildcard $(SRC_DIR)/**/*.cpp $(SRC_DIR)/*.cpp ) SRC_FILES_ = $(wildcard $(SRC_DIR)/*.cpp) @@ -37,11 +43,12 @@ TARGET = $(BIN_DIR)/game all: $(TARGET) $(TARGET): $(OBJ_FILES) - $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJ_FILES) + $(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJ_FILES) $(SDL_LIBRARY) $(SDL_OPTIONS) $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -I$(INC_DIR) -c -o $@ $< + $(CXX) $(CXXFLAGS) ${SDL_INCLUDE} -I$(INC_DIR) -c -o $@ $< +# $(CXX) $(CXXFLAGS) -I$(INC_DIR) -c -o $@ $< clean: rm -rf $(BIN_DIR)/* $(BUILD_DIR)/* test_runnr diff --git a/src/main.cpp b/src/main.cpp index 8dd269cf3782d6e20de7be928efa8e850c43396d..573b2b1f5932d6a3ab1a2f974d2a09ad75061058 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,9 @@ #include "main.h" -int main() { +int main( int argc, char* argv[] ) { + const uint16_t SCREEN_HEIGHT = 600; + const uint16_t SCREEN_WIDTH = 800; GameState state = Uninitialised; @@ -12,7 +14,17 @@ int main() { state = Initialise; // Seed the random number generator srand(static_cast<unsigned int>(time(nullptr))); - + + SDL_Window* window = NULL; + SDL_Surface* screenSurface = NULL; + + //Initialize SDL + //if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) + //{ + //// printf( "SDL could not initialize! SDL_Error: \n%s\n", SDL_GetError() ); + //} + window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); + // Genrate a Random chunk WorldHex2D map( 5 ); //Chunk* chunk = new Chunk( 0, 0, 0); @@ -51,3 +63,4 @@ int main() { logger.info( "Process Ending" ); return 0; } +// int /*WINAPI*/ WinMain(/*HINSTANCE hInstance, HINSTANCE, LPSTR, int*/) { main(); return 0; } diff --git a/src/save-manager.cpp b/src/save-manager.cpp index 3b280d0d64b132765701d6bf953cd7dd3d093f6c..19baa07b1cf404f20bf8498522b8da0dbdfaa714 100644 --- a/src/save-manager.cpp +++ b/src/save-manager.cpp @@ -48,7 +48,7 @@ void SaveManager::findSaves() for( const auto& entry : std::filesystem::directory_iterator( SAVE_LOCATION ) ) { - saves.push_back( SaveItem(entry.path().filename() ) ); + // saves.push_back( SaveItem(entry.path().filename() ) ); } this->saves = saves; }