ajout grand mario, bullets, fleur et decalage auto
BIN
SuperCbr.g1a
After Width: | Height: | Size: 547 B |
After Width: | Height: | Size: 618 B |
After Width: | Height: | Size: 577 B |
After Width: | Height: | Size: 551 B |
After Width: | Height: | Size: 632 B |
After Width: | Height: | Size: 588 B |
After Width: | Height: | Size: 756 B |
After Width: | Height: | Size: 622 B |
882
build-fx/map
|
@ -0,0 +1,12 @@
|
|||
build-fx/src/bonus.c.o: src/bonus.c src/bonus.h src/box.h src/mario.h \
|
||||
src/world.h src/tile.h
|
||||
|
||||
src/bonus.h:
|
||||
|
||||
src/box.h:
|
||||
|
||||
src/mario.h:
|
||||
|
||||
src/world.h:
|
||||
|
||||
src/tile.h:
|
|
@ -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/world.h src/keyboard.h src/score.h src/bonus.h
|
||||
|
||||
src/mario.h:
|
||||
|
||||
|
@ -12,3 +12,5 @@ src/world.h:
|
|||
src/keyboard.h:
|
||||
|
||||
src/score.h:
|
||||
|
||||
src/bonus.h:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
build-fx/src/world.c.o: src/world.c src/world.h src/tile.h src/mario.h \
|
||||
src/box.h src/ennemi.h
|
||||
src/box.h src/ennemi.h src/bonus.h
|
||||
|
||||
src/world.h:
|
||||
|
||||
|
@ -10,3 +10,5 @@ src/mario.h:
|
|||
src/box.h:
|
||||
|
||||
src/ennemi.h:
|
||||
|
||||
src/bonus.h:
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
#include "bonus.h"
|
||||
#include "box.h"
|
||||
#include "mario.h"
|
||||
#include "world.h"
|
||||
#include "tile.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define BONUS_FLEUR 4 // interne, généré depuis champi
|
||||
#define BULLET 1
|
||||
typedef struct
|
||||
{
|
||||
int type;
|
||||
box_t b;
|
||||
int p1;
|
||||
} bonus_t;
|
||||
|
||||
static int sgn(int x)
|
||||
{
|
||||
if (x>0)
|
||||
return 1;
|
||||
else if (x<0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static bonus_t bonus ={BONUS_NONE, {0,0,8,8,0,0,1}, 0};
|
||||
/* 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,4,4,0,0,1}, 0},{0, {0,0,4,4,0,0,1}, 0}};
|
||||
|
||||
void lance_bullet()
|
||||
{
|
||||
for (int i=0; i<2; i++)
|
||||
{
|
||||
if (bullets[i].type==0)
|
||||
{
|
||||
bullets[i].type=BULLET;
|
||||
bullets[i].b.x=mario.p.x;
|
||||
bullets[i].b.y=mario.p.y+8;
|
||||
bullets[i].b.vx=4*last_vx_sign-2;
|
||||
bullets[i].b.vy=0;
|
||||
bullets[i].p1=last_vx_sign;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void bullet_display()
|
||||
{
|
||||
for (int i=0; i<2; i++)
|
||||
{
|
||||
if (bullets[i].type==BULLET)
|
||||
{
|
||||
box_jump(&bullets[i].b,4);
|
||||
box_move(&bullets[i].b);
|
||||
draw_tile(bullets[i].b.x-world_get_real_x0(), bullets[i].b.y-world_get_real_y0(), &bullet, 1+sgn(bullets[i].b.vy)/2, 0);
|
||||
if (bullets[i].b.vx==0)
|
||||
{
|
||||
bullets[i].p1*=-1;
|
||||
bullets[i].b.vx=4*bullets[i].p1;
|
||||
}
|
||||
if (bullets[i].b.y<0)
|
||||
bullets[i].type=0;
|
||||
if (bullets[i].b.x<=world_get_real_x0()-bullets[i].b.w || bullets[i].b.x>=world_get_real_x0()+127)
|
||||
bullets[i].type=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bonus_set(int type, int x, int y)
|
||||
{
|
||||
bonus.type=type;
|
||||
if (mario.size==M_BIG && type==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 bonus_move() //+collision
|
||||
{
|
||||
if (bonus.b.x<=world_get_real_x0()-bonus.b.w || bonus.b.x>=world_get_real_x0()+127)
|
||||
bonus_set(BONUS_NONE,0,0);
|
||||
if (bonus.type==BONUS_NONE)
|
||||
return;
|
||||
|
||||
|
||||
if (bonus.type==BONUS_STAR)
|
||||
{
|
||||
box_jump(&bonus.b,5);
|
||||
}
|
||||
box_move(&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=1;
|
||||
bonus.p1=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bonus.p1*=-1;
|
||||
bonus.b.vx=bonus.p1;
|
||||
}
|
||||
}
|
||||
if (bonus.b.y<0)
|
||||
bonus_set(BONUS_NONE,0,0);
|
||||
}
|
||||
|
||||
bool x_collide= (mario.p.x<=bonus.b.x && bonus.b.x<mario.p.x+mario.p.w) || (mario.p.x<=bonus.b.x+bonus.b.w-1 && bonus.b.x+bonus.b.w<mario.p.x+mario.p.w);
|
||||
bool y_collide= (mario.p.y<=bonus.b.y && bonus.b.y<mario.p.y+mario.p.h) || (mario.p.y<=bonus.b.y+bonus.b.h-1 && bonus.b.y+bonus.b.h<mario.p.y+mario.p.h);
|
||||
if (x_collide&&y_collide)
|
||||
{
|
||||
if (bonus.type==BONUS_CHAMPI)
|
||||
{
|
||||
bonus_set(BONUS_NONE,0,0);
|
||||
score_add(1000);
|
||||
mario_bigger();
|
||||
}
|
||||
if (bonus.type==BONUS_FLEUR)
|
||||
{
|
||||
bonus_set(BONUS_NONE,0,0);
|
||||
mario_has_bullets=1;
|
||||
score_add(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bonus_draw()
|
||||
{
|
||||
bonus_move();
|
||||
if (bonus.type==BONUS_NONE)
|
||||
return;
|
||||
if (bonus.type==BONUS_CHAMPI)
|
||||
draw_tile(bonus.b.x-world_get_real_x0(), bonus.b.y-world_get_real_y0(mario.p.y), &champi, 0,0);
|
||||
if (bonus.type==BONUS_FLEUR)
|
||||
draw_tile(bonus.b.x-world_get_real_x0(), bonus.b.y-world_get_real_y0(mario.p.y), &fleur, 0,0);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef BONUS_H
|
||||
#define BONUS_H
|
||||
|
||||
#define BONUS_NONE 0
|
||||
#define BONUS_CHAMPI 1
|
||||
#define BONUS_1UP 2
|
||||
#define BONUS_STAR 3
|
||||
|
||||
|
||||
void bonus_set(int type, int x, int y);
|
||||
|
||||
void bonus_draw(); //&move &collide
|
||||
void lance_bullet();
|
||||
void bullet_display();
|
||||
|
||||
#endif
|
35
src/box.c
|
@ -44,6 +44,7 @@ static void move_x(box_t * b)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void move_y(box_t * b)
|
||||
{
|
||||
int sgn_vy=sgn(b->vy);
|
||||
|
@ -65,9 +66,37 @@ static void move_y(box_t * b)
|
|||
typetemp=world_get_ctg(b->x+j ,b->y-i);
|
||||
if (/*typetemp==CTG_DEATH ||*/ typetemp==CTG_SOIL)
|
||||
{
|
||||
b->y+=(i-1)*sgn_vy;
|
||||
b->vy=0;
|
||||
return;
|
||||
if (b->vy>0)
|
||||
{
|
||||
int old=b->x;
|
||||
if (world_get_ctg(b->x+2, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+3, b->y+b->h-1+i)==CTG_EMPTY)
|
||||
b->x++;
|
||||
if (world_get_ctg(b->x+1, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+2, b->y+b->h-1+i)==CTG_EMPTY)
|
||||
b->x++;
|
||||
if (world_get_ctg(b->x, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+1, b->y+b->h-1+i)==CTG_EMPTY)
|
||||
b->x++;
|
||||
|
||||
if (world_get_ctg(b->x+b->w-3, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+b->w-4, b->y+b->h-1+i)==CTG_EMPTY)
|
||||
b->x--;
|
||||
if (world_get_ctg(b->x+b->w-2, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+b->w-3, b->y+b->h-1+i)==CTG_EMPTY)
|
||||
b->x--;
|
||||
if (world_get_ctg(b->x+b->w-1, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+b->w-2, b->y+b->h-1+i)==CTG_EMPTY)
|
||||
b->x--;
|
||||
if (old==b->x)
|
||||
{
|
||||
b->y+=(i-1)*sgn_vy;
|
||||
b->vy=0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
b->y+=(i-1)*sgn_vy;
|
||||
b->vy=0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
43
src/ennemi.c
|
@ -11,7 +11,7 @@ void display_ennemi(ennemi_t * e)
|
|||
{
|
||||
if (e->life==DEAD)
|
||||
return;
|
||||
if (e->b.x-e->b.w<=world_get_real_x0(0) || e->b.x>=world_get_real_x0(0)+127)
|
||||
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;
|
||||
|
@ -29,18 +29,32 @@ void display_ennemi(ennemi_t * e)
|
|||
|
||||
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) || (mario.p.x<=e->b.x+e->b.w-1 && e->b.x+e->b.w<mario.p.x+mario.p.w);
|
||||
bool y_collide= (mario.p.y<=e->b.y && e->b.y<mario.p.y+mario.p.h) || (mario.p.y<=e->b.y+e->b.h-1 && e->b.y+e->b.h<mario.p.y+mario.p.h);
|
||||
return (x_collide&&y_collide);
|
||||
if (mario_immunity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool x_collide= (mario.p.x<=e->b.x && e->b.x<mario.p.x+mario.p.w) || (mario.p.x<=e->b.x+e->b.w-1 && e->b.x+e->b.w<mario.p.x+mario.p.w);
|
||||
bool y_collide= (mario.p.y<=e->b.y && e->b.y<mario.p.y+mario.p.h) || (mario.p.y<=e->b.y+e->b.h-1 && e->b.y+e->b.h<mario.p.y+mario.p.h);
|
||||
return (x_collide&&y_collide);
|
||||
}
|
||||
}
|
||||
|
||||
void hurt_mario()
|
||||
{
|
||||
if (mario.size=M_SMALL)
|
||||
mario_dead=1;
|
||||
else
|
||||
mario_smaller();
|
||||
}
|
||||
|
||||
void move_ennemi(ennemi_t *e)
|
||||
{
|
||||
|
||||
if (e->b.x-e->b.w>world_get_real_x0(0) && e->b.x<world_get_real_x0(0)+127)
|
||||
if (e->b.x-e->b.w>world_get_real_x0() && e->b.x<world_get_real_x0()+127)
|
||||
e->discovered=1;
|
||||
if (e->b.x-e->b.w<=world_get_real_x0(0))
|
||||
if (e->b.x+e->b.w<=world_get_real_x0())
|
||||
e->type=NONE;
|
||||
if (e->discovered==0)
|
||||
return;
|
||||
|
@ -49,6 +63,21 @@ void move_ennemi(ennemi_t *e)
|
|||
if (e->type==NONE)
|
||||
return;
|
||||
|
||||
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)
|
||||
{
|
||||
e->b.vx=0;
|
||||
e->b.vy=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e->type==GOOMBA)
|
||||
{
|
||||
if (e->life==1)
|
||||
|
@ -87,7 +116,7 @@ void move_ennemi(ennemi_t *e)
|
|||
mario.p.vy=4;
|
||||
}
|
||||
else
|
||||
mario_dead=1;
|
||||
hurt_mario();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
131
src/level.c
|
@ -58,45 +58,116 @@ void set_level(int n)
|
|||
{
|
||||
world_t level_0[]=
|
||||
{
|
||||
{EARTH,0x00}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x10}, {TUYAU,0x03}, {TUYAU,0x02}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x10}, {TUYAU,0x13}, {TUYAU,0x12}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x00}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {COIN,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {GIFT,0x15}, {0,0}, {COIN,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {COIN,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x00}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x10}, {TUYAU,0x03}, {TUYAU,0x02}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x10}, {TUYAU,0x13}, {TUYAU,0x12}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x00}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {COIN,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {COIN,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {COIN,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0,0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x10}, {TUYAU,0x03}, {TUYAU,0x02}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x10}, {TUYAU,0x13}, {TUYAU,0x12}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x00}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}, {EARTH,0x01}
|
||||
{EARTH,0x01}, {EARTH,0x00}, {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}, {COLLINE,0x21}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {BUISSON,0x00}, {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}, {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}, {BUISSON,0x20}, {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,0x01}, {0,0}, {0,0}, {GIFT,0x11}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {COLLINE,0x11}, {COLLINE,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {COLLINE,0x21}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {GIFT,0x21}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0}, {GIFT,0x11}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {BUISSON,0x00}, {0,0}, {0,0}, {GIFT,0x11}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {BUISSON,0x10}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {BUISSON,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {TUYAU,0x03}, {TUYAU,0x02}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {TUYAU,0x13}, {TUYAU,0x12}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {TUYAU,0x03}, {TUYAU,0x03}, {TUYAU,0x02}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {TUYAU,0x13}, {TUYAU,0x13}, {TUYAU,0x12}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {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,0x00}, {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}, {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,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {TUYAU,0x03}, {TUYAU,0x03}, {TUYAU,0x03}, {TUYAU,0x02}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {TUYAU,0x13}, {TUYAU,0x13}, {TUYAU,0x13}, {TUYAU,0x12}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {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}, {COLLINE,0x21}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {TUYAU,0x03}, {TUYAU,0x03}, {TUYAU,0x03}, {TUYAU,0x02}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {TUYAU,0x13}, {TUYAU,0x13}, {TUYAU,0x13}, {TUYAU,0x12}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {BUISSON,0x00}, {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}, {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}, {BUISSON,0x20}, {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,0x01}, {0,0}, {0,0}, {0,0}, {GIFT,0x131}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {COLLINE,0x11}, {COLLINE,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {COLLINE,0x21}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20}, {0,0},
|
||||
{EARTH,0x21}, {EARTH,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x01}, {EARTH,0x00}, {BUISSON,0x00}, {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}, {BUISSON,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {GIFT,0x21}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x11}, {NUAGE,0x10}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {0,0}, {0,0},
|
||||
{EARTH,0x11}, {EARTH,0x10}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {BRICK,0}, {0,0}, {NUAGE,0x01}, {NUAGE,0x00},
|
||||
{EARTH,0x21}, {EARTH,0x20}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {BRICK,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}, {BRICK,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}, {BRICK,0}, {0,0}, {NUAGE,0x21}, {NUAGE,0x20},
|
||||
{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
|
||||
|
||||
};
|
||||
lvl=&level_0;
|
||||
extern image_t img_lvl0;
|
||||
w_fond=&img_lvl0;
|
||||
w_current_x=25;
|
||||
w_current_y=11;
|
||||
w_current_x=89;
|
||||
w_current_y=13;
|
||||
mario_x_max=0;
|
||||
mario.p.x=25;
|
||||
mario.p.y=16;
|
||||
init_level(lvl);
|
||||
|
||||
ennemis_global_size=1;
|
||||
ennemi_t ennemies0={GOOMBA,{120,16,8,8,-1,0,1},-1,0,1};
|
||||
init_ennemies(&ennemies0);
|
||||
ennemis_global_size=4;
|
||||
ennemi_t ennemies0[]=
|
||||
{
|
||||
{GOOMBA,{176,16,8,8,-1,0,1},-1,0,1},
|
||||
{GOOMBA,{321,16,8,8,-1,0,1},-1,0,1},
|
||||
{GOOMBA,{409,16,8,8,-1,0,1},-1,0,1},
|
||||
{GOOMBA,{419,16,8,8,-1,0,1},-1,0,1}
|
||||
};
|
||||
init_ennemies(ennemies0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ int main(void)
|
|||
{
|
||||
mario_dead=0;
|
||||
end_level=0;
|
||||
mario_smaller();
|
||||
}
|
||||
if (end_level==0)
|
||||
{
|
||||
|
|
115
src/mario.c
|
@ -6,6 +6,7 @@
|
|||
#include "keyboard.h"
|
||||
#include "box.h"
|
||||
#include "score.h"
|
||||
#include "bonus.h"
|
||||
|
||||
static int sgn(int x)
|
||||
{
|
||||
|
@ -21,6 +22,9 @@ extern image_t img_mariosmall;
|
|||
int id_frame=0;
|
||||
tileset_t mario_small={&img_mariosmall, 8,8, 1};
|
||||
|
||||
extern image_t img_mariobig;
|
||||
tileset_t mario_big={&img_mariobig, 8,16, 1};
|
||||
|
||||
pnj mario=
|
||||
{
|
||||
{26,17,8,8,0,0,1},
|
||||
|
@ -29,12 +33,30 @@ pnj mario=
|
|||
0
|
||||
};
|
||||
int mario_x_max=0;
|
||||
int mario_has_bullets=0;
|
||||
int mario_time_accel=0;
|
||||
int mario_dead=0;
|
||||
int mario_coins=0;
|
||||
int last_vx_sign=1;
|
||||
int last_bonus=0;
|
||||
int mario_accel=0;
|
||||
int mario_immunity=0;
|
||||
|
||||
void mario_bigger()
|
||||
{
|
||||
mario.p.h=16;
|
||||
mario.p.y-=7;
|
||||
mario.size=M_BIG;
|
||||
mario_has_bullets=0;
|
||||
}
|
||||
|
||||
void mario_smaller()
|
||||
{
|
||||
mario.p.h=8;
|
||||
mario.size=M_SMALL;
|
||||
mario_has_bullets=0;
|
||||
mario_immunity=1;
|
||||
}
|
||||
|
||||
void mario_draw()
|
||||
{
|
||||
|
@ -47,6 +69,15 @@ void mario_draw()
|
|||
else
|
||||
draw_tile(mario.p.x-world_get_real_x0(mario.p.x), mario.p.y-world_get_real_y0(mario.p.y), &mario_small, 2*last_vx_sign, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=3)
|
||||
draw_tile(mario.p.x-world_get_real_x0(mario.p.x), mario.p.y-world_get_real_y0(mario.p.y), &mario_big, 2*last_vx_sign+(id_frame/4)%2, mario_has_bullets);
|
||||
else if (mario.p.vx*sgn(mario.p.vx)>=1)
|
||||
draw_tile(mario.p.x-world_get_real_x0(mario.p.x), mario.p.y-world_get_real_y0(mario.p.y), &mario_big, 2*last_vx_sign+(id_frame/8)%2, mario_has_bullets);
|
||||
else
|
||||
draw_tile(mario.p.x-world_get_real_x0(mario.p.x), mario.p.y-world_get_real_y0(mario.p.y), &mario_big, 2*last_vx_sign, mario_has_bullets);
|
||||
}
|
||||
}
|
||||
|
||||
int test_sol_le_plus_proche(int x, int y)
|
||||
|
@ -76,15 +107,26 @@ int test_sol_le_plus_proche(int x, int y)
|
|||
int global_quit=0;
|
||||
void mario_move()
|
||||
{
|
||||
if (mario_immunity)
|
||||
{
|
||||
mario_immunity++;
|
||||
if (mario_immunity==40)
|
||||
mario_immunity=0;
|
||||
}
|
||||
|
||||
id_frame++;
|
||||
update_keyboard();
|
||||
if (mario_has_bullets==1 && keys[MK_RUN]==2)
|
||||
{
|
||||
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)
|
||||
box_jump(&mario.p, 8);
|
||||
box_jump(&mario.p, 9);
|
||||
else
|
||||
box_jump(&mario.p, 7);
|
||||
box_jump(&mario.p, 8);
|
||||
}
|
||||
else if (mario.p.vy>=6 && jump==0)
|
||||
mario.p.vy=5;
|
||||
|
@ -147,14 +189,10 @@ void mario_move()
|
|||
last_vx_sign=0;
|
||||
|
||||
if (mario.p.x+mario.p.vx<world_get_real_x0(mario.p.x))
|
||||
mario.p.vx=0;
|
||||
|
||||
|
||||
|
||||
mario.p.vx=0;
|
||||
|
||||
box_move(&mario.p); // <-> + gravity
|
||||
if (mario.p.x>mario_x_max)
|
||||
mario_x_max=mario.p.x;
|
||||
|
||||
if (mario.p.y<0)
|
||||
mario_dead=1;
|
||||
if (mario.p.vx==0)
|
||||
|
@ -175,48 +213,39 @@ void mario_move()
|
|||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
|
||||
// box
|
||||
if ((mario.p.x+mario.p.w/2)/8==(mario.p.x+mario.p.w/2-1)/8)
|
||||
{
|
||||
gift_t* c=(gift_t*)world_get((mario.p.x+mario.p.w/2),mario.p.y+mario.p.h);
|
||||
if (c->type==GIFT)
|
||||
{
|
||||
if (c->time_hit_id==0 && c->content==1 && c->number!=0) // piece
|
||||
{
|
||||
c->number--;
|
||||
c->time_hit_id=1;
|
||||
score_add_coin();
|
||||
}
|
||||
}
|
||||
}
|
||||
//if ((mario.p.x+mario.p.w/2)/8==(mario.p.x+mario.p.w/2-1)/8)
|
||||
//{
|
||||
gift_t* t=(gift_t*)world_get((mario.p.x+mario.p.w/2),mario.p.y+mario.p.h);
|
||||
|
||||
if ((mario.p.x+mario.p.w/2)/8==(mario.p.x+mario.p.w/2-1)/8)
|
||||
{
|
||||
world_t* t=(gift_t*)world_get((mario.p.x+mario.p.w/2),mario.p.y+mario.p.h);
|
||||
if (t->type==GIFT)
|
||||
{
|
||||
gift_t *c=(gift_t*)t;
|
||||
if (c->time_hit_id==0 && c->content==1 && c->number!=0) // piece
|
||||
{
|
||||
c->number--;
|
||||
c->time_hit_id=1;
|
||||
score_add_coin();
|
||||
}
|
||||
}
|
||||
if (t->type==BRICK)
|
||||
if (t->type==GIFT || t->type==BRICK)
|
||||
{
|
||||
brick_t *c=(brick_t*)t;
|
||||
if ((c->content==0 || c->number) && mario.size==M_SMALL) // piece
|
||||
|
||||
if (c->content==1 && c->number)
|
||||
{
|
||||
if (c->number)
|
||||
{
|
||||
c->number--;
|
||||
score_add_coin();
|
||||
}
|
||||
c->number--;
|
||||
score_add_coin();
|
||||
score_add(200);
|
||||
c->time_hit_id=1;
|
||||
}
|
||||
if (c->content==2 && c->number)
|
||||
{
|
||||
c->number--;
|
||||
bonus_set(BONUS_CHAMPI,((mario.p.x+mario.p.w/2)/8)*8,mario.p.y+mario.p.h+8);
|
||||
c->time_hit_id=1;
|
||||
}
|
||||
if (c->content==0 && mario.size==M_BIG && c->type==BRICK)
|
||||
{
|
||||
c->type=0;
|
||||
mario.p.vy=0;
|
||||
}
|
||||
else if (c->type==BRICK)
|
||||
c->time_hit_id=1;
|
||||
|
||||
c->hidden=0;
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,16 @@ void mario_jump();
|
|||
|
||||
void mario_move();
|
||||
|
||||
void mario_bigger();
|
||||
|
||||
void mario_smaller();
|
||||
|
||||
extern int global_quit;
|
||||
extern int numero_frame;
|
||||
extern int mario_x_max;
|
||||
extern int mario_dead;
|
||||
extern int id_frame;
|
||||
extern int mario_immunity;
|
||||
extern int mario_has_bullets;
|
||||
extern int last_vx_sign;
|
||||
#endif
|
|
@ -7,7 +7,7 @@
|
|||
#include <gint/timer.h>
|
||||
|
||||
int score=0;
|
||||
int lifes=5;
|
||||
int lifes=3;
|
||||
|
||||
int combo=0;
|
||||
int combo_id=-10;
|
||||
|
@ -22,7 +22,7 @@ int end_level=-1;
|
|||
void new_game()
|
||||
{
|
||||
|
||||
lifes=5;
|
||||
lifes=3;
|
||||
pieces=0;
|
||||
score=0;
|
||||
combo=0;
|
||||
|
@ -40,7 +40,6 @@ void new_level()
|
|||
void score_add_coin()
|
||||
{
|
||||
pieces++;
|
||||
score_add(10);
|
||||
}
|
||||
|
||||
void score_add(int i)
|
||||
|
|
19
src/tile.c
|
@ -18,6 +18,25 @@ tileset_t gift={&img_gift, 8, 8, 1};
|
|||
extern image_t img_coin;
|
||||
tileset_t coin={&img_coin, 8, 8, 1};
|
||||
|
||||
extern image_t img_nuage;
|
||||
tileset_t nuage={&img_nuage, 8, 8, 0};
|
||||
extern image_t img_buisson;
|
||||
tileset_t buisson={&img_buisson, 8, 8, 0};
|
||||
extern image_t img_colline;
|
||||
tileset_t colline={&img_colline, 8, 8, 0};
|
||||
|
||||
extern image_t img_bloc;
|
||||
tileset_t bloc={&img_bloc, 8, 8, 0};
|
||||
|
||||
extern image_t img_champi;
|
||||
tileset_t champi={&img_champi, 8, 8, 0};
|
||||
|
||||
extern image_t img_fleur;
|
||||
tileset_t fleur={&img_fleur, 8, 8, 0};
|
||||
|
||||
extern image_t img_bullet;
|
||||
tileset_t bullet={&img_bullet, 4, 4, 1};
|
||||
|
||||
void draw_tile(int sx, int sy, tileset_t const * const set, int x, int y)
|
||||
{
|
||||
dsubimage(sx, 64-sy-set->height,
|
||||
|
|
10
src/tile.h
|
@ -16,6 +16,16 @@ extern tileset_t brick;
|
|||
extern tileset_t earth;
|
||||
extern tileset_t gift;
|
||||
extern tileset_t coin;
|
||||
extern tileset_t bloc;
|
||||
|
||||
extern tileset_t nuage;
|
||||
extern tileset_t buisson;
|
||||
extern tileset_t colline;
|
||||
|
||||
extern tileset_t champi;
|
||||
extern tileset_t fleur;
|
||||
|
||||
extern tileset_t bullet;
|
||||
|
||||
void draw_tile(int sx, int sy, tileset_t const * const set, int x, int y);
|
||||
|
||||
|
|
167
src/world.c
|
@ -3,7 +3,7 @@
|
|||
#include "mario.h"
|
||||
#include "ennemi.h"
|
||||
#include <gint/display.h>
|
||||
|
||||
#include "bonus.h"
|
||||
world_t * w_current=0;
|
||||
image_t * w_fond=0;
|
||||
int w_current_x=0;
|
||||
|
@ -30,69 +30,91 @@ world_t* world_get(int x, int y)
|
|||
}
|
||||
}
|
||||
|
||||
void display_cell(int cx, int cy, int sx, int sy)
|
||||
void display_cell(int cx, int cy, int sx, int sy, int plan)
|
||||
{
|
||||
const world_t * cell=world_get(cx,cy);
|
||||
if (cell==0)
|
||||
{
|
||||
extern image_t img_death;
|
||||
//dimage(sx, sy, &img_death);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cell->type==TUYAU)
|
||||
if (plan==1)
|
||||
{
|
||||
tuyau_t* i=(tuyau_t*)cell;
|
||||
draw_tile(sx, sy, &tuyau, i->x, i->y);
|
||||
}
|
||||
|
||||
if (cell->type==EARTH)
|
||||
{
|
||||
earth_t* i=(earth_t*)cell;
|
||||
draw_tile(sx, sy, &earth, i->x, i->y);
|
||||
}
|
||||
if (cell->type==BRICK)
|
||||
{
|
||||
brick_t* i=(brick_t*)cell;
|
||||
if (i->time_hit_id)
|
||||
if (cell->type==TUYAU)
|
||||
{
|
||||
i->time_hit_id++;
|
||||
sy+=2+(i->time_hit_id-4)/4;
|
||||
if (i->time_hit_id==8)
|
||||
i->time_hit_id=0;
|
||||
tuyau_t* i=(tuyau_t*)cell;
|
||||
draw_tile(sx, sy, &tuyau, i->x, i->y);
|
||||
}
|
||||
if (i->time_hit_id || i->content==0 || i->number)
|
||||
draw_tile(sx, sy, &brick, 0, 0);
|
||||
else
|
||||
draw_tile(sx, sy, &gift, 1, 0);
|
||||
if (i->content==1 && i->time_hit_id && i->time_hit_id<=4)
|
||||
draw_tile(sx, sy+8, &coin, 0, 0);
|
||||
}
|
||||
|
||||
if (cell->type==GIFT)
|
||||
{
|
||||
gift_t* i=(gift_t*)cell;
|
||||
if (i->time_hit_id)
|
||||
if (cell->type==EARTH)
|
||||
{
|
||||
i->time_hit_id++;
|
||||
sy+=2+(i->time_hit_id-4)/4;
|
||||
if (i->time_hit_id==8)
|
||||
i->time_hit_id=0;
|
||||
earth_t* i=(earth_t*)cell;
|
||||
draw_tile(sx, sy, &earth, i->x, i->y);
|
||||
}
|
||||
if (i->time_hit_id || i->number)
|
||||
draw_tile(sx, sy, &gift, 0, 0);
|
||||
else
|
||||
draw_tile(sx, sy, &gift, 1, 0);
|
||||
if (i->content==1 && i->time_hit_id && i->time_hit_id<=4)
|
||||
draw_tile(sx, sy+8, &coin, 0, 0);
|
||||
}
|
||||
|
||||
if (cell->type==COIN)
|
||||
{
|
||||
coin_t* i=cell;
|
||||
draw_tile(sx, sy, &coin, i->taken, 0);
|
||||
if (cell->type==BLOC)
|
||||
{
|
||||
draw_tile(sx, sy, &bloc, 0, 0);
|
||||
}
|
||||
|
||||
if (cell->type==BRICK)
|
||||
{
|
||||
brick_t* i=(brick_t*)cell;
|
||||
if (i->time_hit_id)
|
||||
{
|
||||
i->time_hit_id++;
|
||||
sy+=2+(i->time_hit_id-4)/4;
|
||||
if (i->time_hit_id==8)
|
||||
i->time_hit_id=0;
|
||||
}
|
||||
if (i->hidden==0)
|
||||
{
|
||||
if (i->time_hit_id || i->content==0 || i->number)
|
||||
draw_tile(sx, sy, &brick, 0, 0);
|
||||
else
|
||||
draw_tile(sx, sy, &gift, 1, 0);
|
||||
if (i->content==1 && i->time_hit_id && i->time_hit_id<=4)
|
||||
draw_tile(sx, sy+8, &coin, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (cell->type==GIFT)
|
||||
{
|
||||
gift_t* i=(gift_t*)cell;
|
||||
if (i->time_hit_id)
|
||||
{
|
||||
i->time_hit_id++;
|
||||
sy+=2+(i->time_hit_id-4)/4;
|
||||
if (i->time_hit_id==8)
|
||||
i->time_hit_id=0;
|
||||
}
|
||||
if (i->hidden==0)
|
||||
{
|
||||
if (i->time_hit_id || i->number)
|
||||
draw_tile(sx, sy, &gift, 0, 0);
|
||||
else
|
||||
draw_tile(sx, sy, &gift, 1, 0);
|
||||
if (i->content==1 && i->time_hit_id && i->time_hit_id<=4)
|
||||
draw_tile(sx, sy+8, &coin, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cell->type==COIN)
|
||||
{
|
||||
coin_t* i=cell;
|
||||
draw_tile(sx, sy, &coin, i->taken, 0);
|
||||
}
|
||||
|
||||
if (cell->type==BUISSON || cell->type==NUAGE || cell->type==COLLINE)
|
||||
{
|
||||
deco_t* i=(deco_t*)cell;
|
||||
if (i->type==BUISSON)
|
||||
draw_tile(sx, sy, &buisson, i->x, i->y);
|
||||
if (i->type==NUAGE)
|
||||
draw_tile(sx, sy, &nuage, i->x, i->y);
|
||||
if (i->type==COLLINE)
|
||||
draw_tile(sx, sy, &colline, i->x, i->y);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int world_get_ctg(int x, int y)
|
||||
|
@ -104,11 +126,6 @@ int world_get_ctg(int x, int y)
|
|||
}
|
||||
switch (c->type)
|
||||
{
|
||||
case COIN:
|
||||
case EMPTY:
|
||||
return CTG_EMPTY;
|
||||
//case DEATH:
|
||||
return CTG_DEATH;
|
||||
case TUYAU:
|
||||
case GIFT:
|
||||
case BRICK:
|
||||
|
@ -129,32 +146,48 @@ static int min(const int x, const int y)
|
|||
return (x>y?y:x);
|
||||
}
|
||||
|
||||
int world_get_real_x0(int x) //mario delta en 0,0
|
||||
{return min(max(mario_x_max-54,0),w_current_x*8-128);}
|
||||
int world_get_real_x0() //mario delta en 0,0
|
||||
{ //if (mario.p.x>mario_x_max || mario.p.x<mario_x_max-54)
|
||||
// mario_x_max=mario.p.x;
|
||||
return min(max(mario_x_max-54,0),w_current_x*8-128);}
|
||||
|
||||
int world_get_real_y0(int y) //mario delta en 0,0
|
||||
{return min(max(y-24,0),w_current_y*8-64);}
|
||||
int world_get_real_y0() //mario delta en 0,0
|
||||
{return min(max(mario.p.y-32,0),w_current_y*8-64);}
|
||||
|
||||
|
||||
|
||||
void world_draw(int x, int y)
|
||||
{
|
||||
dimage(0,0,w_fond);
|
||||
int mx0=world_get_real_x0(x);
|
||||
int my0=world_get_real_y0(y);
|
||||
int sx0=mx0%8;
|
||||
int sy0=my0%8;
|
||||
display_ennemi_table();
|
||||
mario_draw();
|
||||
//int mx, my;
|
||||
|
||||
int mx=mx0;
|
||||
for (int i=0; i<=17; i++)
|
||||
{
|
||||
int my=my0;
|
||||
for (int j=0; j<=9; j++)
|
||||
{
|
||||
display_cell(mx, my, 8*i-sx0, 8*j-sy0);
|
||||
display_cell(mx, my, 8*i-sx0, 8*j-sy0,0); //ap
|
||||
my+=8;
|
||||
}
|
||||
mx+=8;
|
||||
}
|
||||
|
||||
display_ennemi_table();
|
||||
bonus_draw();
|
||||
bullet_display();
|
||||
mario_draw();
|
||||
|
||||
//int mx, my;
|
||||
|
||||
mx=mx0;
|
||||
for (int i=0; i<=17; i++)
|
||||
{
|
||||
int my=my0;
|
||||
for (int j=0; j<=9; j++)
|
||||
{
|
||||
display_cell(mx, my, 8*i-sx0, 8*j-sy0,1); //pp
|
||||
my+=8;
|
||||
}
|
||||
mx+=8;
|
||||
|
|
46
src/world.h
|
@ -14,7 +14,7 @@
|
|||
#define EARTH 1 // X, Y, _ (XY tileset)
|
||||
typedef struct
|
||||
{
|
||||
int type :4;
|
||||
unsigned type :4;
|
||||
unsigned empty :20;
|
||||
unsigned x :4;
|
||||
unsigned y :4;
|
||||
|
@ -23,28 +23,35 @@ typedef struct
|
|||
#define BRICK 2
|
||||
typedef struct
|
||||
{
|
||||
int type :4;
|
||||
unsigned time_hit_id :20;
|
||||
unsigned type :4;
|
||||
unsigned time_hit_id :16;
|
||||
unsigned hidden :4;
|
||||
unsigned content :4;
|
||||
unsigned number :4;
|
||||
} brick_t;
|
||||
|
||||
//#define PLATEFORM 4
|
||||
#define BLOC 3
|
||||
typedef struct
|
||||
{
|
||||
unsigned type :4;
|
||||
unsigned data :28; // raw binary format
|
||||
} bloc_t;
|
||||
|
||||
#define TUYAU 5 // X, Y, _ (XY tileset)
|
||||
typedef struct
|
||||
{
|
||||
int type :4;
|
||||
unsigned type :4;
|
||||
unsigned empty :20;
|
||||
unsigned x :4;
|
||||
unsigned y :4;
|
||||
|
||||
} tuyau_t;
|
||||
|
||||
#define GIFT 6 // s, t, n (state[hit time], type[vide=0, piece=1, ...], qté)
|
||||
typedef struct
|
||||
{
|
||||
int type :4;
|
||||
unsigned time_hit_id :20;
|
||||
unsigned type :4;
|
||||
unsigned time_hit_id :16;
|
||||
unsigned hidden :4;
|
||||
unsigned content :4;
|
||||
unsigned number :4;
|
||||
} gift_t;
|
||||
|
@ -52,15 +59,26 @@ typedef struct
|
|||
#define COIN 7 // s, _, _ (state)
|
||||
typedef struct
|
||||
{
|
||||
int type :4;
|
||||
int empty :24;
|
||||
unsigned type :4;
|
||||
unsigned empty :24;
|
||||
unsigned taken :4;
|
||||
} coin_t;
|
||||
|
||||
#define NUAGE 8 // X, Y, _ (XY tileset)
|
||||
#define BUISSON 9 // X, Y, _ (XY tileset)
|
||||
#define COLLINE 10 // X, Y, _ (XY tileset)
|
||||
typedef struct
|
||||
{
|
||||
unsigned type :4;
|
||||
unsigned empty :20;
|
||||
unsigned x :4;
|
||||
unsigned y :4;
|
||||
} deco_t;
|
||||
|
||||
// Generic container
|
||||
typedef struct
|
||||
{
|
||||
int type :4;
|
||||
unsigned type :4;
|
||||
unsigned data :28; // raw binary format
|
||||
} world_t;
|
||||
|
||||
|
@ -68,14 +86,14 @@ int world_get_width();
|
|||
|
||||
world_t* world_get(int x, int y);
|
||||
|
||||
void display_cell(int cx, int cy, int sx, int sy);
|
||||
void display_cell(int cx, int cy, int sx, int sy, int plan);
|
||||
|
||||
void world_set(world_t * w);
|
||||
|
||||
void world_draw(int x, int y);
|
||||
|
||||
int world_get_real_x0(int x);
|
||||
int world_get_real_y0(int y);
|
||||
int world_get_real_x0();
|
||||
int world_get_real_y0();
|
||||
|
||||
void world_reset();
|
||||
|
||||
|
|