move init ennemi function

This commit is contained in:
Milang 2020-02-01 14:36:34 +01:00
parent bdab50f58e
commit 2871c50f73
4 changed files with 22 additions and 15 deletions

View File

@ -44,4 +44,6 @@ void display_ennemi_table();
void move_ennemi(ennemi_t *e);
void init_ennemi(ennemi_t * table, int s);
#endif

View File

@ -3,5 +3,6 @@
void set_level(int w, int l);
void get_lvl_id(int w, int l, char * str);
void malloc_error();
#endif

View File

@ -373,3 +373,22 @@ void display_ennemi_table()
display_ennemi(&ennemis_global[i]);
}
}
void init_ennemi(ennemi_t * table, int s)
{
ennemis_global_size=s;
if (ennemis_global)
{
free(ennemis_global);
ennemis_global=0;
}
if (0==ennemis_global_size)
return;
int size=sizeof(ennemi_t)*ennemis_global_size;
ennemis_global=malloc(size);
if (ennemis_global==0)
malloc_error();
memcpy(ennemis_global, table, size);
}

View File

@ -52,21 +52,6 @@ static void init_level(int w, int h, int x, int y, cell_t const * a)
memcpy(map_current->data, a, sizeof(cell_t)*w*h);
}
void init_ennemies(ennemi_t * table)
{
if (ennemis_global)
{
free(ennemis_global);
}
if (0==ennemis_global_size)
return;
int size=sizeof(ennemi_t)*ennemis_global_size;
ennemis_global=malloc(size);
if (ennemis_global==0)
malloc_error();
memcpy(ennemis_global, table, size);
}
static void init_plateformes(plateforme_t * table)
{