update ennemi functions

use `ennemi_t const * ` instead of `ennemi_t *` in display methods
master
milang 3 years ago
parent 6a744b0547
commit 1b3acce432
  1. 2
      include/ennemi.h
  2. 28
      src/ennemi.c

@ -44,7 +44,7 @@ extern ennemi_t * ennemis_global;
extern int ennemis_global_size;
void ennemiesDisplay();
void ennemiMove(ennemi_t *e);
void ennemiMove(ennemi_t const * e);
void ennemiesInit(ennemi_t * table, int s);

@ -16,21 +16,8 @@ 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};
void ennemiDisplay(ennemi_t * e)
void ennemiDisplay(ennemi_t const * e)
{
if (e->life==0 && e->type!=NONE)
{
if (e->p1==0)
{
e->b.vx*=-1;
e->b.vy=5;
}
e->p1++;
e->b.vy--;
e->b.y+=e->b.vy;
e->b.x+=e->b.vx;
if (e->p1>=30) e->type=NONE; // died 1.5 sec before
}
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
else e->discovered=1; // for security, tag as discover all drawed ennemies
@ -104,6 +91,19 @@ void hurtMario()
void ennemiMove(ennemi_t *e)
{
if (e->life==0 && e->type!=NONE)
{
if (e->p1==0)
{
e->b.vx=-2*sgn(e->b.vx);
e->b.vy=5;
}
e->p1++;
e->b.vy--;
e->b.y+=e->b.vy;
e->b.x+=e->b.vx;
if (e->p1>=30) e->type=NONE; // died 1.5 sec before
}
if (e->b.x<cameraX()+128+30 && e->b.x>cameraX()-30)
e->discovered=1;

Loading…
Cancel
Save