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/bonus.c

94 lines
1.8 KiB

#include "bonus.h"
#include "box.h"
#include "mario.h"
#include "world.h"
#include "tile.h"
#include "score.h"
#include "ennemi.h"
#include "constants.h"
#include <stdbool.h>
#include <base.h>
#include <camera.h>
static bonus_t bonus ={BONUS_NONE, {0,0,TILE_W,TILE_H,0,0,0,1}, 0};
void bonusSet(bonus_id t, int x, int y)
{
bonus.type=t;
if (mario.size==M_BIG && t==BONUS_CHAMPI)
bonus.type=BONUS_FLEUR;
bonus.b.x=x;
bonus.b.y=y;
bonus.b.vx=0;
bonus.b.vy=0;
bonus.p1=0;
}
void bonusMove() //+collision
{
if (bonus.type==BONUS_NONE)
return;
if (bonus.type==BONUS_STAR)
{
boxJump(&bonus.b,4);
}
boxMove(&bonus.b);
if (bonus.type==BONUS_CHAMPI || bonus.type==BONUS_1UP || bonus.type==BONUS_STAR)
{
if (bonus.b.vx==0)
{
if (bonus.p1==0)
{
bonus.b.vx=2;
bonus.p1=1;
}
else
{
bonus.p1*=-1;
bonus.b.vx=2*bonus.p1;
}
}
if (bonus.b.y<0)
bonusSet(BONUS_NONE,0,0);
}
int collide=boxContact(&mario.p, &bonus.b);
if (collide && bonus.type!=BONUS_NONE)
{
switch (bonus.type)
{
case BONUS_CHAMPI:
case BONUS_FLEUR:
if (mario.size==M_SMALL) marioBigger();
else mario_has_bullets=1;
break;
case BONUS_1UP:
lifesAdd(1);
break;
case BONUS_STAR:
bonusSet(BONUS_NONE,0,0);
mario_starMode=1;
}
scoreAdd(1000);
bonusSet(BONUS_NONE,0,0);
}
}
void bonusDraw()
{
//bonusMove();
if (bonus.type==BONUS_NONE)
return;
if (bonus.type==BONUS_CHAMPI)
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &champi, 0,0);
if (bonus.type==BONUS_FLEUR)
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &fleur, 0,0);
if (bonus.type==BONUS_1UP)
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &life_1up, 0,0);
if (bonus.type==BONUS_STAR)
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &mario_starman, 0,0);
}