|
|
|
@ -12,18 +12,38 @@
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h> |
|
|
|
|
|
|
|
|
|
/** properties **/ |
|
|
|
|
const int ennemi_widths [NOMBRE_ENNEMIS] = {0, 8, 8, 8, 8 , 8, 8}; |
|
|
|
|
//const int ennemi_heights[NOMBRE_ENNEMIS] = {0, 8, 12, 9, 12, 9, 8};
|
|
|
|
|
const int ennemi_heights[NOMBRE_ENNEMIS] = {0, 8, 8, 8, 8, 8, 8}; |
|
|
|
|
|
|
|
|
|
/** ram storage **/ |
|
|
|
|
ennemi_t * ennemis_global=0; |
|
|
|
|
static int ennemis_global_size=0; |
|
|
|
|
int ennemiesNumber() { return ennemis_global_size; } |
|
|
|
|
|
|
|
|
|
void ennemiesInit(ennemi_t * table, int s) |
|
|
|
|
{ |
|
|
|
|
if (ennemis_global) freeProf(ennemis_global); |
|
|
|
|
|
|
|
|
|
ennemis_global_size = ennemis_global = 0; // reset
|
|
|
|
|
|
|
|
|
|
if (s==0) return; |
|
|
|
|
int const size = sizeof(ennemi_t) * s; |
|
|
|
|
if ((ennemis_global = mallocProf(size)) == 0) mallocError(); |
|
|
|
|
|
|
|
|
|
ennemis_global_size = s; |
|
|
|
|
memcpy(ennemis_global, table, size); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ennemiDisplay(ennemi_t const * e) |
|
|
|
|
{ |
|
|
|
|
if (e->type==NONE) return; |
|
|
|
|
if (e->b.x<=cameraX(0)-e->b.w || e->b.x>=cameraX(0)+127) return; // do not draw if out of the screen
|
|
|
|
|
if (e->type == NONE) return; |
|
|
|
|
if (e->b.x <= cameraX(0) - e->b.w || e->b.x >= cameraX(0) + 127) return; // do not draw if out of the screen
|
|
|
|
|
|
|
|
|
|
{// draw
|
|
|
|
|
int tx=0, ty=0, dsx=0, dsy=0; |
|
|
|
|
tileset_t t={0,ennemi_widths[e->type], ennemi_heights[e->type],1}; |
|
|
|
|
tileset_t t={0, ennemi_widths[e->type], ennemi_heights[e->type], 1}; |
|
|
|
|
switch (e->type) |
|
|
|
|
{ |
|
|
|
|
case GOOMBA_ID: |
|
|
|
@ -86,16 +106,15 @@ void plante_tour(ennemi_t *e)
|
|
|
|
|
{ |
|
|
|
|
e->p1++; |
|
|
|
|
e->p1%=PLANTE_NLAPS; |
|
|
|
|
if (0<=e->p1 && e->p1<35) // (plante en bas, en attente)
|
|
|
|
|
{ |
|
|
|
|
if (abs(mario.p.x-e->b.x)<15) e->p1=0; |
|
|
|
|
} |
|
|
|
|
// En attente
|
|
|
|
|
if (0<=e->p1 && e->p1<35) if (abs(mario.p.x-e->b.x)<15) e->p1=0; |
|
|
|
|
|
|
|
|
|
if (35<=e->p1 && e->p1<58) |
|
|
|
|
{ |
|
|
|
|
if ((e->p1+1)%3==0) e->b.y++; |
|
|
|
|
} |
|
|
|
|
if (58<=e->p1 && e->p1<75){} // plante en attente en haut
|
|
|
|
|
if (75<=e->p1 && e->p1<98) |
|
|
|
|
if (58 <= e->p1 && e->p1 < 75){} // plante en attente en haut
|
|
|
|
|
if (75 <= e->p1 && e->p1 < 98) |
|
|
|
|
{ |
|
|
|
|
if (e->p1%3==0) e->b.y--; |
|
|
|
|
} |
|
|
|
@ -332,24 +351,9 @@ void ennemiMove(ennemi_t *e)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Global variables for ennemies
|
|
|
|
|
ennemi_t * ennemis_global=0; |
|
|
|
|
int ennemis_global_size=0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ennemiesDisplay() |
|
|
|
|
{ |
|
|
|
|
for (int i=0; i<ennemis_global_size; i++) ennemiDisplay(&ennemis_global[i]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ennemiesInit(ennemi_t * table, int s) |
|
|
|
|
{ |
|
|
|
|
if (ennemis_global) |
|
|
|
|
freeProf(ennemis_global); |
|
|
|
|
ennemis_global_size=ennemis_global=0; |
|
|
|
|
if (!s) return; |
|
|
|
|
int size=sizeof(ennemi_t)*s; |
|
|
|
|
if ((ennemis_global=mallocProf(size))==0) mallocError(); |
|
|
|
|
ennemis_global_size=s; |
|
|
|
|
memcpy(ennemis_global, table, size); |
|
|
|
|
} |
|
|
|
|