diff --git a/README.md b/README.md index b7ee8be..523777a 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,23 @@ The game can do following: ## Compiling -Before compiling, you need to install both build suite (GCC/MSVC) with CMake and SDL2 libs. +Before compiling, you need to install both build suite (GCC/MSVC) with CMake and SDL2 libs: -TODO... +```shell +apt update +apt install build-essential cmake libsdl2-dev libsdl2-image-dev +``` + +Clone the repo with submodules updated and launch cmake to prepare compile: + +```shell +cd AST +mkdir build && cd build +cp -R ../data . +cmake .. +make +``` ## Running -Simply run the program with "data" folder 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. \ No newline at end of file diff --git a/src/arenaEngine.c b/src/arenaEngine.c index 358db01..328d171 100644 --- a/src/arenaEngine.c +++ b/src/arenaEngine.c @@ -3,12 +3,6 @@ #include #include "arenaEngine.h" -#ifdef _WIN32 - #define DATA_PATH(p) "data\\p" -#else - #define DATA_PATH(p) "data/p" -#endif - /* * Arena generate functions */ @@ -23,37 +17,39 @@ TILE *createTileList(void) { tile_5 = calloc(1,sizeof(TILE)); tile_0->type_id = 0; - tile_0->texture = IMG_Load(DATA_PATH("tile_grass.png")); + tile_0->texture = IMG_Load("data/tile_grass.png"); tile_0->canBeMined = 0; tile_0->isGround = 1; tile_0->nextTile = tile_1; + if (!tile_0->texture) addLogWarn("GRASS tex failed!"); + tile_1->type_id = 1; - tile_1->texture = IMG_Load(DATA_PATH("tile_rock.png")); + tile_1->texture = IMG_Load("data/tile_rock.png"); tile_1->canBeMined = 0; tile_1->isGround = 1; tile_1->nextTile = tile_2; tile_2->type_id = 2; - tile_2->texture = IMG_Load(DATA_PATH("tile_tree.png")); + tile_2->texture = IMG_Load("data/tile_tree.png"); tile_2->canBeMined = 0; tile_2->isGround = 0; tile_2->nextTile = tile_3; tile_3->type_id = 3; - tile_3->texture = IMG_Load(DATA_PATH("tile_water.png")); + 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_PATH("tile_gold.png")); + 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_PATH("tile_spawn.png")); + tile_5->texture = IMG_Load("data/tile_spawn.png"); tile_5->canBeMined = 0; tile_5->isGround = 1; tile_5->nextTile = NULL; @@ -73,10 +69,10 @@ PLAYER *createPlayerList(void) { p0->Id = 0; p0->PositionX = 0; p0->PositionY = 0; - p0->texture[DOWN] = IMG_Load(DATA_PATH("sprite_player_0.png")); - p0->texture[UP] = IMG_Load(DATA_PATH("sprite_player_1.png")); - p0->texture[LEFT] = IMG_Load(DATA_PATH("sprite_player_2.png")); - p0->texture[RIGHT] = IMG_Load(DATA_PATH("sprite_player_3.png")); + 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); @@ -110,10 +106,10 @@ PLAYER *createPlayerList(void) { p1->Id = 1; p1->PositionX = A_WIDTH-1; p1->PositionY = A_HEIGHT-1; - p1->texture[DOWN] = IMG_Load(DATA_PATH("sprite_ia_0.png")); - p1->texture[UP] = IMG_Load(DATA_PATH("sprite_ia_1.png")); - p1->texture[LEFT] = IMG_Load(DATA_PATH("sprite_ia_2.png")); - p1->texture[RIGHT] = IMG_Load(DATA_PATH("sprite_ia_3.png")); + 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; diff --git a/src/main.c b/src/main.c index 6f98dc6..80ed628 100644 --- a/src/main.c +++ b/src/main.c @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) { addLogInfo("Successfully created arena."); addLogInfo("Display arena GUI..."); + //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) {}