General upgrade to modern toolchain

> Conan v2 support ready
> SDL2 lib fix
> Both linux and windows patch
This commit is contained in:
JackCarterSmith 2024-03-16 11:18:01 +01:00
parent 42a2dc80e5
commit 65d8d93ce4
Signed by: JackCarterSmith
GPG Key ID: 832E52F4E23F8F24
16 changed files with 397 additions and 248 deletions

9
.gitignore vendored
View File

@ -61,6 +61,7 @@ CMakeLists.txt.user
CMakeCache.txt CMakeCache.txt
CMakeFiles CMakeFiles
CMakeScripts CMakeScripts
CMakeUserPresets.json
Testing Testing
Makefile Makefile
*.cmake *.cmake
@ -69,3 +70,11 @@ compile_commands.json
_deps _deps
.project .project
.vscode/
# Conan files
.vsconan/
conan.lock
conanbuildinfo.txt
conaninfo.txt
graph_info.json

View File

@ -1,15 +1,14 @@
# CMakeLists.txt # CMakeLists.txt
# Written by JackCarterSmith, 2021 # Written by JackCarterSmith, 2024
# This code is released under the AST license. # This file is released under the AST license.
cmake_minimum_required(VERSION 3.5.1) cmake_minimum_required(VERSION 3.10)
cmake_policy(VERSION 3.5.1) cmake_policy(VERSION 3.10)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
# define project # 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) project(AST VERSION 1.0.0 DESCRIPTION "Arena Survival Tournament" LANGUAGES C)
set(AST_NAME AST-${PROJECT_VERSION}) set(AST_NAME AST-${PROJECT_VERSION})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY) 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(FindPkgConfig)
include(CheckIncludeFile) include(CheckIncludeFile)
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
#include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
#conan_basic_setup()
# Find SDL2, SDL2_image and SDL2_gfx libraries # Find SDL2, SDL2_image and SDL2_gfx libraries
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR}) include_directories(SDL2::SDL2)
find_package(SDL2_image REQUIRED) find_package(SDL2_image REQUIRED)
include_directories(${SDL2_image_INCLUDE_DIR}) include_directories(SDL2_image::SDL2_image)
# define src/headers files # define src/headers files
@ -47,7 +44,12 @@ if(MSVC)
endif() endif()
# Link SDL2::Main, SDL2::Image and SDL2::GFX to our project # 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 executable

View File

@ -16,23 +16,21 @@ The game can do following and you can learn from that like we do when you create
## Compiling ## 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 ```shell
# For debian based distribution: # For debian based distribution:
apt update apt-get update
apt install build-essential cmake conan apt-get install build-essential cmake conan
``` ```
Clone the repo and launch in order conan and cmake in order to compile the program: Clone the repo and launch in order conan and cmake in order to compile the program:
```shell ```shell
cd AST conan install . --build=missing -s build_type=Release -pr:b=default
mkdir build && cd build cmake --preset release # or with '-G "MinGW Makefiles"/"Ninja"' if under Windows
cp -R ../data . cmake --build --preset release
conan install .. --build=missing cp -R data build/Release/.
cmake .. # or with '-G "MinGW Makefiles"' if under Windows
make
``` ```
## Running ## Running

68
conanfile.py Normal file
View File

@ -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)

View File

@ -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 -> .

BIN
pathfinder_algo_test.ods Normal file

Binary file not shown.

View File

@ -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; i++) {
for (j=0; j<A_HEIGHT; j++) {
// Build up the scan matrix
for (x=0; x<3; x++) {
for (y=0; y<3; y++) {
k = (i-1+x)<0 ? i-1+x : 0;
l = (j-1+y)<0 ? j-1+y : 0;
k = k>=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 //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 //Player 1 est le joueur, player 2 le bot
int action; 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 //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 = 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 //On vérifie si les 2 joueurs sont à côté pour attaquer
printf("Vérification position\n"); printf("Vérification position\n");
/*action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY); //action = FindShortestPath(player1->PositionX,player1->PositionY,player2->PositionX,player2->PositionY);
if(action == 5) //if(action == 5)
{ //{
AttackPlayer(player2,player1); // AttackPlayer(player2,player1);
}*/ //}
} }
return action; return action;
} }

