Finished arena generator
- fixed some seg fault - add security to func
This commit is contained in:
parent
e891ab880e
commit
64fa16d2fd
@ -38,7 +38,7 @@ PROJECT_NAME = ArenaSurvivalTournament
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = alpha0.2
|
PROJECT_NUMBER = alpha1.0
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
@ -453,7 +453,7 @@ EXTRACT_PACKAGE = NO
|
|||||||
# included in the documentation.
|
# included in the documentation.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
EXTRACT_STATIC = YES
|
EXTRACT_STATIC = NO
|
||||||
|
|
||||||
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
|
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
|
||||||
# locally in source files will be included in the documentation. If set to NO,
|
# locally in source files will be included in the documentation. If set to NO,
|
||||||
@ -1592,7 +1592,7 @@ MATHJAX_CODEFILE =
|
|||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
SEARCHENGINE = NO
|
SEARCHENGINE = YES
|
||||||
|
|
||||||
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
|
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
|
||||||
# implemented using a web server instead of a web client using Javascript. There
|
# implemented using a web server instead of a web client using Javascript. There
|
||||||
@ -1666,7 +1666,7 @@ EXTRA_SEARCH_MAPPINGS =
|
|||||||
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
|
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
|
||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
|
|
||||||
GENERATE_LATEX = NO
|
GENERATE_LATEX = YES
|
||||||
|
|
||||||
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
|
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
|
||||||
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
|
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
|
||||||
@ -1776,7 +1776,7 @@ LATEX_EXTRA_FILES =
|
|||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||||
|
|
||||||
PDF_HYPERLINKS = YES
|
PDF_HYPERLINKS = NO
|
||||||
|
|
||||||
# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
|
# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
|
||||||
# the PDF file directly from the LaTeX files. Set this option to YES, to get a
|
# the PDF file directly from the LaTeX files. Set this option to YES, to get a
|
||||||
@ -1784,7 +1784,7 @@ PDF_HYPERLINKS = YES
|
|||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||||
|
|
||||||
USE_PDFLATEX = YES
|
USE_PDFLATEX = NO
|
||||||
|
|
||||||
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
|
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
|
||||||
# command to the generated LaTeX files. This will instruct LaTeX to keep running
|
# command to the generated LaTeX files. This will instruct LaTeX to keep running
|
||||||
|
111
arenaEngine.c
111
arenaEngine.c
@ -9,13 +9,14 @@
|
|||||||
* Arena generate functions
|
* Arena generate functions
|
||||||
*/
|
*/
|
||||||
TILE *createTileList(void) {
|
TILE *createTileList(void) {
|
||||||
TILE *tile_0 = NULL, *tile_1 = NULL, *tile_2 = NULL, *tile_3 = NULL, *tile_4 = NULL;
|
TILE *tile_0 = NULL, *tile_1 = NULL, *tile_2 = NULL, *tile_3 = NULL, *tile_4 = NULL, *tile_5 = NULL;
|
||||||
|
|
||||||
tile_0 = calloc(1,sizeof(TILE));
|
tile_0 = calloc(1,sizeof(TILE));
|
||||||
tile_1 = calloc(1,sizeof(TILE));
|
tile_1 = calloc(1,sizeof(TILE));
|
||||||
tile_2 = calloc(1,sizeof(TILE));
|
tile_2 = calloc(1,sizeof(TILE));
|
||||||
tile_3 = calloc(1,sizeof(TILE));
|
tile_3 = calloc(1,sizeof(TILE));
|
||||||
tile_4 = calloc(1,sizeof(TILE));
|
tile_4 = calloc(1,sizeof(TILE));
|
||||||
|
tile_5 = calloc(1,sizeof(TILE));
|
||||||
|
|
||||||
tile_0->type_id = 0;
|
tile_0->type_id = 0;
|
||||||
tile_0->texture = IMG_Load("data/tile_grass.png");
|
tile_0->texture = IMG_Load("data/tile_grass.png");
|
||||||
@ -45,7 +46,13 @@ TILE *createTileList(void) {
|
|||||||
tile_4->texture = IMG_Load("data/tile_gold.png");
|
tile_4->texture = IMG_Load("data/tile_gold.png");
|
||||||
tile_4->canBeMined = 1;
|
tile_4->canBeMined = 1;
|
||||||
tile_4->isGround = 1;
|
tile_4->isGround = 1;
|
||||||
tile_4->nextTile = NULL;
|
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;
|
||||||
}
|
}
|
||||||
@ -98,7 +105,47 @@ PLAYER *createPlayerList(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clearRessourcesCache(TILE *t, PLAYER *p) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile) {
|
ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile) {
|
||||||
@ -200,7 +247,7 @@ ARENA_H_TILE* genNewArena(int size_h, int size_w) {
|
|||||||
int z,i,j,rand_x,rand_y;
|
int z,i,j,rand_x,rand_y;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate flatgrass arena
|
* Generate new flatgrass arena
|
||||||
*/
|
*/
|
||||||
for(i=0;i<=size_h;i++){
|
for(i=0;i<=size_h;i++){
|
||||||
if (i==0) {
|
if (i==0) {
|
||||||
@ -225,14 +272,14 @@ ARENA_H_TILE* genNewArena(int size_h, int size_w) {
|
|||||||
* Generate some rock area
|
* Generate some rock area
|
||||||
*/
|
*/
|
||||||
for (z=1; z <= A_WIDTH * A_HEIGHT * ROCK_GEN_RATE/100; z++) {
|
for (z=1; z <= A_WIDTH * A_HEIGHT * ROCK_GEN_RATE/100; z++) {
|
||||||
rand_x = random_lim(A_WIDTH+1)-1;
|
rand_x = random_lim(A_WIDTH)-1;
|
||||||
rand_y = random_lim(A_HEIGHT+1)-1;
|
rand_y = random_lim(A_HEIGHT)-1;
|
||||||
|
|
||||||
for (i=-2;i<=1;i++) {
|
for (i=-2;i<=1;i++) {
|
||||||
for (j=-1;j<=3;j++) {
|
for (j=-1;j<=3;j++) {
|
||||||
if (random_lim(101) < 65) {
|
if (random_lim(101) < 65) {
|
||||||
if ((rand_x + i >= 0 && rand_x + i <= A_WIDTH) || (rand_y + i <= 0 && rand_y + i <= A_HEIGHT)) {
|
if (((rand_x + i) >= 0 && (rand_x + i) < A_WIDTH) && ((rand_y + j) >= 0 && (rand_y + j) < A_HEIGHT)) {
|
||||||
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, ROCK)!=0) addLogCritical("Rock failed to add on arena."); else z++;
|
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, ROCK)!=0) addLogWarn("Failed to add rock on arena."); else z++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,14 +290,14 @@ ARENA_H_TILE* genNewArena(int size_h, int size_w) {
|
|||||||
* Generate some tree area on grass
|
* Generate some tree area on grass
|
||||||
*/
|
*/
|
||||||
for (z=1; z <= A_WIDTH * A_HEIGHT * TREE_GEN_RATE/100; z++) {
|
for (z=1; z <= A_WIDTH * A_HEIGHT * TREE_GEN_RATE/100; z++) {
|
||||||
rand_x = random_lim(A_WIDTH+1)-1;
|
rand_x = random_lim(A_WIDTH)-1;
|
||||||
rand_y = random_lim(A_HEIGHT+1)-1;
|
rand_y = random_lim(A_HEIGHT)-1;
|
||||||
|
|
||||||
for (i=-2;i<=2;i++) {
|
for (i=-2;i<=2;i++) {
|
||||||
for (j=-2;j<=2;j++) {
|
for (j=-2;j<=2;j++) {
|
||||||
if (random_lim(101) < 65) {
|
if (random_lim(101) < 65) {
|
||||||
if (((rand_x + i >= 0 && rand_x + i <= A_WIDTH) || (rand_y + i <= 0 && rand_y + i <= A_HEIGHT)) && getTileTypeID(arenaOrigin, rand_x+i, rand_y+j) == GRASS) {
|
if (((rand_x + i >= 0 && rand_x + i < A_WIDTH) && (rand_y + j >= 0 && rand_y + j < A_HEIGHT)) && getTileTypeID(arenaOrigin, rand_x+i, rand_y+j) == GRASS) {
|
||||||
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, TREE)!=0) addLogCritical("Tree failed to add on arena."); else z++;
|
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, TREE)!=0) addLogWarn("Failed to tree add on arena."); else z++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,11 +308,11 @@ ARENA_H_TILE* genNewArena(int size_h, int size_w) {
|
|||||||
* Generate some gold area on rock
|
* Generate some gold area on rock
|
||||||
*/
|
*/
|
||||||
for (z=1; z <= A_WIDTH * A_HEIGHT * GOLD_GEN_RATE/100; z++) {
|
for (z=1; z <= A_WIDTH * A_HEIGHT * GOLD_GEN_RATE/100; z++) {
|
||||||
rand_x = random_lim(A_WIDTH+1)-1;
|
rand_x = random_lim(A_WIDTH)-1;
|
||||||
rand_y = random_lim(A_HEIGHT+1)-1;
|
rand_y = random_lim(A_HEIGHT)-1;
|
||||||
|
|
||||||
if (((rand_x + i >= 0 && rand_x + i <= A_WIDTH) || (rand_y + i <= 0 && rand_y + i <= A_HEIGHT)) && getTileTypeID(arenaOrigin, rand_x+i, rand_y+j) == ROCK) {
|
if (((rand_x + i >= 0 && rand_x + i <= A_WIDTH) && (rand_y + j >= 0 && rand_y + j <= A_HEIGHT)) && getTileTypeID(arenaOrigin, rand_x+i, rand_y+j) == ROCK) {
|
||||||
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, GOLD)!=0) addLogCritical("Tree failed to add on arena."); else z++;
|
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, GOLD)!=0) addLogWarn("Failed to add gold on arena."); else z++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,26 +320,42 @@ ARENA_H_TILE* genNewArena(int size_h, int size_w) {
|
|||||||
* Generate some water area on grass
|
* Generate some water area on grass
|
||||||
*/
|
*/
|
||||||
for (z=1; z <= A_WIDTH * A_HEIGHT * WATER_GEN_RATE/100; z++) {
|
for (z=1; z <= A_WIDTH * A_HEIGHT * WATER_GEN_RATE/100; z++) {
|
||||||
rand_x = random_lim(A_WIDTH+1)-1;
|
rand_x = random_lim(A_WIDTH)-1;
|
||||||
rand_y = random_lim(A_HEIGHT+1)-1;
|
rand_y = random_lim(A_HEIGHT)-1;
|
||||||
|
|
||||||
for (i=-3;i<=3;i++) {
|
for (i=-2;i<=2;i++) {
|
||||||
for (j=-3;j<=3;j++) {
|
for (j=-3;j<=3;j++) {
|
||||||
if (i >= -1 && j >= -1 && i <= 1 && j <= 1) {
|
if (i >= -1 && j >= -1 && i <= 1 && j <= 1) {
|
||||||
if ((rand_x + i >= 0 && rand_x + i <= A_WIDTH) || (rand_y + i <= 0 && rand_y + i <= A_HEIGHT)) {
|
if (((rand_x + i) >= 0 && (rand_x + i) < A_WIDTH) && ((rand_y + j) >= 0 && (rand_y + j) < A_HEIGHT)) {
|
||||||
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, WATER)!=0) addLogCritical("Tree failed to add on arena."); else z++;
|
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, WATER)!=0) {
|
||||||
|
addLogWarn("Failed to add water on arena.");
|
||||||
|
}else z++;
|
||||||
}
|
}
|
||||||
} else if (i < -1 && j < -1 && i > 1 && j > 1) {
|
} /*else {
|
||||||
if (random_lim(101) < 60) {
|
if (random_lim(101) < 60) {
|
||||||
if ((rand_x + i >= 0 && rand_x + i <= A_WIDTH) || (rand_y + i <= 0 && rand_y + i <= A_HEIGHT)) {
|
if ((rand_x + i >= 0 && rand_x + i <= A_WIDTH) && (rand_y + i >= 0 && rand_y + i <= A_HEIGHT)) {
|
||||||
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, WATER)!=0) addLogCritical("Tree failed to add on arena."); else z++;
|
if(setTileTypeID(arenaOrigin, rand_x+i, rand_y+j, WATER)!=0) addLogWarn("Tree failed to add on arena."); else z++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generate spawn
|
||||||
|
*/
|
||||||
|
for (z=0; z <= 1; z++) {
|
||||||
|
if(setTileTypeID(arenaOrigin, 0+z, 0, SPAWN)!=0) addLogWarn("Failed to add spawn area up left corner");
|
||||||
|
if(setTileTypeID(arenaOrigin, 0, 0+z, SPAWN)!=0) addLogWarn("Failed to add spawn area up left corner");
|
||||||
|
if(setTileTypeID(arenaOrigin, 0+z, 0+z, SPAWN)!=0) addLogWarn("Failed to add spawn area up left corner");
|
||||||
|
}
|
||||||
|
for (z=0; z <= 1; z++) {
|
||||||
|
if(setTileTypeID(arenaOrigin, A_WIDTH-1-z, A_HEIGHT-1, SPAWN)!=0) addLogWarn("Failed to add spawn area botton right corner");
|
||||||
|
if(setTileTypeID(arenaOrigin, A_WIDTH-1, A_HEIGHT-1-z, SPAWN)!=0) addLogWarn("Failed to add spawn area botton right corner");
|
||||||
|
if(setTileTypeID(arenaOrigin, A_WIDTH-1-z, A_HEIGHT-1-z, SPAWN)!=0) addLogWarn("Failed to add spawn area botton right corner");
|
||||||
|
}
|
||||||
|
|
||||||
return arenaOrigin;
|
return arenaOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
data/tile_spawn.png
Normal file
BIN
data/tile_spawn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.9 KiB |
@ -12,7 +12,7 @@ int initialise_logger(){
|
|||||||
time(&raw_time);
|
time(&raw_time);
|
||||||
pdh = localtime(&raw_time);
|
pdh = localtime(&raw_time);
|
||||||
char name[32];
|
char name[32];
|
||||||
sprintf(name, "%04d-%02d-%02d.log", pdh->tm_year+1900, pdh->tm_mon+1, pdh->tm_mday);
|
sprintf(name, "logs/%04d-%02d-%02d.log", pdh->tm_year+1900, pdh->tm_mon+1, pdh->tm_mday);
|
||||||
log_file=fopen(name, "a");
|
log_file=fopen(name, "a");
|
||||||
|
|
||||||
if(log_file==NULL) //fichier innexistant
|
if(log_file==NULL) //fichier innexistant
|
||||||
|
10
logs/2018-06-23.log
Normal file
10
logs/2018-06-23.log
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[INFO][09:34:17] Starting game...
|
||||||
|
[INFO][09:34:17] Try init SDL libs...
|
||||||
|
[INFO][09:34:17] Load ressources in memory...
|
||||||
|
[INFO][09:34:17] Create SDL windows instance...
|
||||||
|
[INFO][09:34:17] Creating new arena...
|
||||||
|
[INFO][09:34:17] Successfully created arena.
|
||||||
|
[INFO][09:34:17] Display arena GUI...
|
||||||
|
[INFO][09:34:21] Cleared arena.
|
||||||
|
[INFO][09:34:21] Free ressources.
|
||||||
|
[INFO][09:34:21] Unload SDL libs...
|
28
main.c
28
main.c
@ -10,7 +10,7 @@
|
|||||||
//#include <SDL2/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"
|
||||||
#include "playerInterface.h"
|
#include "playerInterface.h"
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ int random_lim(int max) {
|
|||||||
return r / d;
|
return r / d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
addLogInfo("Starting game...");
|
addLogInfo("Starting game...");
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
@ -38,28 +39,9 @@ int main(int argc, char *argv[]) {
|
|||||||
addLogInfo("Load ressources in memory...");
|
addLogInfo("Load ressources in memory...");
|
||||||
TILE *tile_ressources = createTileList();
|
TILE *tile_ressources = createTileList();
|
||||||
PLAYER *player_ressources = createPlayerList();
|
PLAYER *player_ressources = createPlayerList();
|
||||||
/*
|
|
||||||
SDL_Surface *tile_grass = NULL, *tile_rock = NULL, *tile_tree = NULL, *tile_water = NULL, *sprite_player_act = NULL, *sprite_ia_act = NULL;
|
|
||||||
SDL_Surface *ressource[6] = {tile_grass, tile_rock, tile_tree, tile_water, sprite_player_act, sprite_ia_act};
|
|
||||||
SDL_Surface *sprite_player[4] = {NULL}, *sprite_ia[4] = {NULL};
|
|
||||||
tile_grass = IMG_Load("data/tile_grass.png");
|
|
||||||
tile_rock = IMG_Load("data/tile_rock.png");
|
|
||||||
tile_tree = IMG_Load("data/tile_tree.png");
|
|
||||||
tile_water = IMG_Load("data/tile_water.png");
|
|
||||||
|
|
||||||
sprite_player[DOWN] = IMG_Load("data/sprite_player_1.png");
|
|
||||||
//sprite_player[UP] = IMG_Load("data/sprite_player_2.png");
|
|
||||||
//sprite_player[LEFT] = IMG_Load("data/sprite_player_3.png");
|
|
||||||
//sprite_player[RIGHT] = IMG_Load("data/sprite_player_4.png");
|
|
||||||
|
|
||||||
sprite_ia[DOWN] = IMG_Load("data/sprite_ia_1.png");
|
|
||||||
//sprite_ia[UP] = IMG_Load("data/sprite_ia_2.png");
|
|
||||||
//sprite_ia[LEFT] = IMG_Load("data/sprite_ia_3.png");
|
|
||||||
//sprite_ia[RIGHT] = IMG_Load("data/sprite_ia_4.png");
|
|
||||||
*/
|
|
||||||
|
|
||||||
addLogInfo("Create SDL windows instance...");
|
addLogInfo("Create SDL windows instance...");
|
||||||
SDL_Window* gameWindows = SDL_CreateWindow("Arena Survival Tournament - alpha 0.2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOWS_WIDTH, WINDOWS_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS);
|
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("Creating new arena...");
|
addLogInfo("Creating new arena...");
|
||||||
ARENA_H_TILE* arena = NULL;
|
ARENA_H_TILE* arena = NULL;
|
||||||
@ -71,12 +53,10 @@ int main(int argc, char *argv[]) {
|
|||||||
addLogInfo("Successfully created arena.");
|
addLogInfo("Successfully created arena.");
|
||||||
|
|
||||||
addLogInfo("Display arena GUI...");
|
addLogInfo("Display arena GUI...");
|
||||||
//sprite_player_act = sprite_player[DOWN];
|
|
||||||
//sprite_ia_act = sprite_ia[DOWN];
|
|
||||||
displayArena(arena, gameWindows, tile_ressources, A_HEIGHT, A_WIDTH, TILE_SIZE);
|
displayArena(arena, gameWindows, tile_ressources, A_HEIGHT, A_WIDTH, TILE_SIZE);
|
||||||
|
|
||||||
|
|
||||||
SDL_Delay(10000);
|
SDL_Delay(3000);
|
||||||
|
|
||||||
deleteArena(arena);
|
deleteArena(arena);
|
||||||
addLogInfo("Cleared arena.");
|
addLogInfo("Cleared arena.");
|
||||||
|
8
main.h
8
main.h
@ -1,8 +1,8 @@
|
|||||||
#ifndef MAIN_H_
|
#ifndef MAIN_H_
|
||||||
#define MAIN_H_
|
#define MAIN_H_
|
||||||
|
|
||||||
#define A_WIDTH 20
|
#define A_WIDTH 30
|
||||||
#define A_HEIGHT 20
|
#define A_HEIGHT 30
|
||||||
|
|
||||||
#define TILE_SIZE 32
|
#define TILE_SIZE 32
|
||||||
#define WINDOWS_WIDTH TILE_SIZE * A_WIDTH
|
#define WINDOWS_WIDTH TILE_SIZE * A_WIDTH
|
||||||
@ -13,11 +13,11 @@
|
|||||||
*/
|
*/
|
||||||
#define ROCK_GEN_RATE 30
|
#define ROCK_GEN_RATE 30
|
||||||
#define TREE_GEN_RATE 25
|
#define TREE_GEN_RATE 25
|
||||||
#define WATER_GEN_RATE 20
|
#define WATER_GEN_RATE 8
|
||||||
#define GOLD_GEN_RATE 10
|
#define GOLD_GEN_RATE 10
|
||||||
|
|
||||||
enum {DOWN, UP, LEFT, RIGHT};
|
enum {DOWN, UP, LEFT, RIGHT};
|
||||||
enum {GRASS, ROCK, TREE, WATER, GOLD};
|
enum {GRASS, ROCK, TREE, WATER, GOLD, SPAWN};
|
||||||
|
|
||||||
int random_lim(int max);
|
int random_lim(int max);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user