From 178629a9ad2f75b377b4e54d56a184a01cf21c09 Mon Sep 17 00:00:00 2001 From: anselme16 Date: Thu, 22 Jan 2015 14:41:04 +0100 Subject: [PATCH] fixed some makefile problems --- Makefile | 8 +- generator.c | 234 ------------------------------------------------ purple/Makefile | 8 +- 3 files changed, 12 insertions(+), 238 deletions(-) delete mode 100644 generator.c diff --git a/Makefile b/Makefile index e2cdc42..aede7ef 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,12 @@ endif all : $(BINARY) +purple/purple.$(LIB_PREFIX) : + $(MAKE) -C purple + +orange/orange.$(LIB_PREFIX) : + $(MAKE) -C orange + $(BINARY) : orange/orange.$(LIB_PREFIX) purple/purple.$(LIB_PREFIX) PixelWars_$(GENERATOR).$(LIB_PREFIX) $(CC) PixelWars_$(GENERATOR).$(LIB_PREFIX) orange/orange.$(LIB_PREFIX) purple/purple.$(LIB_PREFIX) -o $(BINARY) $(LIB) @@ -30,6 +36,6 @@ PixelWars_$(GENERATOR).$(LIB_PREFIX) : main.o tools.o generator_$(GENERATOR).o %.o: %.c $(CC) -o $@ -c $< $(FLAGS) - + clean : $(RM) *.o *.a $(BINARY) *.stackdump *~ \ No newline at end of file diff --git a/generator.c b/generator.c deleted file mode 100644 index 2b52f2c..0000000 --- a/generator.c +++ /dev/null @@ -1,234 +0,0 @@ -#include "main.h" - -#define MAX_POWER 10 -#define MAX_EPICENTER_BY_TYPE 7 -#define DIST_MIN_INTER_EPICENTRE 50 -#define MIN_RADIUS 25 -#define OFFSET_RADIUS 50 - -//map type ----> not used for now -enum{ - FLAT, VALLEY, -}; - -//biome type -enum{ - VILLAGE, PLAINS, FOREST,MOUNTAINS,NB_BIOMES -}; - -// probability for each biomes -// in following order {GRASS,TREE,BERRIES, ROCK, IRON_ORE} -char proba_table[NB_BIOMES][5] = {{97,2,1,0,0},{85,13,2,0,0},{40,40,20,0,0},{0,0,0,80,20}}; - -typedef struct{ - int x; - int y; - int type; - int power; - int radius; -} t_biome; - -// variables -int sp_x[NB_TEAMS], sp_y[NB_TEAMS]; -t_biome* l_biomes; -int size_biomes; -int nb_plains, nb_forests, nb_mountains; -int cpt_biome = 0; -int width, height; - -// functions -int distance_manhattan(int x1,int y1, int x2, int y2); -int absolute(int val); -void set_spawns(t_pixel** map, t_team* teams); -void create_biome(int x, int y, int type); -void create_biome_random(int type); -int check_nears_biomes(int x, int y); -int check_nears_spawn(int x, int y); -int in_radius(int x,int y,t_biome e); -int generate(int x, int y); -void init_generator(); - -void create_map(int w, int h){ - int i,j; - - //biome variable - - width = w; - height = h; - - init_generator(); - - //Epicenters generation - // random choice for numbers of biomes - nb_plains = (rand()%MAX_EPICENTER_BY_TYPE)+3; - nb_forests = (rand()%MAX_EPICENTER_BY_TYPE)+3; - nb_mountains = (rand()%MAX_EPICENTER_BY_TYPE)+3; - - size_biomes = nb_plains+ nb_forests + nb_mountains + NB_TEAMS; - - l_biomes = malloc(sizeof(t_biome)*size_biomes); - - // Spawn generations - set_spawns(map,teams); - - for(i=0;ix=x; - biome->y=y; - biome->type = type; - - switch(type){ - case VILLAGE: - biome->power = (rand()%MAX_POWER)+1; - biome->radius = (rand()%(25-10))+10; - break; - case PLAINS: - case FOREST: - case MOUNTAINS: - default: - biome->power = (rand()%MAX_POWER)+1; - biome->radius = (rand()%(OFFSET_RADIUS))+MIN_RADIUS; - break; - } - - l_biomes[cpt_biome++]=*biome; -} - -void create_biome_random(int type){ - int x,y; - do { - x=rand()%width; - y=rand()%height; - } while ((check_nears_biomes(x,y) != 0) || (check_nears_spawn(x,y) != 0)); //prevent biome superposition - - create_biome(x,y,type); -} - -int check_nears_biomes(int x, int y){ - int i, c=0; - for(i=0;i 0 ? val : -val; -} diff --git a/purple/Makefile b/purple/Makefile index d0b1626..41d7dd0 100644 --- a/purple/Makefile +++ b/purple/Makefile @@ -20,9 +20,11 @@ endif all : $(TARGET).$(LIB_PREFIX) -$(TARGET).$(LIB_PREFIX) : - $(CC) *.c -c $(FLAGS) - $(AR) $(TARGET).$(LIB_PREFIX) *.o +$(TARGET).$(LIB_PREFIX) : purple.o + $(AR) $(TARGET).$(LIB_PREFIX) purple.o + +%.o: %.c + $(CC) -o $@ -c $< $(FLAGS) clean : $(RM) *.o *.a *.stackdump *~ \ No newline at end of file