parent
5f9791f6aa
commit
13872b3dcb
65
src/ennemi.c
65
src/ennemi.c
|
@ -178,58 +178,30 @@ void ennemiMove(ennemi_t *e)
|
|||
if (e->b.y<0) e->type=NONE;
|
||||
|
||||
const bool mario_fatal_hit = (mario.p.last_vy<=-2 || mario.p.vy<=-2);
|
||||
|
||||
boxMove(&e->b);
|
||||
switch (e->type) // move
|
||||
{
|
||||
case GOOMBA_ID:
|
||||
case KOOPA_V_ID:
|
||||
boxMove(&e->b);
|
||||
if (e->b.vx==0)
|
||||
{
|
||||
if (e->p1==0)
|
||||
{
|
||||
e->b.vx=-1;
|
||||
e->p1=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
e->p1*=-1;
|
||||
e->b.vx=e->p1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case KOOPA_R_ID:
|
||||
boxMove(&e->b);
|
||||
if (e->b.vx==0)
|
||||
{
|
||||
if (e->p1==0)
|
||||
{
|
||||
e->b.vx=-1;
|
||||
e->p1=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
e->p1*=-1;
|
||||
e->b.vx=e->p1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // demi tour automatique
|
||||
if (e->b.vx)
|
||||
{ // demi tour si au dessus du vide
|
||||
int s=-1;
|
||||
if (e->b.vx>0) s=e->b.w;
|
||||
|
||||
if (worldGetCellCategory(e->b.x+s, e->b.y-1)==CTG_EMPTY && sgn(e->b.vx)==sgn(s))
|
||||
{
|
||||
e->p1*=-1;
|
||||
e->b.vx=e->p1;
|
||||
}
|
||||
if (worldGetCellCategory(e->b.x+s, e->b.y-1)==CTG_EMPTY && sgn(e->b.vx)==sgn(s)) e->b.vx=(e->p1*=-1);
|
||||
}
|
||||
|
||||
// fall through
|
||||
case GOOMBA_ID:
|
||||
case KOOPA_V_ID:
|
||||
if (e->b.vx==0) // demi tour si mur
|
||||
{
|
||||
if (e->p1==0) e->b.vx=e->p1=-1;
|
||||
else e->b.vx=(e->p1*=-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case CARAPACE_VERTE:
|
||||
case CARAPACE_ROUGE:
|
||||
boxMove(&e->b);
|
||||
if (e->b.vx==0)
|
||||
{
|
||||
if (e->p1<2)
|
||||
|
@ -247,6 +219,7 @@ void ennemiMove(ennemi_t *e)
|
|||
e->p1=e->b.vx=0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (e_hitMario && mario_fatal_hit) switch (e->type) // mario attacks
|
||||
|
@ -287,7 +260,6 @@ void ennemiMove(ennemi_t *e)
|
|||
if (mario.p.x>=e->b.x) mario.p.x=e->b.x+e->b.w;
|
||||
if (mario.p.x<=e->b.x) mario.p.x=e->b.x-mario.p.w;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -311,7 +283,7 @@ void ennemiMove(ennemi_t *e)
|
|||
if (e->p1==0 || e->p1>=2)
|
||||
{
|
||||
if (mario.p.x>=e->b.x) e->p1=-1;
|
||||
if (mario.p.x<=e->b.x) e->p1=1;
|
||||
else e->p1=1;
|
||||
e->b.vx=6*e->p1;
|
||||
if (mario_fatal_hit)
|
||||
{
|
||||
|
@ -321,17 +293,12 @@ void ennemiMove(ennemi_t *e)
|
|||
else
|
||||
{ // mario bounce
|
||||
if (mario.p.x>=e->b.x) mario.p.x=e->b.x+e->b.w;
|
||||
if (mario.p.x<=e->b.x) mario.p.x=e->b.x-mario.p.w;
|
||||
else mario.p.x=e->b.x-mario.p.w;
|
||||
}
|
||||
|
||||
}
|
||||
else hurtMario();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Global variables for ennemies
|
||||
|
|
Loading…
Reference in New Issue