add teleporter

This commit is contained in:
Milang 2019-12-16 19:23:36 +01:00
parent ea8499c1f2
commit 0215318e28
24 changed files with 853 additions and 721 deletions

Binary file not shown.

BIN
assets-fx/img/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
build-fx/src/mario.c.o: src/mario.c src/mario.h src/box.h src/tile.h \
src/world.h src/keyboard.h src/score.h src/bonus.h
src/world.h src/keyboard.h src/score.h src/bonus.h src/teleporteur.h
src/mario.h:
@ -14,3 +14,5 @@ src/keyboard.h:
src/score.h:
src/bonus.h:
src/teleporteur.h:

Binary file not shown.

View File

@ -0,0 +1,10 @@
build-fx/src/teleporteur.c.o: src/teleporteur.c src/teleporteur.h \
src/mario.h src/box.h src/keyboard.h
src/teleporteur.h:
src/mario.h:
src/box.h:
src/keyboard.h:

Binary file not shown.

Binary file not shown.

View File

@ -46,9 +46,9 @@ void lance_bullet()
bullets[i].b.x=mario.p.x;
bullets[i].b.y=mario.p.y+8;
if (last_vx_sign==0)
bullets[i].b.vx=-3;
bullets[i].b.vx=-6;
else
bullets[i].b.vx=3;
bullets[i].b.vx=6;
bullets[i].b.vy=0;
bullets[i].p1=last_vx_sign;
return;
@ -124,7 +124,7 @@ void bonus_move() //+collision
if (bonus.type==BONUS_STAR)
{
box_jump(&bonus.b,5);
box_jump(&bonus.b,4);
}
box_move(&bonus.b);
if (bonus.type==BONUS_CHAMPI || bonus.type==BONUS_1UP || bonus.type==BONUS_STAR)
@ -134,7 +134,7 @@ void bonus_move() //+collision
{
if (bonus.p1==0)
{
bonus.b.vx=1;
bonus.b.vx=2;
bonus.p1=1;
}
else
@ -169,6 +169,12 @@ void bonus_move() //+collision
score_add(1000);
lifes++;
}
if (bonus.type==BONUS_STAR)
{
bonus_set(BONUS_NONE,0,0);
score_add(1000);
mario_star_mode=1;
}
}
}
@ -183,4 +189,6 @@ void bonus_draw()
draw_tile(bonus.b.x-world_get_real_x0(), bonus.b.y-world_get_real_y0(mario.p.y), &fleur, 0,0);
if (bonus.type==BONUS_1UP)
draw_tile(bonus.b.x-world_get_real_x0(), bonus.b.y-world_get_real_y0(mario.p.y), &life_1up, 0,0);
if (bonus.type==BONUS_STAR)
draw_tile(bonus.b.x-world_get_real_x0(), bonus.b.y-world_get_real_y0(mario.p.y), &mario_starman, 0,0);
}

View File

