From: Tobias Gläßer Date: Sun, 14 Mar 2004 02:37:18 +0000 (+0000) Subject: applied Ricardo's upgrade direction patch again. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7eeb14fedff6a08ac52fa63270f8bbd398e99b21;p=supertux.git applied Ricardo's upgrade direction patch again. SVN-Revision: 209 --- diff --git a/src/badguy.c b/src/badguy.c index fddd97f60..fc0b3109e 100644 --- a/src/badguy.c +++ b/src/badguy.c @@ -173,7 +173,7 @@ void badguy_action(bad_guy_type* pbad) if(tux.input.fire != DOWN) /* SHOOT! */ { - if(pbad->dir = LEFT) + if(pbad->dir == LEFT) pbad->base.x -= 24; else pbad->base.x += 24; diff --git a/src/gameloop.c b/src/gameloop.c index d24da2926..9cc6de8e4 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -1524,58 +1524,42 @@ void bumpbrick(float x, float y) /* 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'); } diff --git a/src/gameloop.h b/src/gameloop.h index 8c6fbeeda..0c23c95e4 100644 --- a/src/gameloop.h +++ b/src/gameloop.h @@ -42,7 +42,7 @@ unsigned char shape(float x, float y); 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*/ diff --git a/src/player.c b/src/player.c index 2ff970642..12817e630 100644 --- a/src/player.c +++ b/src/player.c @@ -205,7 +205,7 @@ void player_action(player_type* pplayer) 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) || @@ -218,7 +218,7 @@ void player_action(player_type* pplayer) 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); } diff --git a/src/scene.c b/src/scene.c index 88daf204c..1748e456a 100644 --- a/src/scene.c +++ b/src/scene.c @@ -246,7 +246,7 @@ void add_bad_guy(float x, float y, int kind) /* 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; @@ -267,7 +267,7 @@ void add_upgrade(float x, float y, int kind) if (found != -1) { - upgrade_init(&upgrades[found], x, y, kind); + upgrade_init(&upgrades[found], x, y, dir, kind); } } diff --git a/src/scene.h b/src/scene.h index 923156fdf..d4ec0dba6 100644 --- a/src/scene.h +++ b/src/scene.h @@ -55,7 +55,7 @@ void add_broken_brick(float x, float y); 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*/ diff --git a/src/special.c b/src/special.c index 639edc563..ce0193acd 100644 --- a/src/special.c +++ b/src/special.c @@ -101,7 +101,7 @@ void bullet_collision(bullet_type* pbullet, int c_object) } -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; @@ -109,7 +109,10 @@ void upgrade_init(upgrade_type *pupgrade, float x, float y, int kind) 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; diff --git a/src/special.h b/src/special.h index cf5d21e22..596fe1a85 100644 --- a/src/special.h +++ b/src/special.h @@ -52,7 +52,7 @@ void create_special_bitmasks(); 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);