fix bug generator
This commit is contained in:
parent
b1f928028d
commit
d646f13d30
14
generator.c
14
generator.c
@ -29,9 +29,10 @@ typedef struct{
|
|||||||
} t_biome;
|
} t_biome;
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
int sp_x[2], sp_y[2];
|
int sp_x[NB_TEAMS], sp_y[NB_TEAMS];
|
||||||
t_biome* l_biomes;
|
t_biome* l_biomes;
|
||||||
int size_biomes;
|
int size_biomes;
|
||||||
|
int nb_plains, nb_forests, nb_mountains;
|
||||||
int cpt_biome = 0;
|
int cpt_biome = 0;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
@ -51,9 +52,6 @@ void create_map(int w, int h){
|
|||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
//biome variable
|
//biome variable
|
||||||
int nb_plains, nb_forests, nb_mountains;
|
|
||||||
|
|
||||||
int spawn_color = 0;
|
|
||||||
|
|
||||||
width = w;
|
width = w;
|
||||||
height = h;
|
height = h;
|
||||||
@ -88,10 +86,14 @@ void create_map(int w, int h){
|
|||||||
for(j=0;j<height;j++){
|
for(j=0;j<height;j++){
|
||||||
if (i == 0 || j == 0 || i == w-1 || j == h-1){
|
if (i == 0 || j == 0 || i == w-1 || j == h-1){
|
||||||
map[i][j].type = BEDROCK;
|
map[i][j].type = BEDROCK;
|
||||||
}else if((i == sp_x[0] && j == sp_y[0]) || (i == sp_x[1] && j == sp_y[1])){
|
}else if((i == sp_x[PURPLE] && j == sp_y[PURPLE])){
|
||||||
map[i][j].type = SPAWN;
|
map[i][j].type = SPAWN;
|
||||||
map[i][j].data=malloc(sizeof(int));
|
map[i][j].data=malloc(sizeof(int));
|
||||||
memset(map[i][j].data,spawn_color++,sizeof(int));
|
*((int*)(map[i][j].data)) = PURPLE;
|
||||||
|
}else if(i == sp_x[ORANGE] && j == sp_y[ORANGE]){
|
||||||
|
map[i][j].type = SPAWN;
|
||||||
|
map[i][j].data=malloc(sizeof(int));
|
||||||
|
*((int*)(map[i][j].data)) = ORANGE;
|
||||||
}else{
|
}else{
|
||||||
map[i][j].type = generate(i,j);
|
map[i][j].type = generate(i,j);
|
||||||
}
|
}
|
||||||
|
11
orange.c
11
orange.c
@ -102,13 +102,13 @@ void checkActionSuccess(t_info_data* data, int success){
|
|||||||
if (distance(data->pos,data->res_spot.pos) == 0){
|
if (distance(data->pos,data->res_spot.pos) == 0){
|
||||||
data->aim = NO_AIM;
|
data->aim = NO_AIM;
|
||||||
}
|
}
|
||||||
}/*else{
|
}else{
|
||||||
/*aim_pos.x = 0;
|
aim_pos.x = 0;
|
||||||
aim_pos.y = 0;
|
aim_pos.y = 0;
|
||||||
if(distance(data->pos, aim_pos) == 1){
|
if(distance(data->pos, aim_pos) == 1){
|
||||||
data->aim=AIM_SPOT;
|
data->aim=AIM_SPOT;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
break;
|
break;
|
||||||
case ATTACK:
|
case ATTACK:
|
||||||
case PICK:
|
case PICK:
|
||||||
@ -188,6 +188,11 @@ int newDir(t_info_data* data){
|
|||||||
new_dist = distance(orangeNewPos(data->pos,dir),aim_pos);
|
new_dist = distance(orangeNewPos(data->pos,dir),aim_pos);
|
||||||
}while(current_dist <= new_dist);
|
}while(current_dist <= new_dist);
|
||||||
|
|
||||||
|
if (getNear(dir) == DUDE || getNear(dir) == TREE || getNear(dir) == ROCK || getNear(dir) == IRON_ORE){
|
||||||
|
int offset = (rand()%3)-1;
|
||||||
|
dir+=offset;
|
||||||
|
dir%=4;
|
||||||
|
}
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
t_coord orangeNewPos(t_coord pos, int dir){
|
t_coord orangeNewPos(t_coord pos, int dir){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user