@ -12,266 +12,269 @@ const int ennemi_heights[NOMBRE_ENNEMIS] = {0, 8, 12, 9, 12, 9};
void display_ennemi(ennemi_t * e)
{
if (e->life==0)
{
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;
}
if (e->type==NONE)
return;
if (e->b.x<=world_get_real_x0(0)-e->b.w || e->b.x>=world_get_real_x0(0)+127)
return;
else
e->discovered=1;
if (e->life==0)
{
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;
}
if (e->type==NONE)
return;
if (e->b.x<=world_get_real_x0(0)-e->b.w || e->b.x>=world_get_real_x0(0)+127)
return;
else
e->discovered=1;
if (e->type==GOOMBA_ID)
{
extern image_t img_goomba;
tileset_t goomba={&img_goomba, GOOMBA_X, GOOMBA_Y, 1};
if (e->life==1)
draw_tile(e->b.x-world_get_real_x0(0), e->b.y-world_get_real_y0(mario.p.y), &goomba, 1+(time_id/10)%2, 0);
if (e->life==0)
draw_tile(e->b.x-world_get_real_x0(0), e->b.y-world_get_real_y0(mario.p.y), &goomba, 0, 0);
}
if (e->type==KOOPA_V_ID)
{
extern image_t img_koopa_verte;
tileset_t koopa_verte={&img_koopa_verte, KOOPA_X, KOOPA_Y, 1};
if (e->life==1)
draw_tile(e->b.x-world_get_real_x0(0), e->b.y-world_get_real_y0(mario.p.y), &koopa_verte, (1+e->p1)+(time_id/8)%2, 0);
}
if (e->type==CARAPACE_VERTE)
{
extern image_t img_carapace_verte;
tileset_t carapace_verte={&img_carapace_verte, CARAPACE_X, CARAPACE_Y, 1};
draw_tile(e->b.x-world_get_real_x0(0), e->b.y-world_get_real_y0(mario.p.y), &carapace_verte, 0, 0);
}
if (e->type==GOOMBA_ID)
{
extern image_t img_goomba;
tileset_t goomba={&img_goomba, GOOMBA_X, GOOMBA_Y, 1};
if (e->life==1)
draw_tile(e->b.x-world_get_real_x0(0), e->b.y-world_get_real_y0(mario.p.y), &goomba, 1+(time_id/10)%2, 0);
if (e->life==0)
draw_tile(e->b.x-world_get_real_x0(0), e->b.y-world_get_real_y0(mario.p.y), &goomba, 0, 0);
}
if (e->type==KOOPA_V_ID)
{
extern image_t img_koopa_verte;
tileset_t koopa_verte={&img_koopa_verte, KOOPA_X, KOOPA_Y, 1};
if (e->life==1)
draw_tile(e->b.x-world_get_real_x0(0), e->b.y-world_get_real_y0(mario.p.y), &koopa_verte, (1+e->p1)+(time_id/8)%2, 0);
}
if (e->type==CARAPACE_VERTE)
{
extern image_t img_carapace_verte;
tileset_t carapace_verte={&img_carapace_verte, CARAPACE_X, CARAPACE_Y, 1};
draw_tile(e->b.x-world_get_real_x0(0), e->b.y-world_get_real_y0(mario.p.y), &carapace_verte, 0, 0);
}
}
bool ennemi_check_collision(ennemi_t *e)
{ bool x_collide= (mario.p.x<=e->b.x && e->b.x<=mario.p.x+mario.p.w-1) || (mario.p.x<=e->b.x+e->b.w-1 && e->b.x+e->b.w-1<=mario.p.x+mario.p.w-1);
bool y_collide= (mario.p.y<=e->b.y && e->b.y<=mario.p.y+mario.p.h-1) || (mario.p.y<=e->b.y+e->b.h-1 && e->b.y+e->b.h-1<=mario.p.y+mario.p.h-1);
return (x_collide&&y_collide);
bool y_collide= (mario.p.y<=e->b.y && e->b.y<=mario.p.y+mario.p.h-1) || (mario.p.y<=e->b.y+e->b.h-1 && e->b.y+e->b.h-1<=mario.p.y+mario.p.h-1);
return (x_collide&&y_collide);
}
void hurt_mario()
{ if (mario.size==M_SMALL && mario_immunity==0)
{mario_dead=1;end_level=0;}
else
mario_smaller();
{mario_dead=1;end_level=0;}
else
mario_smaller();
}
void move_ennemi(ennemi_t *e)
{
if (e->b.x-e->b.w>world_get_real_x0() && e->b.x<world_get_real_x0()+128)
e->discovered=1;
if (e->b.x+e->b.w<=world_get_real_x0())
e->type=NONE;
if (e->discovered==0)
return;
if (e->life==DEAD)
return;
// e->type=NONE;
if (e->type==NONE)
return;
if (e->b.x-e->b.w>world_get_real_x0() && e->b.x<world_get_real_x0()+128)
e->discovered=1;
if (e->b.x+e->b.w<=world_get_real_x0())
e->type=NONE;
if (e->discovered==0)
return;
if (e->life==DEAD)
return;
// e->type=NONE;
if (e->type==NONE)
return;
bool e_hit_mario=ennemi_check_collision(e);
if (e_hit_mario&&mario_star_mode)
{
e->life=DEAD;
e->p1=0;
score_add(200);
}
bool e_hit_mario=ennemi_check_collision(e);
if (e_hit_mario&&mario_star_mode)
{
e->life=DEAD;
e->p1=0;
score_add(200);
return;
}
for (int i=0; i<ennemis_global_size; i++)
{
ennemi_t* t=&ennemis_global[i];
if (t!=e && t->discovered && t->type!=NONE)
{
for (int i=0; i<ennemis_global_size; i++)
{
ennemi_t* t=&ennemis_global[i];
if (t!=e && t->discovered && t->type!=NONE)
{
bool x_collide= (t->b.x<=e->b.x+e->b.vx && e->b.x+e->b.vx<t->b.x+t->b.w) || (t->b.x<=e->b.x+e->b.w-1+e->b.vx && e->b.x+e->b.w+e->b.vx<t->b.x+t->b.w);
bool y_collide= (t->b.y<=e->b.y+e->b.vy && e->b.y+e->b.vy<t->b.y+t->b.h) || (t->b.y<=e->b.y+e->b.h-1+e->b.vy && e->b.y+e->b.h+e->b.vy<t->b.y+t->b.h);
if (x_collide&&y_collide && t->life!=DEAD)
{
if (e->type!=CARAPACE_VERTE && e->type!=CARAPACE_ROUGE)
{
e->b.vx=0;
e->b.vy=0;
}
else
{
if (t->type==CARAPACE_VERTE || t->type==CARAPACE_ROUGE)
{
e->p1*=-1;
e->b.vx=6*e->p1;
}
else
{
t->life=DEAD;
t->p1=0;
score_add(200);
}
bool x_collide= (t->b.x<=e->b.x+e->b.vx && e->b.x+e->b.vx<t->b.x+t->b.w) || (t->b.x<=e->b.x+e->b.w-1+e->b.vx && e->b.x+e->b.w+e->b.vx<t->b.x+t->b.w);
bool y_collide= (t->b.y<=e->b.y+e->b.vy && e->b.y+e->b.vy<t->b.y+t->b.h) || (t->b.y<=e->b.y+e->b.h-1+e->b.vy && e->b.y+e->b.h+e->b.vy<t->b.y+t->b.h);
if (x_collide&&y_collide && t->life!=DEAD)
{
if (e->type!=CARAPACE_VERTE && e->type!=CARAPACE_ROUGE)
{
e->b.vx=0;
e->b.vy=0;
}
else
{
if (t->type==CARAPACE_VERTE || t->type==CARAPACE_ROUGE)
{
e->p1*=-1;
e->b.vx=6*e->p1;
}
else
{
t->life=DEAD;
t->p1=0;
score_add(200);
}
}
}
}
}
for (int i=0; i<ennemis_global_size; i++)
{
for (int j=0; j<e->b.h; j++)
{
gift_t * c=world_get(e->b.x+j ,e->b.y-1);
if ((c->type==GIFT || c->type==BRICK) && (c->time_hit_id || c->state))
{
e->life=DEAD;
e->p1=0;
score_add(100);
break;
}
}
}
}
}
}
}
int previous_case=-5;
for (int j=0; j<e->b.h; j++)
{
if ((e->b.x+j)/8!=previous_case)
{
previous_case=(e->b.x+j)/8;
gift_t * c=(gift_t*)world_get(e->b.x+j ,e->b.y-1);
if ((c->type==GIFT || c->type==BRICK) && (c->time_hit_id || c->state) && e->life!=DEAD)
{
e->life=DEAD;
e->p1=0;
score_add(100);
break;
}
}
}
if (e->type==GOOMBA_ID)
{
box_move(&e->b);
if (e->type==GOOMBA_ID)
{
box_move(&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;
}
}
if (e->b.y<0)
e->type=NONE;
if (e_hit_mario)
{
if (mario.p.last_vy<=-2)
{
e->life=DEAD;
e->p1=0;
score_add(200);
mario.p.vy=4;
mario.p.y=e->b.y+CARAPACE_Y;
}
else
hurt_mario();
}
}
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;
}
}
if (e->b.y<0)
e->type=NONE;
if (e_hit_mario)
{
if (mario.p.last_vy<=-2)
{
e->life=DEAD;
e->p1=0;
score_add(200);
mario.p.vy=4;
mario.p.y=e->b.y+CARAPACE_Y+1;
}
else
hurt_mario();
}
}
if (e->type==KOOPA_V_ID)
{
box_move(&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;
}
}
if (e->b.y<0)
e->type=NONE;
if (e_hit_mario)
{
if (mario.p.last_vy<=-2)
{
e->type=CARAPACE_VERTE;
e->b.h=CARAPACE_Y;
e->p1=2;
e->b.vx=0;
score_add(200);
mario.p.vy=4;
mario.p.y=e->b.y+CARAPACE_Y+1;
}
else
hurt_mario();
}
}
if (e->type==CARAPACE_VERTE)
{
box_move(&e->b);
if (e->type==KOOPA_V_ID)
{
box_move(&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;
}
}
if (e->b.y<0)
e->type=NONE;
if (e_hit_mario)
{
if (mario.p.last_vy<=-2)
{
e->type=CARAPACE_VERTE;
e->b.h=CARAPACE_Y;
e->p1=2;
e->b.vx=0;
score_add(200);
mario.p.vy=4;
mario.p.y=e->b.y+CARAPACE_Y+1;
}
else
hurt_mario();
}
}
if (e->type==CARAPACE_VERTE)
{
box_move(&e->b);
if (e->b.vx==0)
{
if (e->p1<2)
{
e->p1*=-1;
e->b.vx=6*e->p1;
}
}
if (e->b.y<0)
e->type=NONE;
if (e->p1>=2)
{
e->p1++;
if (e->p1==80)
{
e->type=KOOPA_V_ID;
e->b.h=KOOPA_Y;
e->p1=0;
e->b.vx=0;
}
}
if (e->b.vx==0)
{
if (e->p1<2)
{
e->p1*=-1;
e->b.vx=6*e->p1;
}
}
if (e->b.y<0)
e->type=NONE;
if (e->p1>=2)
{
e->p1++;
if (e->p1==80)
{
e->type=KOOPA_V_ID;
e->b.h=KOOPA_Y;
e->p1=0;
e->b.vx=0;
}
}
if (e_hit_mario)
{
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;
e->b.vx=6*e->p1;
if (mario.p.last_vy<=-2)
{
mario.p.vy=4;
mario.p.y=e->b.y+CARAPACE_Y;
}
else
{
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
{
if (mario.p.last_vy<=-2)
{
e->p1=0;
e->b.vx=0;
mario.p.vy=4;
mario.p.y=e->b.y+CARAPACE_Y+1;
}
else
hurt_mario();
}
}
}
if (e_hit_mario)
{
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;
e->b.vx=6*e->p1;
if (mario.p.last_vy<=-2)
{
mario.p.vy=4;
mario.p.y=e->b.y+CARAPACE_Y;
}
else
{
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
{
if (mario.p.last_vy<=-2)
{
e->p1=0;
e->b.vx=0;
mario.p.vy=4;
mario.p.y=e->b.y+CARAPACE_Y+1;
}
else
hurt_mario();
}
}
}
}
@ -282,9 +285,9 @@ ennemi_t * ennemis_global=0;
int ennemis_global_size=0;
void display_ennemi_table()
{
for (int i=0; i<ennemis_global_size; i++)
{
move_ennemi(&ennemis_global[i]);
display_ennemi(&ennemis_global[i]);
}
}
for (int i=0; i<ennemis_global_size; i++)
{
move_ennemi(&ennemis_global[i]);
display_ennemi(&ennemis_global[i]);
}
}

