Le nouveau Super Mario Bros pour la gamme des fx9860g https://www.planet-casio.com/Fr/forums/topic15994-1-[addin]-SuperCasioBros-v0.1.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
supercasiobros/src/bullet.c

65 lines
1.6 KiB

#include <bullets.h>
#include <bonus.h>
#include <constants.h>
#include <mario.h>
#include <tile.h>
#include <camera.h>
#include <base.h>
#include <ennemi.h>
#include <score.h>
/* Les balles ont les memes propriétés que les boulets et sont donc gérées ici */
static bonus_t bullets[2] =
{
{0, {0,0,TILE_W/2,TILE_H/2,0,0,0,1}, 0},
{0, {0,0,TILE_W/2,TILE_H/2,0,0,0,1}, 0}
};
void bulletThrow()
{
for (int i=0; i<2; i++)
{
if (bullets[i].type==0)
{
bullets[i].type=1;
bullets[i].b.x=mario.p.x;
bullets[i].b.y=mario.p.y+8;
if (mario.last_vx_sgn==0) bullets[i].b.vx=-9; //speed = 9
else bullets[i].b.vx=9;
bullets[i].b.vy=0;
bullets[i].p1=mario.last_vx_sgn;
return;
}
}
}
void bulletsDraw()
{
for (int i=0; i<2; i++) if (bullets[i].type==1) tileDraw(bullets[i].b.x-cameraX(), bullets[i].b.y-cameraY(), &bullet, (1+sgn(bullets[i].b.vy))/2, 0);
}
void bulletsMove()
{
for (int i=0; i<2; i++) if (bullets[i].type) // bullet active
{
boxJump( &bullets[i].b, 4, true);
boxMove(&bullets[i].b);
if (bullets[i].b.vx==0) bullets[i].type=0; // delete a bullet if it is stopped
if (bullets[i].b.y<0) bullets[i].type=0; // delete a bullet if it is out of the map
if (bullets[i].b.x<=cameraX()-bullets[i].b.w || bullets[i].b.x>=cameraX()+127) bullets[i].type=0; // delete a bullet if it is out of the screen
// contact with ennemies
for (int a=0; a<ennemiesNumber(); a++) if (ennemis_global[a].type!=NONE && boxContact(&bullets[i].b, &ennemis_global[a].b))
{
ennemis_global[a].life=DEAD;
bullets[i].type=0;
scoreAdd(KILL_ENNEMI);
break;
}
}
}