add specific comportement when a plateform is could pass trough mario

This commit is contained in:
Milang 2020-02-04 20:34:30 +01:00
parent 48625d4ce4
commit e6ed094095
2 changed files with 12 additions and 11 deletions

Binary file not shown.

View File

@ -21,22 +21,23 @@ void reset_plateforme(plateforme_t* p)
void move_plateforme(plateforme_t* p)
{
int xc = (mario.p.x<p->b.x+p->b.w && mario.p.x>=p->b.x) || (mario.p.x+mario.p.w<p->b.x+p->b.w && mario.p.x+mario.p.w>=p->b.x);
int yc = (mario.p.y-3==p->b.y);
/*if (p->type==P_FALLING)
// Si mario et la plateforme vont se chevaucher, la plateforme est immobilisée
{
if (p->v)
p->v++;
p->b.y+=p->v/2;
}*/
box_t b = p->b;
b.x+=b.vx;
b.y+=b.vy;
int x_collide= (mario.p.x<=b.x && b.x<mario.p.x+mario.p.w) || (mario.p.x<=b.x+b.w-1 && b.x+b.w<mario.p.x+mario.p.w);
int y_collide= (mario.p.y<=b.y && b.y<mario.p.y+mario.p.h) || (mario.p.y<=b.y+b.h-1 && b.y+b.h<mario.p.y+mario.p.h);
if (x_collide&&y_collide)
return;
}
box_t temp=p->b;
box_move(&p->b);
// Si mario est sur la plateforme, il bouge avec
if (xc&&yc)
if (((mario.p.x<p->b.x+p->b.w && mario.p.x>=p->b.x) || (mario.p.x+mario.p.w<p->b.x+p->b.w && mario.p.x+mario.p.w>=p->b.x)) && (mario.p.y-3==p->b.y))
{
box_t mario_clone=mario.p;
mario_clone.vx=temp.vx;