fixed flag bug
This commit is contained in:
parent
71f3e778bb
commit
af29ac6970
BIN
SuperCbr.g1a
BIN
SuperCbr.g1a
Binary file not shown.
|
@ -47,6 +47,8 @@ void display_plateformes();
|
|||
|
||||
int plateforme_check_collide(int x, int y);
|
||||
|
||||
void init_plateformes(plateforme_t * table, int s);
|
||||
|
||||
extern int plateforme_table_size;
|
||||
extern plateforme_t* plateformes;
|
||||
|
||||
|
|
44
src/level.c
44
src/level.c
|
@ -242,17 +242,17 @@ static void unpack_level(packed_level_t * p)
|
|||
else if (contents==PACKED_FLAG)
|
||||
{
|
||||
int props=0;
|
||||
if (pack_access(p,x,y-1)!=PACKED_FLAG)
|
||||
if (pack_access(p,x,y+1)!=PACKED_FLAG)
|
||||
props=0x1400;
|
||||
else if (pack_access(p,x,y-2)!=PACKED_FLAG)
|
||||
else if (pack_access(p,x,y+2)!=PACKED_FLAG)
|
||||
props=0x1401;
|
||||
else if (pack_access(p,x,y-3)!=PACKED_FLAG)
|
||||
else if (pack_access(p,x,y+3)!=PACKED_FLAG)
|
||||
props=0x1302;
|
||||
else if (pack_access(p,x,y-4)!=PACKED_FLAG)
|
||||
else if (pack_access(p,x,y+4)!=PACKED_FLAG)
|
||||
props=0x1302;
|
||||
else if (pack_access(p,x,y-5)!=PACKED_FLAG)
|
||||
else if (pack_access(p,x,y+5)!=PACKED_FLAG)
|
||||
props=0x1202;
|
||||
else if (pack_access(p,x,y-6)!=PACKED_FLAG)
|
||||
else if (pack_access(p,x,y+6)!=PACKED_FLAG)
|
||||
props=0x1202;
|
||||
else
|
||||
props=0x1102;
|
||||
|
@ -274,8 +274,36 @@ static void unpack_level(packed_level_t * p)
|
|||
|
||||
void set_level(int w, int l)
|
||||
{
|
||||
extern packed_level_t bin_lvl_1_2;
|
||||
unpack_level(&bin_lvl_1_2);
|
||||
new_level();
|
||||
set_teleporteurs(0,0);
|
||||
if (map_current)
|
||||
{
|
||||
free(map_current);
|
||||
map_current=0;
|
||||
}
|
||||
ennemis_global_size=0;
|
||||
plateforme_table_size=0;
|
||||
|
||||
if (w+1==1 && l+1==2) // 1-2
|
||||
{
|
||||
extern packed_level_t bin_lvl_1_2;
|
||||
unpack_level(&bin_lvl_1_2);
|
||||
|
||||
teleport_t t[]=
|
||||
{
|
||||
{6,4, 21,12, MK_DOWN},
|
||||
{106,5, 188,12, MK_DOWN},
|
||||
{197,2, 118,4, MK_RIGHT},
|
||||
{180,5, 206,2, MK_RIGHT},
|
||||
};
|
||||
set_teleporteurs(t, sizeof(t)/sizeof(teleport_t));
|
||||
|
||||
plateforme_t plateforme0[]=
|
||||
{
|
||||
PLATEFORME_MOVING_H(8*144,6*8+7,32,1,8*142,8*150)
|
||||
};
|
||||
init_plateformes(plateforme0,sizeof(plateforme0)/sizeof(plateforme_t));
|
||||
}
|
||||
}
|
||||
|
||||
void get_lvl_id(int w, int l, char * str)
|
||||
|
|
110
src/plateforme.c
110
src/plateforme.c
|
@ -5,6 +5,9 @@
|
|||
#include <tile.h>
|
||||
#include <score.h>
|
||||
#include <camera.h>
|
||||
#include <level.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <gint/std/stdlib.h>
|
||||
|
||||
int plateforme_table_size=0;
|
||||
plateforme_t* plateformes=0;
|
||||
|
@ -42,53 +45,53 @@ void move_plateforme(plateforme_t* p)
|
|||
return;
|
||||
*/
|
||||
|
||||
int xc = (mario.p.x<p->x+p->width && mario.p.x>=p->x) || (mario.p.x+mario.p.w<p->x+p->width && mario.p.x+mario.p.w>=p->x);
|
||||
int yc = (mario.p.y-3==p->y);
|
||||
int xc = (mario.p.x<p->x+p->width && mario.p.x>=p->x) || (mario.p.x+mario.p.w<p->x+p->width && mario.p.x+mario.p.w>=p->x);
|
||||
int yc = (mario.p.y-3==p->y);
|
||||
|
||||
if (p->type==P_FALLING)
|
||||
{
|
||||
if (p->v)
|
||||
p->v++;
|
||||
p->y+=p->v/2;
|
||||
}
|
||||
|
||||
if (p->type==P_MOVING_H)
|
||||
{
|
||||
int s=sgn(p->v);
|
||||
int t_v=((s*p->v+time_id%2)/2)*s;
|
||||
if (p->v==0)
|
||||
p->v=p->vinit;
|
||||
p->x+=t_v;
|
||||
if (xc&&yc)
|
||||
mario.p.x+=t_v;
|
||||
if (p->x+p->width > p->xmax && p->v>0)
|
||||
p->v *= -1;
|
||||
if (p->x < p->xmin && p->v<0)
|
||||
p->v *= -1;
|
||||
}
|
||||
|
||||
if (p->type==P_MOVING_V)
|
||||
{
|
||||
int s=sgn(p->v);
|
||||
int t_v=((s*p->v+time_id%2)/2)*s;
|
||||
if (p->v==0)
|
||||
p->v=p->vinit;
|
||||
p->y+=t_v;
|
||||
if (p->y > p->ymax || p->y+3 < p->ymin)
|
||||
p->v *= -1;
|
||||
}
|
||||
if (p->type==P_FALLING)
|
||||
{
|
||||
if (p->v)
|
||||
p->v++;
|
||||
p->y+=p->v/2;
|
||||
}
|
||||
|
||||
if (p->type==P_MOVING_H)
|
||||
{
|
||||
int s=sgn(p->v);
|
||||
int t_v=((s*p->v+time_id%2)/2)*s;
|
||||
if (p->v==0)
|
||||
p->v=p->vinit;
|
||||
p->x+=t_v;
|
||||
if (xc&&yc)
|
||||
{
|
||||
int s=sgn(p->v);
|
||||
int t_v=((s*p->v+time_id%2)/2)*s;
|
||||
if (p->type==P_FALLING)
|
||||
mario.p.y+=p->v/2;
|
||||
if (p->type==P_MOVING_V)
|
||||
mario.p.y+=t_v;
|
||||
if (p->type==P_MOVING_H)
|
||||
mario.p.x+=t_v/2;
|
||||
}
|
||||
mario.p.x+=t_v;
|
||||
if (p->x+p->width > p->xmax && p->v>0)
|
||||
p->v *= -1;
|
||||
if (p->x < p->xmin && p->v<0)
|
||||
p->v *= -1;
|
||||
}
|
||||
|
||||
if (p->type==P_MOVING_V)
|
||||
{
|
||||
int s=sgn(p->v);
|
||||
int t_v=((s*p->v+time_id%2)/2)*s;
|
||||
if (p->v==0)
|
||||
p->v=p->vinit;
|
||||
p->y+=t_v;
|
||||
if (p->y > p->ymax || p->y+3 < p->ymin)
|
||||
p->v *= -1;
|
||||
}
|
||||
|
||||
if (xc&&yc)
|
||||
{
|
||||
int s=sgn(p->v);
|
||||
int t_v=((s*p->v+time_id%2)/2)*s;
|
||||
if (p->type==P_FALLING)
|
||||
mario.p.y+=p->v/2;
|
||||
if (p->type==P_MOVING_V)
|
||||
mario.p.y+=t_v;
|
||||
if (p->type==P_MOVING_H)
|
||||
mario.p.x+=t_v/2;
|
||||
}
|
||||
}
|
||||
|
||||
void display_plateformes()
|
||||
|
@ -128,4 +131,23 @@ int plateforme_check_collide(int x, int y)
|
|||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void init_plateformes(plateforme_t * table, int s)
|
||||
{
|
||||
plateforme_table_size=s;
|
||||
if (plateformes)
|
||||
{
|
||||
free(plateformes);
|
||||
plateformes=0;
|
||||
}
|
||||
if (0==table)
|
||||
return;
|
||||
int size=sizeof(plateforme_t)*plateforme_table_size;
|
||||
plateformes=malloc(size);
|
||||
if (plateformes==0)
|
||||
malloc_error();
|
||||
|
||||
memcpy(plateformes, table, size);
|
||||
}
|
|
@ -13,6 +13,9 @@
|
|||
#include <keyboard.h>
|
||||
#include <base.h>
|
||||
#include <camera.h>
|
||||
#include <level.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <gint/std/stdlib.h>
|
||||
|
||||
map_t * map_current=0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue