- /* Fall if we get off the ground: */
-
- if (pbad->dying != DYING_FALLING)
- {
- if (!issolid(pbad->base.x+16, pbad->base.y + 32))
- {
- if(!physic_is_set(&pbad->physic))
- {
- physic_set_state(&pbad->physic,PH_VT);
- physic_set_start_vy(&pbad->physic,2.);
- }
-
- pbad->base.ym = physic_get_velocity(&pbad->physic);
- }
- else
- {
- /* Land: */
-
- if (pbad->base.ym > 0)
- {
- pbad->base.y = (int)(pbad->base.y / 32) * 32;
- pbad->base.ym = 0;
- }
- physic_init(&pbad->physic);
- }
- }
- else
+BadGuy::BadGuy(float x, float y, BadGuyKind kind_, bool stay_on_platform_)
+ : removable(false), squishcount(0)
+{
+ base.x = x;
+ base.y = y;
+ base.width = 0;
+ base.height = 0;
+ base.xm = 0;
+ base.ym = 0;
+
+ stay_on_platform = stay_on_platform_;
+ mode = NORMAL;
+ dying = DYING_NOT;
+ kind = kind_;
+ old_base = base;
+ dir = LEFT;
+ seen = false;
+ frozen_timer.init(true);
+ animation_offset = 0;
+ sprite_left = sprite_right = 0;
+ physic.reset();
+ timer.init(true);
+
+ if(kind == BAD_MRBOMB) {
+ physic.set_velocity(-BADGUY_WALK_SPEED, 0);
+ set_sprite(img_mrbomb_left, img_mrbomb_right);
+ } else if (kind == BAD_MRICEBLOCK) {
+ physic.set_velocity(-BADGUY_WALK_SPEED, 0);
+ set_sprite(img_mriceblock_left, img_mriceblock_right);
+ } else if(kind == BAD_JUMPY) {
+ set_sprite(img_jumpy_left_up, img_jumpy_left_up);
+ } else if(kind == BAD_BOMB) {
+ set_sprite(img_mrbomb_ticking_left, img_mrbomb_ticking_right);
+ // hack so that the bomb doesn't hurt until it expldes...
+ dying = DYING_SQUISHED;
+ } else if(kind == BAD_FLAME) {
+ base.ym = 0; // we misuse base.ym as angle for the flame
+ physic.enable_gravity(false);
+ set_sprite(img_flame, img_flame);
+ } else if(kind == BAD_BOUNCINGSNOWBALL) {
+ physic.set_velocity(-1.3, 0);
+ set_sprite(img_bouncingsnowball_left, img_bouncingsnowball_right);
+ } else if(kind == BAD_STALACTITE) {
+ physic.enable_gravity(false);
+ set_sprite(img_stalactite, img_stalactite);
+ } else if(kind == BAD_FISH) {
+ set_sprite(img_fish, img_fish);
+ physic.enable_gravity(true);
+ } else if(kind == BAD_FLYINGSNOWBALL) {
+ set_sprite(img_flyingsnowball, img_flyingsnowball);
+ physic.enable_gravity(false);
+ } else if(kind == BAD_SPIKY) {
+ physic.set_velocity(-BADGUY_WALK_SPEED, 0);
+ set_sprite(img_spiky_left, img_spiky_right);
+ } else if(kind == BAD_SNOWBALL) {
+ physic.set_velocity(-BADGUY_WALK_SPEED, 0);
+ set_sprite(img_snowball_left, img_snowball_right);
+ }
+
+ // if we're in a solid tile at start correct that now
+ if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(base))