clean bullets & correct special brick bug

dev
Milang 3 years ago
parent 7475d478f5
commit f739816d03
  1. BIN
      INIT/CasioRAM.mem
  2. 4
      SuperCbr.dlw
  3. BIN
      SuperCbr.g1a
  4. 53
      src/bullet.c
  5. 4
      src/world.c

Binary file not shown.

@ -2,7 +2,7 @@
[_1]
Type=5
Order=1
Order=0
Top=15
Left=2235
Height=4740
@ -13,7 +13,7 @@ OptionA=0
[_2]
Type=1
Order=0
Order=1
Top=15
Left=7800
Height=6885

Binary file not shown.

@ -25,9 +25,9 @@ void bulletThrow()
bullets[i].b.x=mario.p.x;
bullets[i].b.y=mario.p.y+8;
if (last_vx_sign==0)
bullets[i].b.vx=-9; //speed = 9
bullets[i].b.vx=-9; //speed = 9
else
bullets[i].b.vx=9;
bullets[i].b.vx=9;
bullets[i].b.vy=0;
bullets[i].p1=last_vx_sign;
return;
@ -37,43 +37,28 @@ void bulletThrow()
void bulletsDraw()
{
for (int i=0; i<2; i++)
{
if (bullets[i].type==1)
tileDraw(bullets[i].b.x-cameraX(), bullets[i].b.y-cameraY(), &bullet, (1+sgn(bullets[i].b.vy))/2, 0);
}
for (int i=0; i<2; i++) if (bullets[i].type==1) tileDraw(bullets[i].b.x-cameraX(), bullets[i].b.y-cameraY(), &bullet, (1+sgn(bullets[i].b.vy))/2, 0);
}
void bulletsMove()
{
for (int i=0; i<2; i++)
for (int i=0; i<2; i++) if (bullets[i].type) // bullet active
{
if (bullets[i].type==1)
boxJump(&bullets[i].b,4);
boxMove(&bullets[i].b);
if (bullets[i].b.vx==0) bullets[i].type=0; // delete a bullet if it is stopped
if (bullets[i].b.y<0) bullets[i].type=0; // delete a bullet if it is out of the map
if (bullets[i].b.x<=cameraX()-bullets[i].b.w || bullets[i].b.x>=cameraX()+127) bullets[i].type=0; // delete a bullet if it is out of the screen
// contact with ennemies
for (int a=0; a<ennemis_global_size; a++) if (ennemis_global[a].type!=NONE && boxContact(&bullets[i].b, &ennemis_global[a].b))
{
boxJump(&bullets[i].b,4);
boxMove(&bullets[i].b);
if (bullets[i].b.vx==0)
bullets[i].type=0;
if (bullets[i].b.y<0)
bullets[i].type=0;
if (bullets[i].b.x<=cameraX()-bullets[i].b.w || bullets[i].b.x>=cameraX()+127)
bullets[i].type=0;
for (int a=0; a<ennemis_global_size; a++)
{
ennemi_t* t=&ennemis_global[a];
if (t->discovered && t->type!=NONE)
{
bool x_collide= (bullets[i].b.x<=t->b.x && t->b.x<bullets[i].b.x+bullets[i].b.w) || (bullets[i].b.x<=t->b.x+t->b.w-1 && t->b.x+t->b.w<bullets[i].b.x+bullets[i].b.w);
bool y_collide= (bullets[i].b.y<=t->b.y && t->b.y<bullets[i].b.y+bullets[i].b.h) || (bullets[i].b.y<=t->b.y+t->b.h-1 && t->b.y+t->b.h<bullets[i].b.y+bullets[i].b.h);
if (x_collide&& y_collide)
{
t->life=DEAD;
bullets[i].type=0;
scoreAdd(KILL_ENNEMI);
break;
}
}
}
ennemis_global[a].life=DEAD;
bullets[i].type=0;
scoreAdd(KILL_ENNEMI);
break;
}
}
}
}

@ -75,9 +75,9 @@ void cellDraw(int cx, int cy, int sx, int sy, int plan)
}
if (!((brick_t*)cell)->hidden)
{
if (((brick_t*)cell)->time_hit_id || !((brick_t*)cell)->content || !((brick_t*)cell)->number) tileDraw(sx, sy, &brick, 0, ((brick_t*)cell)->state);
if (((brick_t*)cell)->time_hit_id || !((brick_t*)cell)->content || ((brick_t*)cell)->number) tileDraw(sx, sy, &brick, 0, ((brick_t*)cell)->state);
else tileDraw(sx, sy, &gift, 1, 0);
if (((brick_t*)cell)->content==1 && ((brick_t*)cell)->time_hit_id && ((brick_t*)cell)->time_hit_id<=4) tileDraw(sx, sy+8, &coin, 0, 0);
if (((brick_t*)cell)->content==1 && ((brick_t*)cell)->time_hit_id && ((brick_t*)cell)->time_hit_id<=4) tileDraw(sx, sy+8, &coin, 0, 0); // Draw a coin
}
break;

Loading…
Cancel
Save