View File

@ -1,6 +1,6 @@
#include "main.h" #include "main.h"
#include "arenaEngine.h" #include "arenaEngine.h"
#include <SDL.h> #include <SDL2/SDL.h>
#ifndef IAENGINE_H_ #ifndef IAENGINE_H_
#define IAENGINE_H_ #define IAENGINE_H_

View File

@ -3,198 +3,229 @@
#include <string.h> #include <string.h>
#include "arenaEngine.h" #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 *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)); // GRASS tile
tile_1 = calloc(1,sizeof(TILE)); tile_0 = createTile(id++,
tile_2 = calloc(1,sizeof(TILE)); "grass",
tile_3 = calloc(1,sizeof(TILE)); (TILE_CONFIG_GROUND),
tile_4 = calloc(1,sizeof(TILE)); NULL
tile_5 = calloc(1,sizeof(TILE)); );
tile_0->type_id = 0; // ROCK tile
tile_0->texture = IMG_Load("data/tile_grass.png"); tile_1 = createTile(id++,
tile_0->canBeMined = 0; "rock",
tile_0->isGround = 1; (TILE_CONFIG_GROUND),
tile_0->nextTile = tile_1; 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; // WATER tile
tile_1->texture = IMG_Load("data/tile_rock.png"); tile_3 = createTile(id++,
tile_1->canBeMined = 0; "water",
tile_1->isGround = 1; (TILE_CONFIG_NONE),
tile_1->nextTile = tile_2; tile_2
);
tile_2->type_id = 2; // GOLD tile
tile_2->texture = IMG_Load("data/tile_tree.png"); tile_4 = createTile(id++,
tile_2->canBeMined = 0; "gold",
tile_2->isGround = 0; (TILE_CONFIG_GROUND | TILE_CONFIG_MINEABLE),
tile_2->nextTile = tile_3; tile_3
);
tile_3->type_id = 3; // SPAWN tile
tile_3->texture = IMG_Load("data/tile_water.png"); tile_5 = createTile(id++,
tile_3->canBeMined = 0; "spawn",
tile_3->isGround = 0; (TILE_CONFIG_GROUND),
tile_3->nextTile = tile_4; 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;
return tile_0; return tile_0;
} }
PLAYER *createPlayerList(void) { 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; int race;
p0 = calloc(1,sizeof(PLAYER)); // Create the player instance
p1 = calloc(1,sizeof(PLAYER)); p0 = createPlayer(0, "player", 0, 0, NULL);
p2 = calloc(1,sizeof(PLAYER)); printf("Enter the player name: ");
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");
scanf("%s",p0->Name); scanf("%s",p0->Name);
do do
{ {
printf("Race? 1:Orc 2: Elf 3:Humain \n"); printf("1: Orc\n2: Elf\n3: Human\nRace? ");
scanf("%d",&race); scanf("%d",&race);
} while((race < 1) || (race > 3)); } 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);
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"); strcpy(p1->Name, "SKY-NUT");
p1->Race = random_lim(3)+1; setRaceToPlayer(p1, (random_lim(3)+1));
switch(race) //TODO
{ p2 = createPlayer(2, "ia", 0, (A_HEIGHT-1), p1);
//Race ORC p3 = createPlayer(3, "ia", (A_WIDTH-1), 0, p2);
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;
return p0; return p0;
} }
void clearRessourcesCache(TILE *t, PLAYER *p) { void clearRessourcesCache(TILE *t, PLAYER *p) {
PLAYER *p0 = NULL, *p1 = NULL, *p2 = NULL, *p3 = NULL; deleteAllPlayers(p);
TILE *tile_0 = NULL, *tile_1 = NULL, *tile_2 = NULL, *tile_3 = NULL, *tile_4 = NULL, *tile_5 = NULL; deleteAllTiles(t);
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);
} }
ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile) { ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile) {

View File

@ -1,6 +1,6 @@
#include "main.h" #include "main.h"
#include <SDL.h> #include <SDL2/SDL.h>
#include <SDL_image.h> #include <SDL2/SDL_image.h>
#include "fileHandler.h" #include "fileHandler.h"
#include "logHelper.h" #include "logHelper.h"
@ -8,6 +8,11 @@
#define ARENAENGINE_H_ #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{ typedef struct tileType{
int type_id; int type_id;

View File

@ -2,8 +2,8 @@
#include "arenaEngine.h" #include "arenaEngine.h"
#include "logHelper.h" #include "logHelper.h"
#include "IAEngine.h" #include "IAEngine.h"
#include <SDL.h> #include <SDL2/SDL.h>
#include <SDL_image.h> #include <SDL2/SDL_image.h>
//#include <SDL2/SDL_ttf.h> //#include <SDL2/SDL_ttf.h>
#ifndef ARENAGUI_H_ #ifndef ARENAGUI_H_

View File

@ -1,6 +1,6 @@
#include "main.h" #include "main.h"
#include <SDL.h> #include <SDL2/SDL.h>
#include <SDL_image.h> #include <SDL2/SDL_image.h>
#ifndef FILEHANDLER_H_ #ifndef FILEHANDLER_H_
#define FILEHANDLER_H_ #define FILEHANDLER_H_

View File

@ -3,11 +3,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include "logHelper.h" #include "logHelper.h"
#include <SDL.h> #include <SDL2/SDL.h>
#include <SDL_image.h> #include <SDL2/SDL_image.h>
//#include <SDL_ttf.h> //#include <SDL2/SDL_ttf.h>
//#include <SDL_thread.h> //#include <SDL2/SDL_thread.h>
//#include <SDL_mutex.h> //#include <SDL2/SDL_mutex.h>
#include "arenaEngine.h" #include "arenaEngine.h"
#include "arenaGUI.h" #include "arenaGUI.h"
#include "IAEngine.h" #include "IAEngine.h"
@ -30,17 +30,25 @@ int random_lim(int max) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
addLogInfo("Starting game..."); addLogInfo("Starting game");
srand(time(NULL)); srand(time(NULL));
addLogInfo("Try init SDL libs..."); addLogInfo("Try init SDL libs");
initDisplayLib(); initDisplayLib();
addLogInfo("Load ressources in memory..."); addLogInfo("Load resources in memory");
TILE *tile_ressources = createTileList(); TILE *tile_ressources = createTileList();
PLAYER *player_ressources = createPlayerList(); PLAYER *player_ressources = createPlayerList();
addLogInfo("Create SDL windows instance..."); // Create and display the arena view
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); 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..."); addLogInfo("Creating new arena...");
ARENA_H_TILE* arena = NULL; ARENA_H_TILE* arena = NULL;
@ -55,7 +63,7 @@ int main(int argc, char *argv[]) {
//IMG_Init(IMG_INIT_JPG & IMG_INIT_PNG); //IMG_Init(IMG_INIT_JPG & IMG_INIT_PNG);
displayArena(arena, gameWindows, tile_ressources, A_HEIGHT, A_WIDTH, TILE_SIZE); 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); SDL_DestroyWindow(gameWindows);
deleteArena(arena); deleteArena(arena);

View File

@ -11,8 +11,8 @@
/* /*
* Generator tiles spawn rate (in percent) * Generator tiles spawn rate (in percent)
*/ */
#define ROCK_GEN_RATE 28 #define ROCK_GEN_RATE 30
#define TREE_GEN_RATE 22 #define TREE_GEN_RATE 25
#define WATER_GEN_RATE 8 #define WATER_GEN_RATE 8
#define GOLD_GEN_RATE 10 #define GOLD_GEN_RATE 10

View File

@ -9,7 +9,14 @@ int createGameMenuWindows() {
} }
SDL_Window *main_test; 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_Delay(5000);
SDL_DestroyWindow(main_test); SDL_DestroyWindow(main_test);

View File

@ -1,8 +1,8 @@
#include <SDL.h> #include <SDL2/SDL.h>
#ifndef MENUGUI_H_ #ifndef MENUGUI_H_
#define MENUGUI_H_ #define MENUGUI_H_
int createGameMenuWindows();
#endif #endif