2019-12-05 19:24:16 +01:00
|
|
|
#include "bonus.h"
|
|
|
|
#include "box.h"
|
|
|
|
#include "mario.h"
|
|
|
|
#include "world.h"
|
|
|
|
#include "tile.h"
|
2019-12-07 14:32:38 +01:00
|
|
|
#include "score.h"
|
|
|
|
#include "ennemi.h"
|
2019-12-11 16:31:18 +01:00
|
|
|
#include "constants.h"
|
2019-12-05 19:24:16 +01:00
|
|
|
#include <stdbool.h>
|
2020-01-29 14:34:47 +01:00
|
|
|
#include <base.h>
|
2020-01-29 18:24:33 +01:00
|
|
|
#include <camera.h>
|
2019-12-05 19:24:16 +01:00
|
|
|
|
2019-12-11 16:31:18 +01:00
|
|
|
static bonus_t bonus ={BONUS_NONE, {0,0,TILE_W,TILE_H,0,0,0,1}, 0};
|
2019-12-05 19:24:16 +01:00
|
|
|
|
2020-02-16 20:43:35 +01:00
|
|
|
void bonusSet(bonus_id t, int x, int y)
|
2019-12-05 19:24:16 +01:00
|
|
|
{
|
2020-01-29 14:34:47 +01:00
|
|
|
bonus.type=t;
|
|
|
|
if (mario.size==M_BIG && t==BONUS_CHAMPI)
|
2019-12-05 19:24:16 +01:00
|
|
|
bonus.type=BONUS_FLEUR;
|
|
|
|
bonus.b.x=x;
|
|
|
|
bonus.b.y=y;
|
|
|
|
bonus.b.vx=0;
|
|
|
|
bonus.b.vy=0;
|
|
|
|
bonus.p1=0;
|
|
|
|
}
|
|
|
|
|
2020-02-16 20:43:35 +01:00
|
|
|
void bonusMove() //+collision
|
2019-12-05 19:24:16 +01:00
|
|
|
{
|
|
|
|
if (bonus.type==BONUS_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (bonus.type==BONUS_STAR)
|
|
|
|
{
|
2020-02-16 20:43:35 +01:00
|
|
|
boxJump(&bonus.b,4);
|
2019-12-05 19:24:16 +01:00
|
|
|
}
|
2020-02-16 20:43:35 +01:00
|
|
|
boxMove(&bonus.b);
|
2019-12-05 19:24:16 +01:00
|
|
|
if (bonus.type==BONUS_CHAMPI || bonus.type==BONUS_1UP || bonus.type==BONUS_STAR)
|
|
|
|
{
|
2020-02-16 12:51:27 +01:00
|
|
|
|
2019-12-05 19:24:16 +01:00
|
|
|
if (bonus.b.vx==0)
|
|
|
|
{
|
|
|
|
if (bonus.p1==0)
|
|
|
|
{
|
2019-12-16 19:23:36 +01:00
|
|
|
bonus.b.vx=2;
|
2019-12-05 19:24:16 +01:00
|
|
|
bonus.p1=1;
|
|
|
|
}
|
2020-02-16 12:51:27 +01:00
|
|
|
else
|
2019-12-05 19:24:16 +01:00
|
|
|
{
|
|
|
|
bonus.p1*=-1;
|
2020-01-30 21:18:03 +01:00
|
|
|
bonus.b.vx=2*bonus.p1;
|
2019-12-05 19:24:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bonus.b.y<0)
|
2020-02-16 20:43:35 +01:00
|
|
|
bonusSet(BONUS_NONE,0,0);
|
2019-12-05 19:24:16 +01:00
|
|
|
}
|
|
|
|
|
2020-02-16 20:43:35 +01:00
|
|
|
int collide=boxContact(&mario.p, &bonus.b);
|
2020-02-16 12:51:27 +01:00
|
|
|
if (collide)
|
2019-12-05 19:24:16 +01:00
|
|
|
{
|
|
|
|
if (bonus.type==BONUS_CHAMPI)
|
|
|
|
{
|
2020-02-16 20:43:35 +01:00
|
|
|
bonusSet(BONUS_NONE,0,0);
|
|
|
|
scoreAdd(1000);
|
|
|
|
marioBigger();
|
2019-12-05 19:24:16 +01:00
|
|
|
}
|
|
|
|
if (bonus.type==BONUS_FLEUR)
|
|
|
|
{
|
2020-02-16 20:43:35 +01:00
|
|
|
bonusSet(BONUS_NONE,0,0);
|
2019-12-05 19:24:16 +01:00
|
|
|
mario_has_bullets=1;
|
2020-02-16 20:43:35 +01:00
|
|
|
scoreAdd(1000);
|
2019-12-05 19:24:16 +01:00
|
|
|
}
|
2019-12-07 14:32:38 +01:00
|
|
|
if (bonus.type==BONUS_1UP)
|
|
|
|
{
|
2020-02-16 20:43:35 +01:00
|
|
|
bonusSet(BONUS_NONE,0,0);
|
|
|
|
scoreAdd(1000);
|
|
|
|
lifesAdd(1);
|
2019-12-07 14:32:38 +01:00
|
|
|
}
|
2019-12-16 19:23:36 +01:00
|
|
|
if (bonus.type==BONUS_STAR)
|
|
|
|
{
|
2020-02-16 20:43:35 +01:00
|
|
|
bonusSet(BONUS_NONE,0,0);
|
|
|
|
scoreAdd(1000);
|
|
|
|
mario_starMode=1;
|
2019-12-16 19:23:36 +01:00
|
|
|
}
|
2019-12-05 19:24:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 20:43:35 +01:00
|
|
|
void bonusDraw()
|
2019-12-05 19:24:16 +01:00
|
|
|
{
|
2020-02-16 20:43:35 +01:00
|
|
|
//bonusMove();
|
2019-12-05 19:24:16 +01:00
|
|
|
if (bonus.type==BONUS_NONE)
|
|
|
|
return;
|
|
|
|
if (bonus.type==BONUS_CHAMPI)
|
2020-02-16 20:43:35 +01:00
|
|
|
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &champi, 0,0);
|
2019-12-05 19:24:16 +01:00
|
|
|
if (bonus.type==BONUS_FLEUR)
|
2020-02-16 20:43:35 +01:00
|
|
|
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &fleur, 0,0);
|
2019-12-07 14:32:38 +01:00
|
|
|
if (bonus.type==BONUS_1UP)
|
2020-02-16 20:43:35 +01:00
|
|
|
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &life_1up, 0,0);
|
2019-12-16 19:23:36 +01:00
|
|
|
if (bonus.type==BONUS_STAR)
|
2020-02-16 20:43:35 +01:00
|
|
|
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &mario_starman, 0,0);
|
2020-02-16 12:51:27 +01:00
|
|
|
}
|