fix minor camera "bugs"

&correct error provided by previour commit
master
Milang 3 years ago
parent 13872b3dcb
commit 23b98fd3d4
  1. BIN
      SuperCbr.g1a
  2. 4
      include/ennemi.h
  3. 26
      src/camera.c
  4. 14
      src/ennemi.c

Binary file not shown.

@ -38,13 +38,13 @@ typedef struct
int p1 :14;
} ennemi_t;
void ennemiDisplay(ennemi_t * e);
void ennemiDisplay(ennemi_t const * e);
extern ennemi_t * ennemis_global;
extern int ennemis_global_size;
void ennemiesDisplay();
void ennemiMove(ennemi_t const * e);
void ennemiMove(ennemi_t * e);
void ennemiesInit(ennemi_t * table, int s);

@ -16,13 +16,13 @@ int cameraY() {return max(max(y-32,0)-delta_y,0);}
void cameraMove() // only vertical movement
{
if (MKB_getKeyState(MK_UP) && abs(delta_y)<24) delta_y-=4;
if (MKB_getKeyState(MK_DOWN) && abs(delta_y)<24) delta_y+=4;
static int camera_vy=0;
if (MKB_getKeyState(MK_UP) && abs(delta_y)<24) { camera_vy=0; delta_y-=4;}
if (MKB_getKeyState(MK_DOWN) && abs(delta_y)<24) { camera_vy=0; delta_y+=4;}
if (!MKB_getKeyState(MK_DOWN) && !MKB_getKeyState(MK_UP)) delta_y-=4*sgn(delta_y);
static int camera_vy=0;
if (mario.p.y==last_vy) // mario arrêté
immobile++;
if (mario.p.y==last_vy) immobile++;
else
{
last_vy=mario.p.y;
@ -30,26 +30,20 @@ void cameraMove() // only vertical movement
}
if (mario.p.y-cameraY()-mario.p.h<16 || mario.p.y-cameraY()>54)
{
y+=5*sgn(mario.p.y-y);
y+=4*sgn(mario.p.y-y);
}
if (immobile>=2)
{
//y+=(mario.p.y-y)/3;
if (camera_vy==0)
{
distance=2*(mario.p.y-y)*sgn(mario.p.y-y);
}
if (camera_vy==0) distance=2*(mario.p.y-y)*sgn(mario.p.y-y);
//décéleration après avoir parvouru la moitié de la distance, sinon acceleration
if (camera_vy*(camera_vy+1)>distance)
camera_vy--;
else
camera_vy++;
if (camera_vy*(camera_vy+1)>distance) camera_vy--;
else camera_vy++;
//y++;
if (camera_vy<0)
camera_vy=0;
if (camera_vy<0) camera_vy=0;
if (((y+camera_vy*sgn(mario.p.y-y)/2)-(mario.p.y))*sgn(mario.p.y-y)>0)
{

@ -20,7 +20,6 @@ void ennemiDisplay(ennemi_t const * e)
{
if (e->type==NONE) return;
if (e->b.x<=cameraX(0)-e->b.w || e->b.x>=cameraX(0)+127) return; // do not draw if out of the screen
else e->discovered=1; // for security, tag as discover all drawed ennemies
{// draw
int tx=0, ty=0, dsx=0, dsy=0;
@ -91,6 +90,8 @@ void hurtMario()
void ennemiMove(ennemi_t *e)
{
if (!(e->b.x<=cameraX(0)-e->b.w || e->b.x>=cameraX(0)+127)) e->discovered=1; // for security, tag as discover all drawed ennemies
if (e->life==0 && e->type!=NONE)
{
if (e->p1==0)
@ -250,16 +251,11 @@ void ennemiMove(ennemi_t *e)
if (mario.p.x>=e->b.x) e->p1=-1;
if (mario.p.x<=e->b.x) e->p1=1;
e->b.vx=6*e->p1;
if (mario_fatal_hit)
{
mario.p.vy=4;
mario.p.y=e->b.y+ennemi_heights[CARAPACE_VERTE];
}
else
{ // mario bounce
if (mario.p.x>=e->b.x) mario.p.x=e->b.x+e->b.w;
if (mario.p.x<=e->b.x) mario.p.x=e->b.x-mario.p.w;
}
boxMove(&e->b);
}
else
{

Loading…
Cancel
Save