diff --git a/Makefile b/Makefile index 0be5ad9..c2034a8 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,8 @@ else RM=rm -f FixPath=$1 BINARY=PixelWars - LIB=-lSDL -lm - FLAGS=-Wall + LIB=-lSDL -lm + FLAGS=-g -Wall endif endif diff --git a/generator.c b/generator.c index 5b07505..8948368 100644 --- a/generator.c +++ b/generator.c @@ -1,6 +1,8 @@ #include "main.h" #define MAX_POWER 10 +#define MAX_EPICENTER_BY_TYPE 10 +#define MAX_RADIUS 75 typedef struct{ int x; @@ -18,50 +20,44 @@ int width, height; // functions int distance_manhattan(int x1,int y1, int x2, int y2); - int absolute(int val); - -void create_epicenter(int type); - +void set_spawns(t_pixel** map, t_team* teams); +void create_epicenter(int x, int y, int type); +void create_epicenter_random(int type); int generate(int x, int y); void create_map(t_pixel** map, t_team* teams, int w, int h){ - int i,j,k,l; + int i,j; int type; //epicenter variable int nb_rock, nb_tree, nb_berries; - //spawn variable - int x_rand, y_rand; - width = w; height = h; //Epicenters generation - // random choice for numbers of epicenters - nb_rock = rand()%5; - nb_tree = rand()%5; - nb_berries = rand()%5; + nb_rock = rand()%MAX_EPICENTER_BY_TYPE; + nb_tree = rand()%MAX_EPICENTER_BY_TYPE; + nb_berries = rand()%MAX_EPICENTER_BY_TYPE; size_epicenters = nb_rock + nb_tree + nb_berries + NB_TEAMS; l_epicenters = malloc(sizeof(t_epicenter)*size_epicenters); - //plains generation for each player => after spawn - for(i=0;ix=x; + epicenter->y=y; + epicenter->type = type; + epicenter->power = (rand()%MAX_POWER)+1; + epicenter->radius = (rand()%100)+1; - epicenter.x=rand()%width; - epicenter.y=rand()%height; - epicenter.type = type; - epicenter.power = rand()%MAX_POWER; - epicenter.radius = rand()%(width*height/4); - - l_epicenters[cpt_epicenter++]=epicenter; + l_epicenters[cpt_epicenter++]=*epicenter; } - + +void create_epicenter_random(int type){ + create_epicenter(rand()%width,rand()%height,type); +} + int generate(int x, int y){ - int i, ratio, dist_to_epi, sum, val, type; + int i, ratio, dist_to_epi, sum, val; int proba[5]; t_epicenter epi; + for(i=0;i<5;i++){ + proba[i]=0; + } + for(i=0;iformat, 255, 255, 255)); if (SDL_Init(SDL_INIT_VIDEO) == -1) { - fprintf(stderr, "Erreur d'initialisation de la SDL"); + fprintf(stderr, "Erreur d'initialisation de la SDL");// and you don't want my french comment :p exit(EXIT_FAILURE); } }