View File

@ -194,12 +194,33 @@ void set_level(int n)
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BUISSON,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BUISSON,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x01}, {EARTH,0x10}, {COLLINE,0x01}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {COLLINE,0x11}, {COLLINE,0x01}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {COLLINE,0x11}, {COLLINE,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {COLLINE,0x11}, {COLLINE,0x21}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0x11}, {0,0x10},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0x21}, {0,0x20},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x21}, {EARTH,0x20}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00}, {0,0},
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0},
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20}, {0,0},
{EARTH,0x01}, {EARTH,0x00}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
{EARTH,0x11}, {EARTH,0x10}, {BLOC,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
};
lvl=(world_t*)&level_0;
extern image_t img_lvl0;
w_fond=&img_lvl0;
w_current_x=137;
w_current_x=158;
w_current_y=13;
mario_x_max=0;
mario.p.x=25;
@ -242,4 +263,4 @@ void get_lvl_id(int n, char * str)
str[2]='2';
return;
}
}
}

View File

@ -7,6 +7,7 @@
#include "box.h"
#include "score.h"
#include "bonus.h"
#include "teleporteur.h"
static int sgn(int x)
{
@ -29,12 +30,12 @@ pnj mario=
};
int mario_x_max=0;
int mario_has_bullets=0;
int mario_time_accel=0;
static int mario_time_accel=0;
int mario_dead=0;
int mario_coins=0;
//static int mario_coins=0;
int last_vx_sign=1;
int last_bonus=0;
int mario_accel=0;
//static int last_bonus=0;
static int mario_accel=0;
int mario_immunity=0;
int mario_star_mode=0;
@ -58,7 +59,7 @@ void mario_smaller()
void mario_draw()
{
if (mario_immunity==0 || (mario_immunity/7)%2==0)
if ( (mario_immunity==0 || (mario_immunity/7)%2==0) && (mario_star_mode/2)%2==0)
{
if (mario.size==M_SMALL)
{
@ -108,13 +109,19 @@ int test_sol_le_plus_proche(int x, int y)
int global_quit=0;
void mario_move()
{
if (mario_star_mode)
{
mario_star_mode++;
if (mario_star_mode==200)
mario_star_mode=0;
}
if (mario_immunity)
{
mario_immunity++;
if (mario_immunity==60)
mario_immunity=0;
}
id_frame++;
update_keyboard();
if (mario_has_bullets==1 && keys[MK_RUN]==2)
@ -122,14 +129,14 @@ void mario_move()
lance_bullet();
}
int jump = keys[MK_JUMP1] || keys[MK_JUMP2];
if (keys[MK_JUMP1]==2 || keys[MK_JUMP2]==2)
{
if (mario.p.vx*sgn(mario.p.vx)>=3)
if (keys[MK_JUMP1]==2 || keys[MK_JUMP2]==2)
{
if (mario.p.vx*sgn(mario.p.vx)>=6)
box_jump(&mario.p, 9);
else
box_jump(&mario.p, 8);
}
else if (mario.p.vy>=6 && jump==0)
else if (mario.p.vy>=6 && jump==0)
mario.p.vy=5;
int vx=sgn(keys[MK_RIGHT] - keys[MK_LEFT]);
@ -149,14 +156,14 @@ void mario_move()
{
if (keys[MK_RUN] && (c1==CTG_SOIL || c2==CTG_SOIL))
{
if(mario.p.vx*sgn(mario.p.vx)<=8)
if(mario.p.vx*sgn(mario.p.vx)<=8)
mario.p.vx+=vx;
}
else
{
if (mario.p.vx*vx<4)
mario.p.vx+=vx;
}
if (keys[MK_RUN]==0)
{
@ -169,7 +176,7 @@ void mario_move()
{
if (mario.p.vx)
{
if (mario_accel)
if (mario_accel)
{
mario_time_accel++;
mario_time_accel%=4;
@ -200,7 +207,7 @@ void mario_move()
mario.p.vx=0;
mario.p.x=world_get_real_x0(mario.p.x);
}
teleporteurs_check();
box_move(&mario.p); // <-> + gravity
if (mario.p.y<0)
@ -213,13 +220,13 @@ void mario_move()
c=(coin_t*)world_get(mario.p.x, mario.p.y);
if (c->type==COIN && c->taken==0)
{score_add_coin();c->taken=1;}
c=world_get(mario.p.x+mario.p.w-1, mario.p.y);
c=(coin_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y);
if (c->type==COIN && c->taken==0)
{score_add_coin();c->taken=1;}
c=world_get(mario.p.x, mario.p.y+mario.p.h-1);
c=(coin_t*)world_get(mario.p.x, mario.p.y+mario.p.h-1);
if (c->type==COIN && c->taken==0)
{score_add_coin();c->taken=1;}
c=world_get(mario.p.x+mario.p.w-1, mario.p.y+mario.p.h-1);
c=(coin_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y+mario.p.h-1);
if (c->type==COIN && c->taken==0)
{score_add_coin();c->taken=1;}
@ -251,6 +258,12 @@ void mario_move()
bonus_set(BONUS_1UP,((mario.p.x+mario.p.w/2)/8)*8,mario.p.y+mario.p.h+8);
c->time_hit_id=1;
}
else if (c->content==4 && c->number)
{
c->number--;
bonus_set(BONUS_STAR,((mario.p.x+mario.p.w/2)/8)*8,mario.p.y+mario.p.h+8);
c->time_hit_id=1;
}
else if (c->content==0 && mario.size==M_BIG && c->type==BRICK)
{
c->state=1;
@ -267,4 +280,3 @@ void mario_move()
//}
}

43
src/teleporteur.c Normal file
View File

@ -0,0 +1,43 @@
#include "teleporteur.h"
#include "mario.h"
#include "keyboard.h"
#include <stdbool.h>
teleporteur_t *teleporteurs=0;
int nombre_teleporteurs=1;
static void check_teleporteur(teleporteur_t * t)
{
if (t->active==0)
return;
bool x=(mario.p.x<=t->x && mario.p.x+mario.p.w>t->x);
bool y=(mario.p.y<=t->y && mario.p.y+mario.p.h>t->y);
if (x&&y)
{
if (t->key==-1)
{
mario_x_max=0;
mario.p.x=t->target_x;
mario.p.y=t->target_y;
mario.p.vx=0;
mario.p.vy=0;
sleep_ms(3,500);
}
else if (keys[t->key])
{
mario_x_max=0;
mario.p.x=t->target_x;
mario.p.y=t->target_y;
mario.p.vx=0;
mario.p.vy=0;
sleep_ms(3,500);
}
}
}
void teleporteurs_check()
{
for (int i=0; i<nombre_teleporteurs; i++)
check_teleporteur(&teleporteurs[i]);
}

20
src/teleporteur.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef TELEPORTEUR_H
#define TELEPORTEUR_H
typedef struct
{
int x;
int y;
int active;
int key; // -1 if no key, ou sinon le keycode (MK)
int target_x;
int target_y;
} teleporteur_t;
void teleporteurs_check();
extern teleporteur_t *teleporteurs;
extern int nombre_teleporteurs;
#endif

View File

@ -35,6 +35,9 @@ const tileset_t champi={&img_champi, TILE_W, TILE_H, 0};
extern image_t img_1up;
const tileset_t life_1up={&img_1up, TILE_W, TILE_H, 0};
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};

View File

@ -26,6 +26,7 @@ extern const tileset_t colline;
extern const tileset_t champi;
extern const tileset_t fleur;
extern const tileset_t life_1up;
extern const tileset_t mario_starman;
extern const tileset_t bullet;