#include #include #include #include #include #include int plateforme_table_size=0; plateforme_t* plateformes=0; static int sgn(int x) { if (x==0) return 0; else if (x>0) return 1; return -1; } void reset_plateforme(plateforme_t* p) { p->x=p->xinit; p->y=p->yinit; p->v=p->vinit; } void move_plateforme(plateforme_t* p) {/* if (p->x+p->width-world_get_real_x0()<-50) return; if (p->x-world_get_real_x0()-128>50) return; if (p->y-world_get_real_y0()-64>50) return; if (p->y+3-world_get_real_y0()<-50) return; */ int xc = (mario.p.xx+p->width && mario.p.x>=p->x) || (mario.p.x+mario.p.wx+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 (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() { if (plateformes==0 || plateforme_table_size==0) return; plateforme_t * p=0; for (int i=0; ix; j < p->x+p->width; j+=3) draw_tile(j-camera_x(),p->y-camera_y(), &tplateforme, 0,0); //drect(p->x-world_get_real_x0(),64-(p->y-world_get_real_y0()),p->x-world_get_real_x0()+p->width,64-(p->y-world_get_real_y0()-3), C_BLACK); } } void move_plateformes() { if (plateformes==0 || plateforme_table_size==0) return; plateforme_t * p=0; for (int i=0; ix<=x && p->x+p->width>x && p->y<=y && p->y+3>y) return 1; } return 0; }