completing piranha plants

This commit is contained in:
Milang 2020-03-10 19:20:06 +01:00
parent 9476c81e50
commit eb1e3e1fc6
9 changed files with 31 additions and 15 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -26,7 +26,9 @@ extern const int ennemi_heights[NOMBRE_ENNEMIS];
#define PLANTE(x,y) {PLANTE_ID,{x,y,ennemi_widths[PLANTE_ID],ennemi_heights[PLANTE_ID],0,0,0,0},ALIVE,0,0}
// pour plante ID, ymin est associé à p1=0
// Dimensions pr les boites
#define PLANTE_NLAPS 99
typedef struct
@ -48,4 +50,6 @@ void ennemiMove(ennemi_t * e);
void ennemiesInit(ennemi_t * table, int s);
void plante_tour(ennemi_t *e);
#endif

View File

@ -72,6 +72,7 @@ void ennemiDisplay(ennemi_t const * e)
{
extern image_t img_plante;
t.sheet=&img_plante;
t.width*=2;
dsx=-4;
}
}
@ -79,22 +80,22 @@ void ennemiDisplay(ennemi_t const * e)
}
}
static void plante_tour(ennemi_t *e)
void plante_tour(ennemi_t *e)
{
if (e->type==PLANTE_ID)
{
e->p1++;
e->p1%=93;
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;
}
if (35<=e->p1 && e->p1<52)
if (35<=e->p1 && e->p1<58)
{
if ((e->p1+1)%3==0) e->b.y++;
}
if (52<=e->p1 && e->p1<75){} // plante en attente en haut
if (75<=e->p1 && e->p1<92)
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--;
}
@ -267,7 +268,7 @@ void ennemiMove(ennemi_t *e)
e->p1=2;
e->b.vx=0;
scoreAdd(KILL_ENNEMI);
mario.p.vy=4;
mario.p.vy=6;
mario.p.y=e->b.y+ennemi_heights[e->type]+1;
break;
@ -279,19 +280,21 @@ void ennemiMove(ennemi_t *e)
if (mario.p.x<=e->b.x) e->p1=1;
e->b.vx=6*e->p1;
mario.p.vy=4;
mario.p.vy=6;
mario.p.y=e->b.y+ennemi_heights[CARAPACE_VERTE];
boxMove(&e->b);
}
else
{
e->p1=e->b.vx=0;
mario.p.vy=4;
e->p1=e->b.vx=mario.p.vx=0;
mario.p.vy=6;
mario.p.y=e->b.y+ennemi_heights[CARAPACE_VERTE]+1;
}
break;
case PLANTE_ID:
hurtMario();
break;
}
else if (e_hitMario) switch (e->type) // hurt mario
{
@ -310,17 +313,22 @@ void ennemiMove(ennemi_t *e)
e->b.vx=6*e->p1;
if (mario_fatal_hit)
{
mario.p.vy=4;
mario.p.vy=6;
mario.p.y=e->b.y+ennemi_heights[CARAPACE_VERTE];
}
else
{ // mario bounce
if (mario.p.x>=e->b.x) mario.p.x=e->b.x+e->b.w;
else mario.p.x=e->b.x-mario.p.w;
mario.p.vx=0;
}
}
else hurtMario();
break;
case PLANTE_ID:
hurtMario();
break;
}
}

View File

@ -321,7 +321,7 @@ static void unpackLevel(packed_level_t * p)
}
else if (contents==PACKED_PLANTE)
{
ennemi_t e=PLANTE(8*x+4,8*y/*-8*/);
ennemi_t e=PLANTE(8*x+4,8*y-8);
ennemis[nombre_ennemis]=e;
nombre_ennemis++;
}

View File

@ -46,7 +46,7 @@ extern image_t img_star;
const tileset_t mario_starman={&img_star, TILE_W, TILE_H, 0};
extern image_t img_fleur;
const tileset_t fleur={&img_fleur, TILE_W, TILE_H, 0};
const tileset_t fleur={&img_fleur, 2*TILE_W, TILE_H, 0};
extern image_t img_bullet;
const tileset_t bullet={&img_bullet, TILE_W/2, TILE_H/2, 1};

View File

@ -55,6 +55,8 @@ void teleportersActive()
mario.p.x=t.tx*8+4; mario.p.y=t.ty*8; // Move Mario
mario.p.vx=0; mario.p.vy=0; // Disables every move of mario
cameraAdjust();
for (i=0; i<ennemis_global_size; i++) plante_tour
}
}
}

View File

@ -166,6 +166,8 @@ void worldDraw()
// draw immunity remaining time [It's a progress bar on the left side of the screen]
if (mario_immunity) drect(0,64-MARIO_IMMUNITY_TIME+mario_immunity,2,64, C_BLACK);
}
void worldMove()