From a82e9bef82999ee087b64521d99034d15b1314e7 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Mon, 12 Jan 2015 20:01:09 +0100 Subject: [PATCH] debugged generator --- Makefile | 2 +- generator.c | 70 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 01c9aee..caedac8 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC=gcc LIB=-lSDL -lm -L./lib -FLAGS=-Wall -I./include +FLAGS=-Wall ifdef SystemRoot RM=del /Q diff --git a/generator.c b/generator.c index 2d80bb6..3c7ab1a 100644 --- a/generator.c +++ b/generator.c @@ -12,7 +12,8 @@ typedef struct{ // variables t_epicenter* l_epicenters; -int size_epi; +int size_epicenters; +int cpt_epicenter = 0; int width, height; // functions @@ -25,41 +26,63 @@ void create_epicenter(int type); int generate(int x, int y); void create_map(t_pixel** map, t_team* teams, int w, int h){ - int i,j; + int i,j,k,l; + int type; + + //epicenter variable + int nb_rock, nb_tree, nb_berries; + + //spawn variable + int x_rand, y_rand; + width = w; height = h; - //génération des épicentres - l_epicenters = malloc(); // TODO : wtf malloc dans le vide + //Epicenters generation + // random choice for numbers of epicenters + nb_rock = rand()%5; + nb_tree = rand()%5; + nb_berries = rand()%5; + + 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;iheight;j++){ if (i == 0 || j == 0){ - map[i][j]=BEDROCK; - else{ - map[i][j] = generate(i,j); + map[i][j].type = BEDROCK; + }else{ + type=generate(i,j); + map[i][j].type = type; } } } - for(int k=0;k