4 // Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
5 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
6 // Copyright (C) 2004 Matthias Braun <matze@braunis.de>
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #include "resources.h"
34 #include "sprite_manager.h"
36 Sprite* img_mriceblock_flat_left;
37 Sprite* img_mriceblock_flat_right;
38 Sprite* img_mriceblock_falling_left;
39 Sprite* img_mriceblock_falling_right;
40 Sprite* img_mriceblock_left;
41 Sprite* img_mriceblock_right;
42 Sprite* img_jumpy_left_up;
43 Sprite* img_jumpy_left_down;
44 Sprite* img_jumpy_left_middle;
45 Sprite* img_jumpy_left_iced;
46 Sprite* img_mrbomb_left;
47 Sprite* img_mrbomb_right;
48 Sprite* img_mrbomb_iced_left;
49 Sprite* img_mrbomb_iced_right;
50 Sprite* img_mrbomb_ticking_left;
51 Sprite* img_mrbomb_ticking_right;
52 Sprite* img_mrbomb_explosion;
53 Sprite* img_stalactite;
54 Sprite* img_stalactite_broken;
57 Sprite* img_fish_down;
58 Sprite* img_fish_iced;
59 Sprite* img_fish_iced_down;
60 Sprite* img_bouncingsnowball_left;
61 Sprite* img_bouncingsnowball_right;
62 Sprite* img_bouncingsnowball_squished;
63 Sprite* img_flyingsnowball;
64 Sprite* img_flyingsnowball_squished;
65 Sprite* img_spiky_left;
66 Sprite* img_spiky_right;
67 Sprite* img_spiky_iced_left;
68 Sprite* img_spiky_iced_right;
69 Sprite* img_snowball_left;
70 Sprite* img_snowball_right;
71 Sprite* img_snowball_squished_left;
72 Sprite* img_snowball_squished_right;
74 #define BADGUY_WALK_SPEED .8f
76 BadGuyKind badguykind_from_string(const std::string& str)
78 if (str == "money" || str == "jumpy") // was money in old maps
80 else if (str == "laptop" || str == "mriceblock") // was laptop in old maps
81 return BAD_MRICEBLOCK;
82 else if (str == "mrbomb")
84 else if (str == "stalactite")
85 return BAD_STALACTITE;
86 else if (str == "flame")
88 else if (str == "fish")
90 else if (str == "bouncingsnowball")
91 return BAD_BOUNCINGSNOWBALL;
92 else if (str == "flyingsnowball")
93 return BAD_FLYINGSNOWBALL;
94 else if (str == "spiky")
96 else if (str == "snowball" || str == "bsod") // was bsod in old maps
100 printf("Couldn't convert badguy: '%s'\n", str.c_str());
105 std::string badguykind_to_string(BadGuyKind kind)
127 case BAD_BOUNCINGSNOWBALL:
128 return "bouncingsnowball";
130 case BAD_FLYINGSNOWBALL:
131 return "flyingsnowball";
144 BadGuy::BadGuy(float x, float y, BadGuyKind kind_, bool stay_on_platform_)
145 : removable(false), squishcount(0)
154 stay_on_platform = stay_on_platform_;
161 frozen_timer.init(true);
162 animation_offset = 0;
163 sprite_left = sprite_right = 0;
167 if(kind == BAD_MRBOMB) {
168 physic.set_velocity(-BADGUY_WALK_SPEED, 0);
169 set_sprite(img_mrbomb_left, img_mrbomb_right);
170 } else if (kind == BAD_MRICEBLOCK) {
171 physic.set_velocity(-BADGUY_WALK_SPEED, 0);
172 set_sprite(img_mriceblock_left, img_mriceblock_right);
173 } else if(kind == BAD_JUMPY) {
174 set_sprite(img_jumpy_left_up, img_jumpy_left_up);
175 } else if(kind == BAD_BOMB) {
176 set_sprite(img_mrbomb_ticking_left, img_mrbomb_ticking_right);
177 // hack so that the bomb doesn't hurt until it expldes...
178 dying = DYING_SQUISHED;
179 } else if(kind == BAD_FLAME) {
180 base.ym = 0; // we misuse base.ym as angle for the flame
181 physic.enable_gravity(false);
182 set_sprite(img_flame, img_flame);
183 } else if(kind == BAD_BOUNCINGSNOWBALL) {
184 physic.set_velocity(-1.3, 0);
185 set_sprite(img_bouncingsnowball_left, img_bouncingsnowball_right);
186 } else if(kind == BAD_STALACTITE) {
187 physic.enable_gravity(false);
188 set_sprite(img_stalactite, img_stalactite);
189 } else if(kind == BAD_FISH) {
190 set_sprite(img_fish, img_fish);
191 physic.enable_gravity(true);
192 } else if(kind == BAD_FLYINGSNOWBALL) {
193 set_sprite(img_flyingsnowball, img_flyingsnowball);
194 physic.enable_gravity(false);
195 } else if(kind == BAD_SPIKY) {
196 physic.set_velocity(-BADGUY_WALK_SPEED, 0);
197 set_sprite(img_spiky_left, img_spiky_right);
198 } else if(kind == BAD_SNOWBALL) {
199 physic.set_velocity(-BADGUY_WALK_SPEED, 0);
200 set_sprite(img_snowball_left, img_snowball_right);
203 // if we're in a solid tile at start correct that now
204 if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(base))
206 std::cout << "Warning: badguy started in wall: kind: " << badguykind_to_string(kind)
207 << " pos: (" << base.x << ", " << base.y << ")" << std::endl;
208 while(collision_object_map(base))
214 BadGuy::action_mriceblock(double frame_ratio)
216 Player& tux = *World::current()->get_tux();
221 /* Move left/right: */
225 physic.apply(frame_ratio, base.x, base.y);
226 if (dying != DYING_FALLING)
227 collision_swept_object_map(&old_base,&base);
229 else if (mode == HELD)
230 { /* FIXME: The pbad object shouldn't know about pplayer objects. */
231 /* If we're holding the iceblock */
235 base.x = tux.base.x + 16;
236 base.y = tux.base.y + tux.base.height/1.5 - base.height;
238 else /* facing left */
240 base.x = tux.base.x - 16;
241 base.y = tux.base.y + tux.base.height/1.5 - base.height;
243 if(collision_object_map(base))
246 base.y = tux.base.y + tux.base.height/1.5 - base.height;
249 if(tux.input.fire != DOWN) /* SHOOT! */
258 tux.kick_timer.start(KICKING_TIME);
259 set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
260 physic.set_velocity_x((dir == LEFT) ? -3.5 : 3.5);
261 play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
268 check_horizontal_bump();
269 if(mode == KICK && changed != dir)
271 /* handle stereo sound (number 10 should be tweaked...)*/
272 if (base.x < scroll_x + screen->w/2 - 10)
273 play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
274 else if (base.x > scroll_x + screen->w/2 + 10)
275 play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
277 play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
281 /* Handle mode timer: */
287 set_sprite(img_mriceblock_left, img_mriceblock_right);
288 physic.set_velocity( (dir == LEFT) ? -.8 : .8, 0);
294 BadGuy::check_horizontal_bump(bool checkcliff)
296 float halfheight = base.height / 2;
297 if (dir == LEFT && issolid( base.x, (int) base.y + halfheight))
300 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
303 if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight))
306 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
310 // don't check for cliffs when we're falling
313 if(!issolid(base.x + base.width/2, base.y + base.height))
316 if(dir == LEFT && !issolid(base.x, (int) base.y + base.height + halfheight))
319 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
322 if(dir == RIGHT && !issolid(base.x + base.width,
323 (int) base.y + base.height + halfheight))
326 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
334 /* Fall if we get off the ground: */
335 if (dying != DYING_FALLING)
337 if (!issolid(base.x+base.width/2, base.y + base.height))
339 // not solid below us? enable gravity
340 physic.enable_gravity(true);
345 if (physic.get_velocity_y() < 0)
347 base.y = int((base.y + base.height)/32) * 32 - base.height;
348 physic.set_velocity_y(0);
350 // no gravity anymore please
351 physic.enable_gravity(false);
353 if (stay_on_platform && mode == NORMAL)
355 if (!issolid(base.x + ((dir == LEFT) ? 0 : base.width),
356 base.y + base.height))
361 physic.set_velocity_x(fabsf(physic.get_velocity_x()));
366 physic.set_velocity_x(-fabsf(physic.get_velocity_x()));
374 physic.enable_gravity(true);
385 BadGuy::action_jumpy(double frame_ratio)
387 if(frozen_timer.check())
389 set_sprite(img_jumpy_left_iced, img_jumpy_left_iced);
393 const float vy = physic.get_velocity_y();
395 // XXX: These tests *should* use location from ground, not velocity
396 if (fabsf(vy) > 5.6f)
397 set_sprite(img_jumpy_left_down, img_jumpy_left_down);
398 else if (fabsf(vy) > 5.3f)
399 set_sprite(img_jumpy_left_middle, img_jumpy_left_middle);
401 set_sprite(img_jumpy_left_up, img_jumpy_left_up);
403 Player& tux = *World::current()->get_tux();
405 static const float JUMPV = 6;
408 // jump when on ground
409 if(dying == DYING_NOT && issolid(base.x, base.y+32))
411 physic.set_velocity_y(JUMPV);
412 physic.enable_gravity(true);
416 else if(mode == JUMPY_JUMP)
421 // set direction based on tux
422 if(tux.base.x > base.x)
428 physic.apply(frame_ratio, base.x, base.y);
429 if(dying == DYING_NOT)
430 collision_swept_object_map(&old_base, &base);
434 BadGuy::action_mrbomb(double frame_ratio)
436 if(frozen_timer.check())
438 set_sprite(img_mrbomb_iced_left, img_mrbomb_iced_right);
442 if (dying == DYING_NOT)
443 check_horizontal_bump(true);
447 physic.apply(frame_ratio, base.x, base.y);
448 if (dying != DYING_FALLING)
449 collision_swept_object_map(&old_base,&base);
453 BadGuy::action_bomb(double frame_ratio)
455 static const int TICKINGTIME = 1000;
456 static const int EXPLODETIME = 1000;
462 timer.start(TICKINGTIME);
463 } else if(!timer.check()) {
464 if(mode == BOMB_TICKING) {
466 set_sprite(img_mrbomb_explosion, img_mrbomb_explosion);
467 dying = DYING_NOT; // now the bomb hurts
468 timer.start(EXPLODETIME);
470 /* play explosion sound */ // FIXME: is the stereo all right? maybe we should use player cordinates...
471 if (base.x < scroll_x + screen->w/2 - 10)
472 play_sound(sounds[SND_EXPLODE], SOUND_LEFT_SPEAKER);
473 else if (base.x > scroll_x + screen->w/2 + 10)
474 play_sound(sounds[SND_EXPLODE], SOUND_RIGHT_SPEAKER);
476 play_sound(sounds[SND_EXPLODE], SOUND_CENTER_SPEAKER);
478 } else if(mode == BOMB_EXPLODE) {
485 physic.apply(frame_ratio, base.x, base.y);
486 collision_swept_object_map(&old_base,&base);
490 BadGuy::action_stalactite(double frame_ratio)
492 Player& tux = *World::current()->get_tux();
494 static const int SHAKETIME = 800;
495 static const int RANGE = 40;
498 // start shaking when tux is below the stalactite and at least 40 pixels
500 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
501 && tux.base.y + tux.base.height > base.y) {
502 timer.start(SHAKETIME);
503 mode = STALACTITE_SHAKING;
505 } if(mode == STALACTITE_SHAKING) {
506 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
508 mode = STALACTITE_FALL;
510 } else if(mode == STALACTITE_FALL) {
512 /* Destroy if we collides with land */
513 if(issolid(base.x+base.width/2, base.y+base.height))
516 dying = DYING_SQUISHED;
518 set_sprite(img_stalactite_broken, img_stalactite_broken);
520 } else if(mode == FLAT) {
525 physic.apply(frame_ratio, base.x, base.y);
527 if(dying == DYING_SQUISHED && !timer.check())
532 BadGuy::action_flame(double frame_ratio)
534 static const float radius = 100;
535 static const float speed = 0.02;
536 base.x = old_base.x + cos(base.ym) * radius;
537 base.y = old_base.y + sin(base.ym) * radius;
539 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
543 BadGuy::action_fish(double frame_ratio)
545 if(frozen_timer.check())
547 if(physic.get_velocity_y() < 0)
548 set_sprite(img_fish_iced_down, img_fish_iced_down);
550 set_sprite(img_fish_iced, img_fish_iced);
555 static const float JUMPV = 6;
556 static const int WAITTIME = 1000;
558 // go in wait mode when back in water
559 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
560 && physic.get_velocity_y() <= 0 && mode == NORMAL)
564 physic.set_velocity(0, 0);
565 physic.enable_gravity(false);
566 timer.start(WAITTIME);
568 else if(mode == FISH_WAIT && !timer.check())
571 set_sprite(img_fish, img_fish);
573 physic.set_velocity(0, JUMPV);
574 physic.enable_gravity(true);
577 physic.apply(frame_ratio, base.x, base.y);
578 if(dying == DYING_NOT)
579 collision_swept_object_map(&old_base, &base);
581 if(physic.get_velocity_y() < 0)
582 set_sprite(img_fish_down, img_fish_down);
586 BadGuy::action_bouncingsnowball(double frame_ratio)
588 static const float JUMPV = 4.5;
592 // jump when on ground
593 if(dying == DYING_NOT && issolid(base.x, base.y+32))
595 physic.set_velocity_y(JUMPV);
596 physic.enable_gravity(true);
603 // check for right/left collisions
604 check_horizontal_bump();
606 physic.apply(frame_ratio, base.x, base.y);
607 if(dying == DYING_NOT)
608 collision_swept_object_map(&old_base, &base);
610 // Handle dying timer:
611 if (dying == DYING_SQUISHED && !timer.check())
613 /* Remove it if time's up: */
620 BadGuy::action_flyingsnowball(double frame_ratio)
622 static const float FLYINGSPEED = 1;
623 static const int DIRCHANGETIME = 1000;
625 // go into flyup mode if none specified yet
626 if(dying == DYING_NOT && mode == NORMAL) {
628 physic.set_velocity_y(FLYINGSPEED);
629 timer.start(DIRCHANGETIME/2);
632 if(dying == DYING_NOT && !timer.check()) {
635 physic.set_velocity_y(-FLYINGSPEED);
636 } else if(mode == FLY_DOWN) {
638 physic.set_velocity_y(FLYINGSPEED);
640 timer.start(DIRCHANGETIME);
643 if(dying != DYING_NOT)
644 physic.enable_gravity(true);
646 physic.apply(frame_ratio, base.x, base.y);
647 if(dying == DYING_NOT || dying == DYING_SQUISHED)
648 collision_swept_object_map(&old_base, &base);
650 // Handle dying timer:
651 if (dying == DYING_SQUISHED && !timer.check())
653 /* Remove it if time's up: */
660 BadGuy::action_spiky(double frame_ratio)
662 if(frozen_timer.check())
664 set_sprite(img_spiky_iced_left, img_spiky_iced_right);
668 if (dying == DYING_NOT)
669 check_horizontal_bump();
673 // jump when we're about to fall
674 if (physic.get_velocity_y() == 0 &&
675 !issolid(base.x+base.width/2, base.y + base.height)) {
676 physic.enable_gravity(true);
677 physic.set_velocity_y(2);
681 physic.apply(frame_ratio, base.x, base.y);
682 if (dying != DYING_FALLING)
683 collision_swept_object_map(&old_base,&base);
687 BadGuy::action_snowball(double frame_ratio)
689 if (dying == DYING_NOT)
690 check_horizontal_bump();
694 physic.apply(frame_ratio, base.x, base.y);
695 if (dying != DYING_FALLING)
696 collision_swept_object_map(&old_base,&base);
700 BadGuy::action(double frame_ratio)
702 // Remove if it's far off the screen:
703 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
709 // BadGuy fall below the ground
710 if (base.y > screen->h) {
715 // Once it's on screen, it's activated!
716 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
725 action_mriceblock(frame_ratio);
729 action_jumpy(frame_ratio);
733 action_mrbomb(frame_ratio);
737 action_bomb(frame_ratio);
741 action_stalactite(frame_ratio);
745 action_flame(frame_ratio);
749 action_fish(frame_ratio);
752 case BAD_BOUNCINGSNOWBALL:
753 action_bouncingsnowball(frame_ratio);
756 case BAD_FLYINGSNOWBALL:
757 action_flyingsnowball(frame_ratio);
761 action_spiky(frame_ratio);
765 action_snowball(frame_ratio);
775 // Don't try to draw stuff that is outside of the screen
776 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
779 if(sprite_left == 0 || sprite_right == 0)
784 Sprite* sprite = (dir == LEFT) ? sprite_left : sprite_right;
785 sprite->draw(base.x, base.y);
788 fillrect(base.x - scroll_x, base.y - scroll_y, base.width, base.height, 75,0,75, 150);
792 BadGuy::set_sprite(Sprite* left, Sprite* right)
801 // FIXME: Using the image size for the physics and collision is
802 // a bad idea, since images should always overlap there physical
805 if(base.width == 0 && base.height == 0) {
806 base.width = left->get_width();
807 base.height = left->get_height();
808 } else if(base.width != left->get_width() || base.height != left->get_height()) {
809 base.x -= (left->get_width() - base.width) / 2;
810 base.y -= left->get_height() - base.height;
811 base.width = left->get_width();
812 base.height = left->get_height();
816 base.width = base.height = 0;
820 animation_offset = 0;
822 sprite_right = right;
828 // these can't be bumped
829 if(kind == BAD_FLAME || kind == BAD_BOMB || kind == BAD_FISH
830 || kind == BAD_FLYINGSNOWBALL)
833 physic.set_velocity_y(3);
838 BadGuy::make_player_jump(Player* player)
840 player->physic.set_velocity_y(2);
841 player->base.y = base.y - player->base.height - 2;
845 BadGuy::squish_me(Player* player)
847 make_player_jump(player);
849 World::current()->add_score(base.x,
850 base.y, 50 * player_status.score_multiplier);
851 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
852 player_status.score_multiplier++;
854 dying = DYING_SQUISHED;
856 physic.set_velocity(0, 0);
860 BadGuy::squish(Player* player)
862 static const int MAX_ICEBLOCK_SQUICHES = 10;
864 if(kind == BAD_MRBOMB) {
865 // mrbomb transforms into a bomb now
866 World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
868 make_player_jump(player);
869 World::current()->add_score(base.x, base.y, 50 * player_status.score_multiplier);
870 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
871 player_status.score_multiplier++;
875 } else if (kind == BAD_MRICEBLOCK) {
876 if (mode == NORMAL || mode == KICK)
879 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
881 set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
882 physic.set_velocity_x(0);
885 } else if (mode == FLAT) {
887 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
889 if (player->base.x < base.x + (base.width/2)) {
890 physic.set_velocity_x(5);
893 physic.set_velocity_x(-5);
898 player->kick_timer.start(KICKING_TIME);
899 set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
902 make_player_jump(player);
904 player_status.score_multiplier++;
906 // check for maximum number of squiches
908 if(squishcount >= MAX_ICEBLOCK_SQUICHES) {
914 } else if(kind == BAD_FISH) {
915 // fish can only be killed when falling down
916 if(physic.get_velocity_y() >= 0)
919 make_player_jump(player);
921 World::current()->add_score(base.x, base.y, 25 * player_status.score_multiplier);
922 player_status.score_multiplier++;
924 // simply remove the fish...
927 } else if(kind == BAD_BOUNCINGSNOWBALL) {
929 set_sprite(img_bouncingsnowball_squished,img_bouncingsnowball_squished);
931 } else if(kind == BAD_FLYINGSNOWBALL) {
933 set_sprite(img_flyingsnowball_squished,img_flyingsnowball_squished);
935 } else if(kind == BAD_SNOWBALL) {
937 set_sprite(img_snowball_squished_left, img_snowball_squished_right);
943 BadGuy::kill_me(int score)
948 dying = DYING_FALLING;
949 if(kind == BAD_MRICEBLOCK) {
950 set_sprite(img_mriceblock_falling_left, img_mriceblock_falling_right);
953 Player& tux = *World::current()->get_tux();
954 tux.holding_something = false;
958 physic.enable_gravity(true);
960 /* Gain some points: */
961 World::current()->add_score(base.x, base.y,
962 score * player_status.score_multiplier);
964 /* Play death sound: */
965 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
968 void BadGuy::explode(BadGuy *badguy)
970 World::current()->add_bad_guy(badguy->base.x, badguy->base.y, BAD_BOMB);
975 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
977 BadGuy* pbad_c = NULL;
978 Bullet* pbullet_c = NULL;
980 if(type == COLLISION_BUMP) {
985 if(type == COLLISION_SQUISH) {
986 Player* player = static_cast<Player*>(p_c_object);
991 /* COLLISION_NORMAL */
995 pbullet_c = (Bullet*) p_c_object;
997 if(pbullet_c->kind == FIRE_BULLET)
999 if(kind == BAD_MRICEBLOCK || kind == BAD_STALACTITE ||
1000 kind == BAD_FISH || kind == BAD_BOUNCINGSNOWBALL ||
1001 kind == BAD_FLYINGSNOWBALL || kind == BAD_FLYINGSNOWBALL)
1004 else if(pbullet_c->kind == ICE_BULLET)
1006 if(kind == BAD_FLAME)
1009 frozen_timer.start(FROZEN_TIME);
1014 pbad_c = (BadGuy*) p_c_object;
1016 /* If we're a kicked mriceblock, kill any badguys we hit */
1017 if(kind == BAD_MRICEBLOCK && mode == KICK)
1019 pbad_c->kill_me(25);
1022 // a held mriceblock gets kills the enemy too but falls to ground then
1023 else if(kind == BAD_MRICEBLOCK && mode == HELD)
1025 pbad_c->kill_me(25);
1029 /* Kill badguys that run into exploding bomb */
1030 else if (kind == BAD_BOMB && dying == DYING_NOT)
1032 if (pbad_c->kind == BAD_MRBOMB)
1034 // mrbomb transforms into a bomb now
1038 else if (pbad_c->kind != BAD_MRBOMB)
1040 pbad_c->kill_me(50);
1044 /* Kill any badguys that get hit by stalactite */
1045 else if (kind == BAD_STALACTITE && dying == DYING_NOT)
1047 if (pbad_c->kind == BAD_MRBOMB)
1049 // mrbomb transforms into a bomb now
1054 pbad_c->kill_me(50);
1057 /* When enemies run into eachother, make them change directions */
1060 // Jumpy, fish, flame, stalactites are exceptions
1061 if (pbad_c->kind == BAD_JUMPY || pbad_c->kind == BAD_FLAME
1062 || pbad_c->kind == BAD_STALACTITE || pbad_c->kind == BAD_FISH)
1065 // Bounce off of other badguy if we land on top of him
1066 if (base.y + base.height < pbad_c->base.y + pbad_c->base.height)
1068 if (pbad_c->dir == LEFT)
1071 physic.set_velocity(fabsf(physic.get_velocity_x()), 2);
1073 else if (pbad_c->dir == RIGHT)
1076 physic.set_velocity(-fabsf(physic.get_velocity_x()), 2);
1083 else if (base.y + base.height > pbad_c->base.y + pbad_c->base.height)
1086 if (pbad_c->kind != BAD_FLAME)
1091 physic.set_velocity_x(fabsf(physic.get_velocity_x()));
1093 else if (dir == RIGHT)
1096 physic.set_velocity_x(-fabsf(physic.get_velocity_x()));
1105 Player* player = static_cast<Player*>(p_c_object);
1106 /* Get kicked if were flat */
1107 if (mode == FLAT && !dying)
1109 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
1111 // Hit from left side
1112 if (player->base.x < base.x) {
1113 physic.set_velocity_x(5);
1116 // Hit from right side
1118 physic.set_velocity_x(-5);
1123 player->kick_timer.start(KICKING_TIME);
1124 set_sprite(img_mriceblock_flat_left, img_mriceblock_flat_right);
1132 //---------------------------------------------------------------------------
1134 void load_badguy_gfx()
1136 img_mriceblock_flat_left = sprite_manager->load("mriceblock-flat-left");
1137 img_mriceblock_flat_right = sprite_manager->load("mriceblock-flat-right");
1138 img_mriceblock_falling_left = sprite_manager->load("mriceblock-falling-left");
1139 img_mriceblock_falling_right = sprite_manager->load("mriceblock-falling-right");
1140 img_mriceblock_left = sprite_manager->load("mriceblock-left");
1141 img_mriceblock_right = sprite_manager->load("mriceblock-right");
1142 img_jumpy_left_up = sprite_manager->load("jumpy-left-up");
1143 img_jumpy_left_down = sprite_manager->load("jumpy-left-down");
1144 img_jumpy_left_middle = sprite_manager->load("jumpy-left-middle");
1145 img_jumpy_left_iced = sprite_manager->load("jumpy-left-iced");
1146 img_mrbomb_left = sprite_manager->load("mrbomb-left");
1147 img_mrbomb_right = sprite_manager->load("mrbomb-right");
1148 img_mrbomb_iced_left = sprite_manager->load("mrbomb-iced-left");
1149 img_mrbomb_iced_right = sprite_manager->load("mrbomb-iced-right");
1150 img_mrbomb_ticking_left = sprite_manager->load("mrbomb-ticking-left");
1151 img_mrbomb_ticking_right = sprite_manager->load("mrbomb-ticking-right");
1152 img_mrbomb_explosion = sprite_manager->load("mrbomb-explosion");
1153 img_stalactite = sprite_manager->load("stalactite");
1154 img_stalactite_broken = sprite_manager->load("stalactite-broken");
1155 img_flame = sprite_manager->load("flame");
1156 img_fish = sprite_manager->load("fish");
1157 img_fish_down = sprite_manager->load("fish-down");
1158 img_fish_iced = sprite_manager->load("fish-iced");
1159 img_fish_iced_down = sprite_manager->load("fish-iced-down");
1160 img_bouncingsnowball_left = sprite_manager->load("bouncingsnowball-left");
1161 img_bouncingsnowball_right = sprite_manager->load("bouncingsnowball-right");
1162 img_bouncingsnowball_squished = sprite_manager->load("bouncingsnowball-squished");
1163 img_flyingsnowball = sprite_manager->load("flyingsnowball");
1164 img_flyingsnowball_squished = sprite_manager->load("flyingsnowball-squished");
1165 img_spiky_left = sprite_manager->load("spiky-left");
1166 img_spiky_right = sprite_manager->load("spiky-right");
1167 img_spiky_iced_left = sprite_manager->load("spiky-iced-left");
1168 img_spiky_iced_right = sprite_manager->load("spiky-iced-right");
1169 img_snowball_left = sprite_manager->load("snowball-left");
1170 img_snowball_right = sprite_manager->load("snowball-right");
1171 img_snowball_squished_left = sprite_manager->load("snowball-squished-left");
1172 img_snowball_squished_right = sprite_manager->load("snowball-squished-right");
1175 void free_badguy_gfx()