diff --git a/.gitignore b/.gitignore index fef25ea..0c7f655 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ CMakeLists.txt.user CMakeCache.txt CMakeFiles CMakeScripts +CMakeUserPresets.json Testing Makefile *.cmake @@ -69,3 +70,11 @@ compile_commands.json _deps .project +.vscode/ + +# Conan files +.vsconan/ +conan.lock +conanbuildinfo.txt +conaninfo.txt +graph_info.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 986d585..fa7161b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,14 @@ # CMakeLists.txt -# Written by JackCarterSmith, 2021 -# This code is released under the AST license. +# Written by JackCarterSmith, 2024 +# This file is released under the AST license. -cmake_minimum_required(VERSION 3.5.1) -cmake_policy(VERSION 3.5.1) +cmake_minimum_required(VERSION 3.10) +cmake_policy(VERSION 3.10) set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) # define project -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2) -set(APPEND CMAKE_EXE_LINKER_FLAGS -Wl,-subsystem,console) +#set(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,-subsystem,console") project(AST VERSION 1.0.0 DESCRIPTION "Arena Survival Tournament" LANGUAGES C) set(AST_NAME AST-${PROJECT_VERSION}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY) @@ -17,14 +16,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURC include(FindPkgConfig) include(CheckIncludeFile) include(CheckCSourceCompiles) -#include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -#conan_basic_setup() # Find SDL2, SDL2_image and SDL2_gfx libraries find_package(SDL2 REQUIRED) -include_directories(${SDL2_INCLUDE_DIR}) +include_directories(SDL2::SDL2) find_package(SDL2_image REQUIRED) -include_directories(${SDL2_image_INCLUDE_DIR}) +include_directories(SDL2_image::SDL2_image) # define src/headers files @@ -47,10 +44,15 @@ if(MSVC) endif() # Link SDL2::Main, SDL2::Image and SDL2::GFX to our project -target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2_image_LIBRARIES}) +if(MINGW) + # Override mingw32 lib order due to a failure in SDL conan recipe (can't link against WinMain) + target_link_libraries(${PROJECT_NAME} mingw32 SDL2::SDL2 SDL2_image::SDL2_image) +else() + target_link_libraries(${PROJECT_NAME} SDL2::SDL2 SDL2_image::SDL2_image) +endif() # install executable install(TARGETS AST RUNTIME DESTINATION bin -) \ No newline at end of file +) diff --git a/README.md b/README.md index 3e13dca..916ff36 100644 --- a/README.md +++ b/README.md @@ -16,25 +16,23 @@ The game can do following and you can learn from that like we do when you create ## Compiling -Before compiling, you need to install your favorite compiler (GCC or MSVC) with CMake and the lib manager Conan (https://conan.io): +Before compiling, you need to install your favorite compiler (GCC or MSVC) with CMake and the lib manager Conan>=1.59 (https://conan.io): ```shell # For debian based distribution: -apt update -apt install build-essential cmake conan +apt-get update +apt-get install build-essential cmake conan ``` Clone the repo and launch in order conan and cmake in order to compile the program: ```shell -cd AST -mkdir build && cd build -cp -R ../data . -conan install .. --build=missing -cmake .. # or with '-G "MinGW Makefiles"' if under Windows -make +conan install . --build=missing -s build_type=Release -pr:b=default +cmake --preset release # or with '-G "MinGW Makefiles"/"Ninja"' if under Windows +cmake --build --preset release +cp -R data build/Release/. ``` ## Running -Simply run the program with `data` folder (required) and `logs` folder (optional) or use the launch script. \ No newline at end of file +Simply run the program with `data` folder (required) and `logs` folder (optional) or use the launch script. diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..de64d9d --- /dev/null +++ b/conanfile.py @@ -0,0 +1,68 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import copy + +required_conan_version = ">=1.59" + +class AST(ConanFile): + name = "AST" + version = "0.4" + description = """Old school project + Turn based strategy game""" + license = "MIT" + author = "JackCarterSmith (j@jcsmith.fr)" + url = "https://git.jcsmith.fr/JCS-Prod/AST" + + package_type = "application" + revision_mode = "scm" + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeToolchain", "CMakeDeps" + +# default_options = { +# "shared": True +# } + + def configure(self): + self.options["sdl"].shared = True + self.options["sdl"].vulkan = False + self.options["sdl"].opengles = False + self.options["sdl"].iconv = False + self.options["sdl_image"].shared = True + self.options["sdl_image"].with_libjpeg = False + self.options["sdl_image"].with_libtiff = False + self.options["sdl_image"].with_libwebp = False + self.options["sdl_image"].lbm = False + self.options["sdl_image"].pcx = False + self.options["sdl_image"].pnm = False + self.options["sdl_image"].svg = False + self.options["sdl_image"].tga = False + self.options["sdl_image"].xcf = False + self.options["sdl_image"].xpm = False + self.options["sdl_image"].xv = False + + if self.settings.os == "Linux": + self.options["sdl"].wayland = False + self.options["sdl"].nas = True + + if self.settings.os == "Windows": + self.options["sdl"].directx = False + + def requirements(self): + self.requires("sdl/2.28.5", override=True) + self.requires("sdl_image/[>=2.6.3 <2.7]") + + def layout(self): + cmake_layout(self, src_folder='.', build_folder='build') + + def generate(self): + for dep in self.dependencies.values(): + if self.settings.os == "Windows": + copy(self, "*.dll", dep.cpp_info.bindirs[0], self.build_folder) + +# def package(self): +# copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) +# copy(self, pattern="*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) +# copy(self, pattern="*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) +# copy(self, pattern="*.so", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) +# copy(self, pattern="*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) +# copy(self, pattern="*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index 6718a18..0000000 --- a/conanfile.txt +++ /dev/null @@ -1,25 +0,0 @@ -[requires] -sdl/2.0.16 -sdl_image/2.0.5 - -[generators] -cmake -cmake_find_package - -[options] -sdl:shared=True -sdl_image:shared=True -sdl_image:with_libjpeg=False -sdl_image:with_libtiff=False -sdl_image:with_libwebp=False -sdl_image:lbm=False -sdl_image:pcx=False -sdl_image:pnm=False -sdl_image:svg=False -sdl_image:tga=False -sdl_image:xcf=False -sdl_image:xpm=False -sdl_image:xv=False - -[imports] -bin, *.dll -> . \ No newline at end of file diff --git a/pathfinder_algo_test.ods b/pathfinder_algo_test.ods new file mode 100644 index 0000000..96e01a0 Binary files /dev/null and b/pathfinder_algo_test.ods differ diff --git a/src/IAEngine.c b/src/IAEngine.c index c8bd87d..efaa924 100644 --- a/src/IAEngine.c +++ b/src/IAEngine.c @@ -162,29 +162,75 @@ int FindPath(ARENA_H_TILE *arena,PLAYER *player1, PLAYER *player2) } -int IAEngine(ARENA_H_TILE *arena,TILE *t_list,PLAYER *player1,PLAYER *player2) -{ +/* +static void refreshWMap(float map[A_WIDTH][A_HEIGHT]) { + int16_t i,j,k,l; + uint8_t x,y; + float ng_matrix[3][3]; + + for (i=0; i=A_WIDTH ? A_WIDTH-1 : k; + l = l>=A_HEIGHT ? A_HEIGHT-1 : l; + ng_matrix[x][y] = map[k][l]; + } + } + + newmap[i][j] = (0.25 * (ng_matrix[0][0]) + 0.5 * (ng_matrix[1][0]) + 0.25 * (ng_matrix[2][0]) + + 0.5 * (ng_matrix[0][1]) + 1.0 * (ng_matrix[1][1]) + 0.5 * (ng_matrix[2][1]) + + 0.25 * (ng_matrix[0][2]) + 0.5 * (ng_matrix[1][2]) + 0.25 * (ng_matrix[2][2])) / 9; + } + } +} +*/ + +int IAEngine(ARENA_H_TILE *arena, TILE *t_list, PLAYER *p1, PLAYER *p2) { + /* + //uint8_t windowSizeX, windowSizeY; + //uint8_t scanStartX, scanStartY; + float wMap[A_WIDTH][A_HEIGHT] = {0.0f}; + + // Set the max value on the player location + wMap[p1->PositionX][p1->PositionY] = 1.0f; + + // Compute the max scan window (for optimization) + //windowSizeX = abs(p2->PositionX - p1->PositionX); + //windowSizeY = abs(p2->PositionY - p1->PositionY); + */ + + + + + + + + //Fonction avec seulement 2 joueurs, voir la gestion quand il y a 2 IA supplémentaire //Player 1 est le joueur, player 2 le bot int action; - if((player1 != NULL) & (player2 !=NULL)) + if((p1 != NULL) && (p2 !=NULL)) { //On récupère les positions des 2 joueurs . L'IA sait où est le joueur //action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY); - action = FindPath(arena,player1,player2); + action = FindPath(arena, p1, p2); //On vérifie si les 2 joueurs sont à côté pour attaquer printf("Vérification position\n"); - /*action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY); - if(action == 5) - { - AttackPlayer(player2,player1); - }*/ + //action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY); + //if(action == 5) + //{ + // AttackPlayer(player2,player1); + //} } return action; } diff --git a/src/IAEngine.h b/src/IAEngine.h index b458332..5dc69d0 100644 --- a/src/IAEngine.h +++ b/src/IAEngine.h @@ -1,6 +1,6 @@ #include "main.h" #include "arenaEngine.h" -#include +#include #ifndef IAENGINE_H_ #define IAENGINE_H_ diff --git a/src/arenaEngine.c b/src/arenaEngine.c index 328d171..98af09d 100644 --- a/src/arenaEngine.c +++ b/src/arenaEngine.c @@ -3,198 +3,229 @@ #include #include "arenaEngine.h" -/* - * Arena generate functions - */ + +/* ======================================= TILES STUFF ======================================= */ + +static TILE *createTile(const int id, const char *img_name, const TILE_CONFIG config, TILE *prev) { + TILE *tile = NULL; + char imgPath[64] = {0}; + char logMess[64] = {0}; + + // Allocate a new tile in memory + tile = calloc(1,sizeof(TILE)); + if (tile == NULL) { + sprintf(logMess, "Adding tile ID %d failed!", id); + addLogWarn(logMess); + return tile; + } + + // Configure the tile + tile->type_id = id; + sprintf(imgPath, "data/tile_%s.png", img_name); + tile->texture = IMG_Load(imgPath); + tile->canBeMined = (config & TILE_CONFIG_MINEABLE); + tile->isGround = (config & TILE_CONFIG_GROUND); + tile->nextTile = NULL; + + if (!tile->texture) { + sprintf(logMess, "Adding texture for tile ID %d failed!", id); + addLogWarn(logMess); + return tile; + } + + // Link to the previous tile in list + if (prev) + prev->nextTile = tile; + + // Return the pointer to new allocated tile + return tile; +} + +static void deleteAllTiles(TILE *tileList) { + if (!tileList) return; + + if (tileList->nextTile) + deleteAllTiles(tileList->nextTile); + + if (tileList->texture) + SDL_FreeSurface(tileList->texture); + + free(tileList); +} + + +/* ======================================= PLAYERS STUFF ======================================= */ + +static PLAYER *createPlayer(const int id, const char *img_name, int sPosX, int sPosY, PLAYER *prev) { + PLAYER *p = NULL; + char imgPath[64] = {0}; + char logMess[64] = {0}; + + // Allocate a new player in memory + p = calloc(1,sizeof(PLAYER)); + if (p == NULL) { + sprintf(logMess, "Adding player ID %d failed!", id); + addLogWarn(logMess); + return p; + } + + // Configure the player + p->Id = id; + p->PositionX = sPosX; + p->PositionY = sPosY; + sprintf(imgPath, "data/sprite_%s_0.png", img_name); + p->texture[DOWN] = IMG_Load(imgPath); + sprintf(imgPath, "data/sprite_%s_1.png", img_name); + p->texture[UP] = IMG_Load(imgPath); + sprintf(imgPath, "data/sprite_%s_2.png", img_name); + p->texture[LEFT] = IMG_Load(imgPath); + sprintf(imgPath, "data/sprite_%s_3.png", img_name); + p->texture[RIGHT] = IMG_Load(imgPath); + + if (!p->texture[DOWN] || !p->texture[UP] || !p->texture[LEFT] || !p->texture[RIGHT]) { + sprintf(logMess, "Adding texture for player ID %d failed!", id); + addLogWarn(logMess); + return p; + } + + // Link to the previous player in list + if (prev) + prev->suiv = p; + + // Return the pointer to new allocated tile + return p; +} + +static void deleteAllPlayers(PLAYER *pList) { + if (!pList) return; + + if (pList->suiv) + deleteAllPlayers(pList->suiv); + + if (pList->texture[RIGHT]) + SDL_FreeSurface(pList->texture[RIGHT]); + if (pList->texture[LEFT]) + SDL_FreeSurface(pList->texture[LEFT]); + if (pList->texture[UP]) + SDL_FreeSurface(pList->texture[UP]); + if (pList->texture[DOWN]) + SDL_FreeSurface(pList->texture[DOWN]); + + free(pList); +} + + + +/* ======================================= ARENA GLOBAL FUNCTIONS ======================================= */ + +static void setRaceToPlayer(PLAYER *p, int race_id) { + p->Race = race_id; + switch(race_id) { + //Race ORC + case 1: p->HealthPoints = 100; + p->AttacksPoints = 10; + break; + + //Race Elfe + case 2: p->HealthPoints = 80; + p->AttacksPoints = 9; + break; + + //Race Humaine + default: + case 3: p->HealthPoints = 90; + p->AttacksPoints = 9; + } +} + TILE *createTileList(void) { - TILE *tile_0 = NULL, *tile_1 = NULL, *tile_2 = NULL, *tile_3 = NULL, *tile_4 = NULL, *tile_5 = NULL; + uint16_t id = 0; + TILE *tile_0 = NULL; + TILE *tile_1 = NULL; + TILE *tile_2 = NULL; + TILE *tile_3 = NULL; + TILE *tile_4 = NULL; + TILE *tile_5 = NULL; - tile_0 = calloc(1,sizeof(TILE)); - tile_1 = calloc(1,sizeof(TILE)); - tile_2 = calloc(1,sizeof(TILE)); - tile_3 = calloc(1,sizeof(TILE)); - tile_4 = calloc(1,sizeof(TILE)); - tile_5 = calloc(1,sizeof(TILE)); + // GRASS tile + tile_0 = createTile(id++, + "grass", + (TILE_CONFIG_GROUND), + NULL + ); - tile_0->type_id = 0; - tile_0->texture = IMG_Load("data/tile_grass.png"); - tile_0->canBeMined = 0; - tile_0->isGround = 1; - tile_0->nextTile = tile_1; + // ROCK tile + tile_1 = createTile(id++, + "rock", + (TILE_CONFIG_GROUND), + tile_0 + ); - if (!tile_0->texture) addLogWarn("GRASS tex failed!"); + // TREE tile + tile_2 = createTile(id++, + "tree", + (TILE_CONFIG_NONE), + tile_1 + ); - tile_1->type_id = 1; - tile_1->texture = IMG_Load("data/tile_rock.png"); - tile_1->canBeMined = 0; - tile_1->isGround = 1; - tile_1->nextTile = tile_2; + // WATER tile + tile_3 = createTile(id++, + "water", + (TILE_CONFIG_NONE), + tile_2 + ); - tile_2->type_id = 2; - tile_2->texture = IMG_Load("data/tile_tree.png"); - tile_2->canBeMined = 0; - tile_2->isGround = 0; - tile_2->nextTile = tile_3; + // GOLD tile + tile_4 = createTile(id++, + "gold", + (TILE_CONFIG_GROUND | TILE_CONFIG_MINEABLE), + tile_3 + ); - tile_3->type_id = 3; - tile_3->texture = IMG_Load("data/tile_water.png"); - tile_3->canBeMined = 0; - tile_3->isGround = 0; - tile_3->nextTile = tile_4; - - tile_4->type_id = 4; - tile_4->texture = IMG_Load("data/tile_gold.png"); - tile_4->canBeMined = 1; - tile_4->isGround = 1; - tile_4->nextTile = tile_5; - - tile_5->type_id = 5; - tile_5->texture = IMG_Load("data/tile_spawn.png"); - tile_5->canBeMined = 0; - tile_5->isGround = 1; - tile_5->nextTile = NULL; + // SPAWN tile + tile_5 = createTile(id++, + "spawn", + (TILE_CONFIG_GROUND), + tile_4 + ); return tile_0; } PLAYER *createPlayerList(void) { - PLAYER *p0 = NULL, *p1 = NULL, *p2 = NULL, *p3 = NULL; + PLAYER *p0 = NULL; + PLAYER *p1 = NULL; + PLAYER *p2 = NULL; + PLAYER *p3 = NULL; int race; - p0 = calloc(1,sizeof(PLAYER)); - p1 = calloc(1,sizeof(PLAYER)); - p2 = calloc(1,sizeof(PLAYER)); - p3 = calloc(1,sizeof(PLAYER)); - - p0->Id = 0; - p0->PositionX = 0; - p0->PositionY = 0; - p0->texture[DOWN] = IMG_Load("data/sprite_player_0.png"); - p0->texture[UP] = IMG_Load("data/sprite_player_1.png"); - p0->texture[LEFT] = IMG_Load("data/sprite_player_2.png"); - p0->texture[RIGHT] = IMG_Load("data/sprite_player_3.png"); - p0->suiv = p1; - printf("Entrer le nom du joueur\n"); + // Create the player instance + p0 = createPlayer(0, "player", 0, 0, NULL); + printf("Enter the player name: "); scanf("%s",p0->Name); do { - printf("Race? 1:Orc 2: Elf 3:Humain \n"); + printf("1: Orc\n2: Elf\n3: Human\nRace? "); scanf("%d",&race); } while((race < 1) || (race > 3)); + setRaceToPlayer(p0, race); - p0->Race = race; + // Create the AI instance + p1 = createPlayer(1, "ia", (A_WIDTH-1), (A_HEIGHT-1), p0); + strcpy(p1->Name, "SKY-NUT"); + setRaceToPlayer(p1, (random_lim(3)+1)); - switch(race) - { - //Race ORC - case 1: p0->HealthPoints = 100; - p0->AttacksPoints = 10; - break; - - //Race Elfe - case 2: p0->HealthPoints = 80; - p0->AttacksPoints = 9; - break; - - //Race Humaine - case 3: p0->HealthPoints = 90; - p0->AttacksPoints = 9; - break; - } - - p1->Id = 1; - p1->PositionX = A_WIDTH-1; - p1->PositionY = A_HEIGHT-1; - p1->texture[DOWN] = IMG_Load("data/sprite_ia_0.png"); - p1->texture[UP] = IMG_Load("data/sprite_ia_1.png"); - p1->texture[LEFT] = IMG_Load("data/sprite_ia_2.png"); - p1->texture[RIGHT] = IMG_Load("data/sprite_ia_3.png"); - p1->suiv = p2; - strcpy(p1->Name,"SKY-NUT"); - p1->Race = random_lim(3)+1; - - switch(race) - { - //Race ORC - case 1: p1->HealthPoints = 100; - p1->AttacksPoints = 10; - break; - - //Race Elfe - case 2: p1->HealthPoints = 80; - p1->AttacksPoints = 9; - break; - - //Race Humaine - case 3: p1->HealthPoints = 90; - p1->AttacksPoints = 9; - break; - } - - p2->Id = 0; - p2->PositionX = 0; - p2->PositionY = A_HEIGHT; - //p2->texture[DOWN] = IMG_Load("data/sprite_player_0.png"); - //p2->texture[UP] = IMG_Load("data/sprite_player_1.png"); - //p2->texture[LEFT] = IMG_Load("data/sprite_player_2.png"); - //p2->texture[RIGHT] = IMG_Load("data/sprite_player_3.png"); - p2->suiv = p3; - - p3->Id = 0; - p3->PositionX = A_WIDTH; - p3->PositionY = 0; - //p3->texture[DOWN] = IMG_Load("data/sprite_player_0.png"); - //p3->texture[UP] = IMG_Load("data/sprite_player_1.png"); - //p3->texture[LEFT] = IMG_Load("data/sprite_player_2.png"); - //p3->texture[RIGHT] = IMG_Load("data/sprite_player_3.png"); - p3->suiv = NULL; + //TODO + p2 = createPlayer(2, "ia", 0, (A_HEIGHT-1), p1); + p3 = createPlayer(3, "ia", (A_WIDTH-1), 0, p2); return p0; } void clearRessourcesCache(TILE *t, PLAYER *p) { - PLAYER *p0 = NULL, *p1 = NULL, *p2 = NULL, *p3 = NULL; - TILE *tile_0 = NULL, *tile_1 = NULL, *tile_2 = NULL, *tile_3 = NULL, *tile_4 = NULL, *tile_5 = NULL; - int i; - - p0 = p; - p1 = p0->suiv; - p2 = p1->suiv; - p3 = p2->suiv; - - tile_0 = t; - tile_1 = tile_0->nextTile; - tile_2 = tile_1->nextTile; - tile_3 = tile_2->nextTile; - tile_4 = tile_3->nextTile; - tile_5 = tile_4->nextTile; - - for (i=0;i<=3;i++) { - SDL_FreeSurface(p0->texture[i]); - } - for (i=0;i<=3;i++) { - SDL_FreeSurface(p1->texture[i]); - } - /* - for (i=0;i<=3;i++) { - SDL_FreeSurface(p2->texture[i]); - } - for (i=0;i<=3;i++) { - SDL_FreeSurface(p3->texture[i]); - } - */ - - free(p3);free(p2);free(p1);free(p0); - - SDL_FreeSurface(tile_0->texture); - SDL_FreeSurface(tile_1->texture); - SDL_FreeSurface(tile_2->texture); - SDL_FreeSurface(tile_3->texture); - SDL_FreeSurface(tile_4->texture); - SDL_FreeSurface(tile_5->texture); - - free(tile_0);free(tile_1);free(tile_2);free(tile_3);free(tile_4);free(tile_5); + deleteAllPlayers(p); + deleteAllTiles(t); } ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile) { diff --git a/src/arenaEngine.h b/src/arenaEngine.h index e2c88e8..4cfa801 100644 --- a/src/arenaEngine.h +++ b/src/arenaEngine.h @@ -1,6 +1,6 @@ #include "main.h" -#include -#include +#include +#include #include "fileHandler.h" #include "logHelper.h" @@ -8,6 +8,11 @@ #define ARENAENGINE_H_ +typedef uint8_t TILE_CONFIG; +#define TILE_CONFIG_NONE (0x0) +#define TILE_CONFIG_MINEABLE (0x1) +#define TILE_CONFIG_GROUND (0x2) + typedef struct tileType{ int type_id; @@ -15,7 +20,7 @@ typedef struct tileType{ int isGround; int canBeMined; struct tileType *nextTile; -}TILE; +} TILE; typedef struct Player { @@ -37,20 +42,20 @@ typedef struct Player struct Player * suiv; -}PLAYER; +} PLAYER; typedef struct arena_h_tile{ //Rows chained list int type_id; //PLAYER* playerOnTile; struct arena_h_tile *nextRow; struct arena_w_tile *nextColumn; -}ARENA_H_TILE; +} ARENA_H_TILE; typedef struct arena_w_tile{ //Columns chained list int type_id; //PLAYER* playerOnTile; struct arena_w_tile *nextColumn; -}ARENA_W_TILE; +} ARENA_W_TILE; //Generation functions diff --git a/src/arenaGUI.h b/src/arenaGUI.h index 56e67aa..8f53145 100644 --- a/src/arenaGUI.h +++ b/src/arenaGUI.h @@ -2,8 +2,8 @@ #include "arenaEngine.h" #include "logHelper.h" #include "IAEngine.h" -#include -#include +#include +#include //#include #ifndef ARENAGUI_H_ diff --git a/src/fileHandler.h b/src/fileHandler.h index 63d44d7..c7fca1b 100644 --- a/src/fileHandler.h +++ b/src/fileHandler.h @@ -1,6 +1,6 @@ #include "main.h" -#include -#include +#include +#include #ifndef FILEHANDLER_H_ #define FILEHANDLER_H_ diff --git a/src/main.c b/src/main.c index 80ed628..fdced49 100644 --- a/src/main.c +++ b/src/main.c @@ -3,11 +3,11 @@ #include #include #include "logHelper.h" -#include -#include -//#include -//#include -//#include +#include +#include +//#include +//#include +//#include #include "arenaEngine.h" #include "arenaGUI.h" #include "IAEngine.h" @@ -30,17 +30,25 @@ int random_lim(int max) { int main(int argc, char *argv[]) { - addLogInfo("Starting game..."); + addLogInfo("Starting game"); srand(time(NULL)); - addLogInfo("Try init SDL libs..."); + addLogInfo("Try init SDL libs"); initDisplayLib(); - addLogInfo("Load ressources in memory..."); + addLogInfo("Load resources in memory"); TILE *tile_ressources = createTileList(); PLAYER *player_ressources = createPlayerList(); - addLogInfo("Create SDL windows instance..."); - SDL_Window* gameWindows = SDL_CreateWindow("Arena Survival Tournament - alpha 0.3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOWS_WIDTH, WINDOWS_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); + // Create and display the arena view + addLogInfo("Create SDL windows instance"); + SDL_Window* gameWindows = SDL_CreateWindow( + "Arena Survival Tournament - r4", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + WINDOWS_WIDTH, + WINDOWS_HEIGHT, + (SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS) + ); addLogInfo("Creating new arena..."); ARENA_H_TILE* arena = NULL; @@ -55,7 +63,7 @@ int main(int argc, char *argv[]) { //IMG_Init(IMG_INIT_JPG & IMG_INIT_PNG); displayArena(arena, gameWindows, tile_ressources, A_HEIGHT, A_WIDTH, TILE_SIZE); - while (updateArena(gameWindows,arena,tile_ressources,player_ressources)!=0) {} + while (!updateArena(gameWindows,arena,tile_ressources,player_ressources)) {} SDL_DestroyWindow(gameWindows); deleteArena(arena); diff --git a/src/main.h b/src/main.h index 5fd73ad..f5a39a8 100644 --- a/src/main.h +++ b/src/main.h @@ -11,8 +11,8 @@ /* * Generator tiles spawn rate (in percent) */ -#define ROCK_GEN_RATE 28 -#define TREE_GEN_RATE 22 +#define ROCK_GEN_RATE 30 +#define TREE_GEN_RATE 25 #define WATER_GEN_RATE 8 #define GOLD_GEN_RATE 10 diff --git a/src/menuGUI.c b/src/menuGUI.c index 97013cf..64938dc 100644 --- a/src/menuGUI.c +++ b/src/menuGUI.c @@ -9,7 +9,14 @@ int createGameMenuWindows() { } SDL_Window *main_test; - main_test = SDL_CreateWindow("My test windows", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 140, SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS); + main_test = SDL_CreateWindow( + "My test windows", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 320, + 140, + (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS) + ); SDL_Delay(5000); SDL_DestroyWindow(main_test); diff --git a/src/menuGUI.h b/src/menuGUI.h index fe55a7d..122cae7 100644 --- a/src/menuGUI.h +++ b/src/menuGUI.h @@ -1,8 +1,8 @@ -#include +#include #ifndef MENUGUI_H_ #define MENUGUI_H_ - +int createGameMenuWindows(); #endif