if(tux.input.fire != DOWN) /* SHOOT! */
{
- if(pbad->dir = LEFT)
+ if(pbad->dir == LEFT)
pbad->base.x -= 24;
else
pbad->base.x += 24;
/* Empty a box: */
-void tryemptybox(float x, float y)
+void tryemptybox(float x, float y, int col_side)
{
- if (isfullbox(x, y))
- {
- if (shape(x, y) == 'A')
- {
-
- /* Box with a distro! */
-
- add_bouncy_distro(((int)(x + 1) / 32) * 32,
- (int)(y / 32) * 32 - 32);
-
- play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
- score = score + SCORE_DISTRO;
- distros++;
- }
- else if (shape(x, y) == 'B')
- {
- /* Add an upgrade! */
-
- if (tux.size == SMALL)
- {
- /* Tux is small, add mints! */
-
- add_upgrade((int)((x + 1) / 32) * 32,
- (int)(y / 32) * 32 - 32,
- UPGRADE_MINTS);
- }
- else
- {
- /* Tux is big, add coffee: */
-
- add_upgrade((int)((x + 1) / 32) * 32,
- (int)(y / 32) * 32 - 32,
- UPGRADE_COFFEE);
- }
-
- play_sound(sounds[SND_UPGRADE], SOUND_CENTER_SPEAKER);
- }
- else if (shape(x, y) == '!')
- {
- /* Add a golden herring */
-
- add_upgrade((int)((x + 1) / 32) * 32,
- (int)(y / 32) * 32 - 32,
- UPGRADE_HERRING);
- }
-
- /* Empty the box: */
-
- level_change(¤t_level,x, y, 'a');
- }
+if (!isfullbox(x, y))
+ return;
+
+// according to the collision side, set the upgrade direction
+
+if(col_side == LEFT)
+ col_side = RIGHT;
+else
+ col_side = LEFT;
+
+switch(shape(x,y))
+ {
+ case 'A': /* Box with a distro! */
+ add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32 - 32);
+ play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
+ score = score + SCORE_DISTRO;
+ distros++;
+ break;
+ case 'B': /* Add an upgrade! */
+ if (tux.size == SMALL) /* Tux is small, add mints! */
+ add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_MINTS);
+ else /* Tux is big, add coffee: */
+ add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_COFFEE);
+ play_sound(sounds[SND_UPGRADE], SOUND_CENTER_SPEAKER);
+ break;
+ case '!': /* Add a golden herring */
+ add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_HERRING);
+ break;
+ default:
+ break;
+ }
+
+/* Empty the box: */
+level_change(¤t_level,x, y, 'a');
}
void bumpbrick(float x, float y);
void trygrabdistro(float x, float y, int bounciness);
void trybreakbrick(float x, float y);
-void tryemptybox(float x, float y);
+void tryemptybox(float x, float y, int col_side);
void trybumpbadguy(float x, float y);
#endif /*SUPERTUX_GAMELOOP_H*/
trybreakbrick(pplayer->base.x, pplayer->base.y);
bumpbrick(pplayer->base.x, pplayer->base.y);
- tryemptybox(pplayer->base.x, pplayer->base.y);
+ tryemptybox(pplayer->base.x, pplayer->base.y, RIGHT);
}
if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
trybreakbrick(pplayer->base.x+ 31, pplayer->base.y);
bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
- tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
+ tryemptybox(pplayer->base.x+ 31, pplayer->base.y, LEFT);
}
/* Add an upgrade: */
-void add_upgrade(float x, float y, int kind)
+void add_upgrade(float x, float y, int dir, int kind)
{
int i, found;
if (found != -1)
{
- upgrade_init(&upgrades[found], x, y, kind);
+ upgrade_init(&upgrades[found], x, y, dir, kind);
}
}
void add_broken_brick_piece(float x, float y, float xm, float ym);
void add_bouncy_brick(float x, float y);
void add_bad_guy(float x, float y, int kind);
-void add_upgrade(float x, float y, int kind);
+void add_upgrade(float x, float y, int dir, int kind);
void add_bullet(float x, float y, float xm, int dir);
#endif /*SUPERTUX_SCENE_H*/
}
-void upgrade_init(upgrade_type *pupgrade, float x, float y, int kind)
+void upgrade_init(upgrade_type *pupgrade, float x, float y, int dir, int kind)
{
pupgrade->base.width = 32;
pupgrade->base.height = 0;
pupgrade->kind = kind;
pupgrade->base.x = x;
pupgrade->base.y = y;
- pupgrade->base.xm = 2;
+ if(dir == LEFT)
+ pupgrade->base.xm = -2;
+ else
+ pupgrade->base.xm = 2;
pupgrade->base.ym = -2;
pupgrade->base.height = 0;
pupgrade->old_base = pupgrade->base;
extern texture_type img_golden_herring;
-void upgrade_init(upgrade_type *pupgrade, float x, float y, int kind);
+void upgrade_init(upgrade_type *pupgrade, float x, float y, int dir, int kind);
void upgrade_action(upgrade_type *pupgrade);
void upgrade_draw(upgrade_type *pupgrade);
void upgrade_collision(upgrade_type *pupgrade, void* p_c_object, int c_object);