X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy.cpp;h=7b8db66c90fb00d0b0b4cf3de033bab72bf9ef52;hb=c11b04d0525c1566260b02bacd78fd7faa7be8f1;hp=3c084fbc9414c5de446091487c02c602629de4b7;hpb=cf4a9fe888b3faa0fcfd45870af756a5955d9030;p=supertux.git diff --git a/src/badguy.cpp b/src/badguy.cpp index 3c084fbc9..7b8db66c9 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -32,6 +32,7 @@ #include "tile.h" #include "resources.h" #include "sprite_manager.h" +#include "gameloop.h" Sprite* img_mriceblock_flat_left; Sprite* img_mriceblock_flat_right; @@ -296,12 +297,18 @@ BadGuy::check_horizontal_bump(bool checkcliff) float halfheight = base.height / 2; if (dir == LEFT && issolid( base.x, (int) base.y + halfheight)) { + if (kind == BAD_MRICEBLOCK && mode == KICK) + World::current()->trybreakbrick(base.x, (int) base.y + halfheight, false); + dir = RIGHT; physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y()); return; } if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight)) { + if (kind == BAD_MRICEBLOCK && mode == KICK) + World::current()->trybreakbrick(base.x + base.width, (int) base.y + halfheight, false); + dir = LEFT; physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y()); return; @@ -712,6 +719,17 @@ BadGuy::action(double frame_ratio) return; } + // Kill us if we landed on spikes + if (dying == DYING_NOT + && (kind != BAD_STALACTITE && kind != BAD_FLAME && kind != BAD_BOMB) + && (isspike(base.x, base.y) || isspike(base.x + base.width, base.y) + || isspike(base.x, base.y + base.height) + || isspike(base.x + base.width, base.y + base.height))) + { + physic.set_velocity_y(3); + kill_me(0); + } + // Once it's on screen, it's activated! if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE) seen = true; @@ -954,10 +972,11 @@ BadGuy::kill_me(int score) tux.holding_something = false; } } - + physic.enable_gravity(true); /* Gain some points: */ + if (score != 0) World::current()->add_score(base.x, base.y, score * player_status.score_multiplier); @@ -996,16 +1015,14 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) if(pbullet_c->kind == FIRE_BULLET) { - if(kind == BAD_MRICEBLOCK || kind == BAD_STALACTITE || - kind == BAD_FISH || kind == BAD_BOUNCINGSNOWBALL || - kind == BAD_FLYINGSNOWBALL || kind == BAD_FLYINGSNOWBALL) - kill_me(10); + if (kind != BAD_BOMB && kind != BAD_STALACTITE && kind != BAD_FLAME) + kill_me(10); } else if(pbullet_c->kind == ICE_BULLET) { - if(kind == BAD_FLAME) - kill_me(10); - else + //if(kind == BAD_FLAME) + // kill_me(10); + //else frozen_timer.start(FROZEN_TIME); } break; @@ -1013,13 +1030,14 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) case CO_BADGUY: pbad_c = (BadGuy*) p_c_object; - /* If we're a kicked mriceblock, kill any badguys we hit */ - if(kind == BAD_MRICEBLOCK && mode == KICK) + /* If we're a kicked mriceblock, kill [almost] any badguys we hit */ + if(kind == BAD_MRICEBLOCK && mode == KICK && + kind != BAD_FLAME && kind != BAD_BOMB && kind != BAD_STALACTITE) { pbad_c->kill_me(25); } - // a held mriceblock gets kills the enemy too but falls to ground then + // a held mriceblock kills the enemy too but falls to ground then else if(kind == BAD_MRICEBLOCK && mode == HELD) { pbad_c->kill_me(25); @@ -1076,8 +1094,6 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) physic.set_velocity(-fabsf(physic.get_velocity_x()), 2); } - - break; } else if (base.y + base.height > pbad_c->base.y + pbad_c->base.height) @@ -1089,6 +1105,10 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) { dir = RIGHT; physic.set_velocity_x(fabsf(physic.get_velocity_x())); + + // in case badguys get "jammed" + if (physic.get_velocity_x() != 0) + base.x = pbad_c->base.x + pbad_c->base.width; } else if (dir == RIGHT) {