2 // C Implementation: badguy
7 // Author: Tobias Glaesser <tobi.web@gmx.de> & Bill Kendrick, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
23 #include "resources.h"
24 #include "sprite_manager.h"
26 Sprite* img_bsod_squished_left;
27 Sprite* img_bsod_squished_right;
28 Sprite* img_bsod_falling_left;
29 Sprite* img_bsod_falling_right;
30 Sprite* img_laptop_flat_left;
31 Sprite* img_laptop_flat_right;
32 Sprite* img_laptop_falling_left;
33 Sprite* img_laptop_falling_right;
34 Sprite* img_bsod_left;
35 Sprite* img_bsod_right;
36 Sprite* img_laptop_left;
37 Sprite* img_laptop_right;
38 Sprite* img_jumpy_left_up;
39 Sprite* img_jumpy_left_down;
40 Sprite* img_jumpy_left_middle;
41 Sprite* img_mrbomb_left;
42 Sprite* img_mrbomb_right;
43 Sprite* img_mrbomb_ticking_left;
44 Sprite* img_mrbomb_ticking_right;
45 Sprite* img_mrbomb_explosion;
46 Sprite* img_stalactite;
47 Sprite* img_stalactite_broken;
50 Sprite* img_fish_down;
51 Sprite* img_bouncingsnowball_left;
52 Sprite* img_bouncingsnowball_right;
53 Sprite* img_bouncingsnowball_squished;
54 Sprite* img_flyingsnowball;
55 Sprite* img_flyingsnowball_squished;
56 Sprite* img_spiky_left;
57 Sprite* img_spiky_right;
58 Sprite* img_snowball_left;
59 Sprite* img_snowball_right;
60 Sprite* img_snowball_squished_left;
61 Sprite* img_snowball_squished_right;
63 BadGuyKind badguykind_from_string(const std::string& str)
67 else if (str == "laptop" || str == "mriceblock")
69 else if (str == "bsod")
71 else if (str == "mrbomb")
73 else if (str == "stalactite")
74 return BAD_STALACTITE;
75 else if (str == "flame")
77 else if (str == "fish")
79 else if (str == "bouncingsnowball")
80 return BAD_BOUNCINGSNOWBALL;
81 else if (str == "flyingsnowball")
82 return BAD_FLYINGSNOWBALL;
83 else if (str == "spiky")
85 else if (str == "snowball")
89 printf("Couldn't convert badguy: '%s'\n", str.c_str());
94 std::string badguykind_to_string(BadGuyKind kind)
119 case BAD_BOUNCINGSNOWBALL:
120 return "bouncingsnowball";
122 case BAD_FLYINGSNOWBALL:
123 return "flyingsnowball";
137 BadGuy::init(float x, float y, BadGuyKind kind_)
153 animation_length = 1;
154 animation_offset = 0;
155 sprite_left = sprite_right = 0;
159 if(kind == BAD_BSOD) {
160 physic.set_velocity(-1.3, 0);
161 set_sprite(img_bsod_left, img_bsod_right, 4);
162 } else if(kind == BAD_MRBOMB) {
163 physic.set_velocity(-1.3, 0);
164 set_sprite(img_mrbomb_left, img_mrbomb_right, 4);
165 } else if (kind == BAD_LAPTOP) {
166 physic.set_velocity(-1.3, 0);
167 set_sprite(img_laptop_left, img_laptop_right, 4, 5);
168 } else if(kind == BAD_MONEY) {
169 set_sprite(img_jumpy_left_up, img_jumpy_left_up, 1);
170 } else if(kind == BAD_BOMB) {
171 set_sprite(img_mrbomb_ticking_left, img_mrbomb_ticking_right, 1);
172 // hack so that the bomb doesn't hurt until it expldes...
173 dying = DYING_SQUISHED;
174 } else if(kind == BAD_FLAME) {
175 base.ym = 0; // we misuse base.ym as angle for the flame
176 physic.enable_gravity(false);
177 set_sprite(img_flame, img_flame, 2, 0.5);
178 } else if(kind == BAD_BOUNCINGSNOWBALL) {
179 physic.set_velocity(-1.3, 0);
180 set_sprite(img_bouncingsnowball_left, img_bouncingsnowball_right, 6);
181 } else if(kind == BAD_STALACTITE) {
182 physic.enable_gravity(false);
183 set_sprite(img_stalactite, img_stalactite, 1);
184 } else if(kind == BAD_FISH) {
185 set_sprite(img_fish, img_fish, 2, 1);
186 physic.enable_gravity(true);
187 } else if(kind == BAD_FLYINGSNOWBALL) {
188 set_sprite(img_flyingsnowball, img_flyingsnowball, 2, 5);
189 physic.enable_gravity(false);
190 } else if(kind == BAD_SPIKY) {
191 physic.set_velocity(-1.3, 0);
192 set_sprite(img_spiky_left, img_spiky_right, 3);
193 } else if(kind == BAD_SNOWBALL) {
194 physic.set_velocity(-1.3, 0);
195 set_sprite(img_snowball_left, img_snowball_right, 4, 5);
198 // if we're in a solid tile at start correct that now
199 if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(&base)) {
200 printf("Warning: badguy started in wall!.\n");
201 while(collision_object_map(&base))
207 BadGuy::action_bsod(float frame_ratio)
209 static const float BSODJUMP = 2;
211 if (dying == DYING_NOT)
212 check_horizontal_bump();
216 // jump when we're about to fall
217 if (physic.get_velocity_y() == 0 &&
218 !issolid(base.x+base.width/2, base.y + base.height)) {
219 physic.enable_gravity(true);
220 physic.set_velocity(physic.get_velocity_x(), BSODJUMP);
223 // Handle dying timer:
224 if (dying == DYING_SQUISHED && !timer.check())
226 /* Remove it if time's up: */
232 physic.apply(frame_ratio, base.x, base.y);
233 if(dying != DYING_FALLING)
234 collision_swept_object_map(&old_base, &base);
238 BadGuy::action_laptop(float frame_ratio)
240 Player& tux = *World::current()->get_tux();
242 if(dying == DYING_NOT)
245 /* Move left/right: */
246 if (mode == NORMAL || mode == KICK)
249 physic.apply(frame_ratio, base.x, base.y);
250 if (dying != DYING_FALLING)
251 collision_swept_object_map(&old_base,&base);
253 else if (mode == HELD)
254 { /* FIXME: The pbad object shouldn't know about pplayer objects. */
255 /* If we're holding the laptop */
259 base.x = tux.base.x + 16;
260 base.y = tux.base.y + tux.base.height/1.5 - base.height;
262 else /* facing left */
264 base.x = tux.base.x - 16;
265 base.y = tux.base.y + tux.base.height/1.5 - base.height;
267 if(collision_object_map(&base))
270 base.y = tux.base.y + tux.base.height/1.5 - base.height;
273 if(tux.input.fire != DOWN) /* SHOOT! */
282 set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1);
283 physic.set_velocity((dir == LEFT) ? -8 : 8, -8);
284 play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
291 check_horizontal_bump();
292 if(mode == KICK && changed != dir)
294 /* handle stereo sound (number 10 should be tweaked...)*/
295 if (base.x < scroll_x + screen->w/2 - 10)
296 play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
297 else if (base.x > scroll_x + screen->w/2 + 10)
298 play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
300 play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
304 /* Handle mode timer: */
310 set_sprite(img_laptop_left, img_laptop_right, 4, 5);
311 physic.set_velocity( (dir == LEFT) ? -1.3 : 1.3, 0);
317 BadGuy::check_horizontal_bump(bool checkcliff)
319 float halfheight = base.height / 2;
320 if (dir == LEFT && issolid( base.x, (int) base.y + halfheight))
323 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
326 if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight))
329 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
333 // don't check for cliffs when we're falling
336 if(!issolid(base.x + base.width/2, base.y + base.height))
339 if(dir == LEFT && !issolid(base.x, (int) base.y + base.height + halfheight))
342 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
345 if(dir == RIGHT && !issolid(base.x + base.width,
346 (int) base.y + base.height + halfheight))
349 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
357 /* Fall if we get off the ground: */
358 if (dying != DYING_FALLING)
360 if (!issolid(base.x+base.width/2, base.y + base.height))
362 // not solid below us? enable gravity
363 physic.enable_gravity(true);
368 if (physic.get_velocity_y() < 0)
370 base.y = int((base.y + base.height)/32) * 32 - base.height;
371 physic.set_velocity(physic.get_velocity_x(), 0);
373 // no gravity anymore please
374 physic.enable_gravity(false);
379 physic.enable_gravity(true);
386 for(std::vector<BadGuy>::iterator i = World::current()->bad_guys.begin();
387 i != World::current()->bad_guys.end(); ++i)
389 if( & (*i) == this) {
390 World::current()->bad_guys.erase(i);
397 BadGuy::action_money(float frame_ratio)
399 if (fabsf(physic.get_velocity_y()) < 2.5f)
400 set_sprite(img_jumpy_left_middle, img_jumpy_left_middle, 1);
401 else if (physic.get_velocity_y() < 0)
402 set_sprite(img_jumpy_left_up, img_jumpy_left_up, 1);
404 set_sprite(img_jumpy_left_down, img_jumpy_left_down, 1);
406 Player& tux = *World::current()->get_tux();
408 static const float JUMPV = 6;
411 // jump when on ground
412 if(dying == DYING_NOT && issolid(base.x, base.y+32))
414 physic.set_velocity(physic.get_velocity_x(), JUMPV);
415 physic.enable_gravity(true);
419 else if(mode == MONEY_JUMP)
424 // set direction based on tux
425 if(tux.base.x > base.x)
431 physic.apply(frame_ratio, base.x, base.y);
432 if(dying == DYING_NOT)
433 collision_swept_object_map(&old_base, &base);
437 BadGuy::action_mrbomb(float frame_ratio)
439 if (dying == DYING_NOT)
440 check_horizontal_bump(true);
444 physic.apply(frame_ratio, base.x, base.y);
445 if (dying != DYING_FALLING)
446 collision_swept_object_map(&old_base,&base);
450 BadGuy::action_bomb(float frame_ratio)
452 static const int TICKINGTIME = 1000;
453 static const int EXPLODETIME = 1000;
459 timer.start(TICKINGTIME);
460 } else if(!timer.check()) {
461 if(mode == BOMB_TICKING) {
463 set_sprite(img_mrbomb_explosion, img_mrbomb_explosion, 1);
464 dying = DYING_NOT; // now the bomb hurts
465 timer.start(EXPLODETIME);
466 } else if(mode == BOMB_EXPLODE) {
473 physic.apply(frame_ratio, base.x, base.y);
474 collision_swept_object_map(&old_base,&base);
478 BadGuy::action_stalactite(float frame_ratio)
480 Player& tux = *World::current()->get_tux();
482 static const int SHAKETIME = 800;
483 static const int RANGE = 40;
486 // start shaking when tux is below the stalactite and at least 40 pixels
488 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
489 && tux.base.y + tux.base.height > base.y) {
490 timer.start(SHAKETIME);
491 mode = STALACTITE_SHAKING;
493 } if(mode == STALACTITE_SHAKING) {
494 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
496 mode = STALACTITE_FALL;
498 } else if(mode == STALACTITE_FALL) {
500 /* Destroy if we collides with land */
501 if(issolid(base.x+base.width/2, base.y+base.height))
504 dying = DYING_SQUISHED;
506 set_sprite(img_stalactite_broken, img_stalactite_broken, 1);
508 } else if(mode == FLAT) {
513 physic.apply(frame_ratio, base.x, base.y);
515 if(dying == DYING_SQUISHED && !timer.check())
520 BadGuy::action_flame(float frame_ratio)
522 static const float radius = 100;
523 static const float speed = 0.02;
524 base.x = old_base.x + cos(base.ym) * radius;
525 base.y = old_base.y + sin(base.ym) * radius;
527 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
531 BadGuy::action_fish(float frame_ratio)
533 static const float JUMPV = 6;
534 static const int WAITTIME = 1000;
536 // go in wait mode when back in water
537 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
538 && physic.get_velocity_y() <= 0 && mode == NORMAL)
542 physic.set_velocity(0, 0);
543 physic.enable_gravity(false);
544 timer.start(WAITTIME);
546 else if(mode == FISH_WAIT && !timer.check())
549 set_sprite(img_fish, img_fish, 2, 2);
550 animation_offset = global_frame_counter; // restart animation
552 physic.set_velocity(0, JUMPV);
553 physic.enable_gravity(true);
556 physic.apply(frame_ratio, base.x, base.y);
557 if(dying == DYING_NOT)
558 collision_swept_object_map(&old_base, &base);
560 if(physic.get_velocity_y() < 0)
561 set_sprite(img_fish_down, img_fish_down);
565 BadGuy::action_bouncingsnowball(float frame_ratio)
567 static const float JUMPV = 4.5;
571 // jump when on ground
572 if(dying == DYING_NOT && issolid(base.x, base.y+32))
574 physic.set_velocity(physic.get_velocity_x(), JUMPV);
575 physic.enable_gravity(true);
582 // check for right/left collisions
583 check_horizontal_bump();
585 physic.apply(frame_ratio, base.x, base.y);
586 if(dying == DYING_NOT)
587 collision_swept_object_map(&old_base, &base);
589 // Handle dying timer:
590 if (dying == DYING_SQUISHED && !timer.check())
592 /* Remove it if time's up: */
599 BadGuy::action_flyingsnowball(float frame_ratio)
601 static const float FLYINGSPEED = 1;
602 static const int DIRCHANGETIME = 1000;
604 // go into flyup mode if none specified yet
605 if(dying == DYING_NOT && mode == NORMAL) {
607 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
608 timer.start(DIRCHANGETIME/2);
611 if(dying == DYING_NOT && !timer.check()) {
614 physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED);
615 } else if(mode == FLY_DOWN) {
617 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
619 timer.start(DIRCHANGETIME);
622 if(dying != DYING_NOT)
623 physic.enable_gravity(true);
625 physic.apply(frame_ratio, base.x, base.y);
626 if(dying == DYING_NOT || dying == DYING_SQUISHED)
627 collision_swept_object_map(&old_base, &base);
629 // Handle dying timer:
630 if (dying == DYING_SQUISHED && !timer.check())
632 /* Remove it if time's up: */
639 BadGuy::action_spiky(float frame_ratio)
641 if (dying == DYING_NOT)
642 check_horizontal_bump();
646 // jump when we're about to fall
647 if (physic.get_velocity_y() == 0 &&
648 !issolid(base.x+base.width/2, base.y + base.height)) {
649 physic.enable_gravity(true);
650 physic.set_velocity(physic.get_velocity_x(), 2);
654 physic.apply(frame_ratio, base.x, base.y);
655 if (dying != DYING_FALLING)
656 collision_swept_object_map(&old_base,&base);
660 BadGuy::action_snowball(float frame_ratio)
662 if (dying == DYING_NOT)
663 check_horizontal_bump();
667 physic.apply(frame_ratio, base.x, base.y);
668 if (dying != DYING_FALLING)
669 collision_swept_object_map(&old_base,&base);
673 BadGuy::action(float frame_ratio)
675 // Remove if it's far off the screen:
676 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
682 // BadGuy fall below the ground
683 if (base.y > screen->h) {
688 // Once it's on screen, it's activated!
689 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
698 action_bsod(frame_ratio);
702 action_laptop(frame_ratio);
706 action_money(frame_ratio);
710 action_mrbomb(frame_ratio);
714 action_bomb(frame_ratio);
718 action_stalactite(frame_ratio);
722 action_flame(frame_ratio);
726 action_fish(frame_ratio);
729 case BAD_BOUNCINGSNOWBALL:
730 action_bouncingsnowball(frame_ratio);
733 case BAD_FLYINGSNOWBALL:
734 action_flyingsnowball(frame_ratio);
738 action_spiky(frame_ratio);
742 action_snowball(frame_ratio);
750 // Don't try to draw stuff that is outside of the screen
751 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
754 if(sprite_left == 0 || sprite_right == 0)
756 std::cout << "BadGuy: Error no sprite loaded" << std::endl;
760 float global_frame = (float(global_frame_counter - animation_offset) / 10);
761 global_frame *= animation_speed;
762 //size_t frame = size_t(global_frame) % animation_length;
763 Sprite* sprite = (dir == LEFT) ? sprite_left : sprite_right;
764 sprite->draw(base.x - scroll_x, base.y);
767 fillrect(base.x - scroll_x, base.y, base.width, base.height, 75,0,75, 150);
771 BadGuy::set_sprite(Sprite* left, Sprite* right,
772 int nanimlength, float nanimspeed)
781 // FIXME: Using the image size for the physics and collision is
782 // a bad idea, since images should always overlap there physical
785 if(base.width == 0 && base.height == 0) {
786 base.width = left->get_width();
787 base.height = left->get_height();
788 } else if(base.width != left->get_width() || base.height != left->get_height()) {
789 base.x -= (left->get_width() - base.width) / 2;
790 base.y -= left->get_height() - base.height;
791 base.width = left->get_width();
792 base.height = left->get_height();
796 base.width = base.height = 0;
800 animation_length = nanimlength;
801 animation_speed = nanimspeed;
802 animation_offset = 0;
804 sprite_right = right;
810 if(kind == BAD_BSOD || kind == BAD_LAPTOP || kind == BAD_MRBOMB
811 || kind == BAD_BOUNCINGSNOWBALL) {
817 BadGuy::make_player_jump(Player* player)
819 player->physic.set_velocity(player->physic.get_velocity_x(), 2);
820 player->base.y = base.y - player->base.height - 2;
824 BadGuy::squish_me(Player* player)
826 make_player_jump(player);
828 World::current()->add_score(base.x - scroll_x,
829 base.y, 50 * player_status.score_multiplier);
830 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
831 player_status.score_multiplier++;
833 dying = DYING_SQUISHED;
835 physic.set_velocity(0, 0);
839 BadGuy::squish(Player* player)
841 if(kind == BAD_MRBOMB) {
842 // mrbomb transforms into a bomb now
843 World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
845 make_player_jump(player);
846 World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier);
847 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
848 player_status.score_multiplier++;
853 } else if(kind == BAD_BSOD) {
855 set_sprite(img_bsod_squished_left, img_bsod_squished_right, 1);
856 physic.set_velocity(0, physic.get_velocity_y());
859 } else if (kind == BAD_LAPTOP) {
860 if (mode == NORMAL || mode == KICK)
863 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
865 set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1);
866 physic.set_velocity(0, physic.get_velocity_y());
869 } else if (mode == FLAT) {
871 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
873 if (player->base.x < base.x + (base.width/2)) {
874 physic.set_velocity(5, physic.get_velocity_y());
877 physic.set_velocity(-5, physic.get_velocity_y());
882 set_sprite(img_laptop_flat_left, img_laptop_flat_right, 1);
885 make_player_jump(player);
887 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
888 player_status.score_multiplier++;
890 } else if(kind == BAD_FISH) {
891 // fish can only be killed when falling down
892 if(physic.get_velocity_y() >= 0)
895 make_player_jump(player);
897 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
898 player_status.score_multiplier++;
900 // simply remove the fish...
903 } else if(kind == BAD_BOUNCINGSNOWBALL) {
905 set_sprite(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1);
907 } else if(kind == BAD_FLYINGSNOWBALL) {
909 set_sprite(img_flyingsnowball_squished,img_flyingsnowball_squished,1);
911 } else if(kind == BAD_SNOWBALL) {
913 set_sprite(img_snowball_squished_left, img_snowball_squished_right, 1);
921 if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
924 dying = DYING_FALLING;
925 if(kind == BAD_LAPTOP)
926 set_sprite(img_laptop_falling_left, img_laptop_falling_right, 1);
927 else if(kind == BAD_BSOD)
928 set_sprite(img_bsod_falling_left, img_bsod_falling_right, 1);
930 physic.enable_gravity(true);
931 physic.set_velocity(physic.get_velocity_x(), 0);
933 /* Gain some points: */
934 if (kind == BAD_BSOD)
935 World::current()->add_score(base.x - scroll_x, base.y,
936 50 * player_status.score_multiplier);
938 World::current()->add_score(base.x - scroll_x, base.y,
939 25 * player_status.score_multiplier);
941 /* Play death sound: */
942 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
946 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
948 BadGuy* pbad_c = NULL;
950 if(type == COLLISION_BUMP) {
954 if(type == COLLISION_SQUISH) {
955 Player* player = static_cast<Player*>(p_c_object);
967 pbad_c = (BadGuy*) p_c_object;
968 if(kind == BAD_LAPTOP && mode == KICK &&
969 pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB)
971 /* We're in kick mode, kill the other guy
972 and yourself(wuahaha) : */
980 //---------------------------------------------------------------------------
982 void load_badguy_gfx()
984 img_bsod_squished_left = sprite_manager->load("bsod-squished-left");
985 img_bsod_squished_right = sprite_manager->load("bsod-squished-right");
986 img_bsod_falling_left = sprite_manager->load("bsod-falling-left");
987 img_bsod_falling_right = sprite_manager->load("bsod-falling-right");
988 img_laptop_flat_left = sprite_manager->load("laptop-flat-left");
989 img_laptop_flat_right = sprite_manager->load("laptop-flat-right");
990 img_laptop_falling_left = sprite_manager->load("laptop-falling-left");
991 img_laptop_falling_right = sprite_manager->load("laptop-falling-right");
992 img_bsod_left = sprite_manager->load("bsod-left");
993 img_bsod_right = sprite_manager->load("bsod-right");
994 img_laptop_left = sprite_manager->load("laptop-left");
995 img_laptop_right = sprite_manager->load("laptop-right");
996 img_jumpy_left_up = sprite_manager->load("jumpy-left-up");
997 img_jumpy_left_down = sprite_manager->load("jumpy-left-down");
998 img_jumpy_left_middle = sprite_manager->load("jumpy-left-middle");
999 img_mrbomb_left = sprite_manager->load("mrbomb-left");
1000 img_mrbomb_right = sprite_manager->load("mrbomb-right");
1001 img_mrbomb_ticking_left = sprite_manager->load("mrbomb-ticking-left");
1002 img_mrbomb_ticking_right = sprite_manager->load("mrbomb-ticking-right");
1003 img_mrbomb_explosion = sprite_manager->load("mrbomb-explosion");
1004 img_stalactite = sprite_manager->load("stalactite");
1005 img_stalactite_broken = sprite_manager->load("stalactite-broken");
1006 img_flame = sprite_manager->load("flame");
1007 img_fish = sprite_manager->load("fish");
1008 img_fish_down = sprite_manager->load("fish-down");
1009 img_bouncingsnowball_left = sprite_manager->load("bouncingsnowball-left");
1010 img_bouncingsnowball_right = sprite_manager->load("bouncingsnowball-right");
1011 img_bouncingsnowball_squished = sprite_manager->load("bouncingsnowball-squished");
1012 img_flyingsnowball = sprite_manager->load("flyingsnowball");
1013 img_flyingsnowball_squished = sprite_manager->load("flyingsnowball-squished");
1014 img_spiky_left = sprite_manager->load("spiky-left");
1015 img_spiky_right = sprite_manager->load("spiky-right");
1016 img_snowball_left = sprite_manager->load("snowball-left");
1017 img_snowball_right = sprite_manager->load("snowball-right");
1018 img_snowball_squished_left = sprite_manager->load("snowball-squished-left");
1019 img_snowball_squished_right = sprite_manager->load("snowball-squished-right");
1022 img_bsod_left[0] = new Surface(datadir + "/images/shared/bsod-left-0.png", USE_ALPHA);
1024 img_bsod_left[1] = new Surface(datadir +
1025 "/images/shared/bsod-left-1.png",
1028 img_bsod_left[2] = new Surface(datadir +
1029 "/images/shared/bsod-left-2.png",
1032 img_bsod_left[3] = new Surface(datadir +
1033 "/images/shared/bsod-left-3.png",
1036 img_bsod_right[0] = new Surface(datadir +
1037 "/images/shared/bsod-right-0.png",
1040 img_bsod_right[1] = new Surface(datadir +
1041 "/images/shared/bsod-right-1.png",
1044 img_bsod_right[2] = new Surface(datadir +
1045 "/images/shared/bsod-right-2.png",
1048 img_bsod_right[3] = new Surface(datadir +
1049 "/images/shared/bsod-right-3.png",
1052 img_bsod_squished_left[0] = new Surface(datadir +
1053 "/images/shared/bsod-squished-left.png",
1056 img_bsod_squished_right[0] = new Surface(datadir +
1057 "/images/shared/bsod-squished-right.png",
1060 img_bsod_falling_left[0] = new Surface(datadir +
1061 "/images/shared/bsod-falling-left.png",
1064 img_bsod_falling_right[0] = new Surface(datadir +
1065 "/images/shared/bsod-falling-right.png",
1071 img_laptop_left[0] = new Surface(datadir + "/images/shared/mriceblock-left-0.png", USE_ALPHA);
1072 img_laptop_left[1] = new Surface(datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1073 img_laptop_left[2] = new Surface(datadir + "/images/shared/mriceblock-left-2.png", USE_ALPHA);
1074 img_laptop_left[3] = new Surface(datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1076 img_laptop_right[0] = new Surface(datadir + "/images/shared/mriceblock-right-0.png", USE_ALPHA);
1077 img_laptop_right[1] = new Surface(datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1078 img_laptop_right[2] = new Surface(datadir + "/images/shared/mriceblock-right-2.png", USE_ALPHA);
1079 img_laptop_right[3] = new Surface(datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1081 img_laptop_flat_left[0] = new Surface(
1082 datadir + "/images/shared/laptop-flat-left.png",
1085 img_laptop_flat_right[0] = new Surface(datadir +
1086 "/images/shared/laptop-flat-right.png",
1089 img_laptop_falling_left[0] = new Surface(datadir +
1090 "/images/shared/laptop-falling-left.png",
1093 img_laptop_falling_right[0] = new Surface(datadir +
1094 "/images/shared/laptop-falling-right.png",
1099 img_jumpy_left_up = new Surface(datadir +
1100 "/images/shared/jumpy-left-up-0.png",
1102 img_jumpy_left_down = new Surface(datadir +
1103 "/images/shared/jumpy-left-down-0.png",
1105 img_jumpy_left_middle = new Surface(datadir +
1106 "/images/shared/jumpy-left-middle-0.png",
1110 for(int i=0; i<4; ++i) {
1112 snprintf(num, 4, "%d", i);
1113 img_mrbomb_left[i] = new Surface(
1114 datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA);
1115 img_mrbomb_right[i] = new Surface(
1116 datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA);
1118 img_mrbomb_ticking_left[0] = new Surface(
1119 datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA);
1120 img_mrbomb_ticking_right[0] = new Surface(
1121 datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA);
1122 img_mrbomb_explosion[0] = new Surface(
1123 datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA);
1126 img_stalactite[0] = new Surface(
1127 datadir + "/images/shared/stalactite.png", USE_ALPHA);
1128 img_stalactite_broken[0] = new Surface(
1129 datadir + "/images/shared/stalactite-broken.png", USE_ALPHA);
1132 img_flame[0] = new Surface(
1133 datadir + "/images/shared/flame-0.png", USE_ALPHA);
1134 img_flame[1] = new Surface(
1135 datadir + "/images/shared/flame-1.png", USE_ALPHA);
1138 img_fish[0] = new Surface(
1139 datadir + "/images/shared/fish-left-0.png", USE_ALPHA);
1140 img_fish[1] = new Surface(
1141 datadir + "/images/shared/fish-left-1.png", USE_ALPHA);
1142 img_fish_down[0] = new Surface(
1143 datadir + "/images/shared/fish-down-0.png", USE_ALPHA);
1145 /* bouncing snowball */
1146 for(int i=0; i<6; ++i) {
1148 snprintf(num, 4, "%d", i);
1149 img_bouncingsnowball_left[i] = new Surface(
1150 datadir + "/images/shared/bouncingsnowball-left-" + num + ".png",
1152 img_bouncingsnowball_right[i] = new Surface(
1153 datadir + "/images/shared/bouncingsnowball-right-" + num + ".png",
1156 img_bouncingsnowball_squished[0] = new Surface(
1157 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1159 /* flying snowball */
1160 img_flyingsnowball[0] = new Surface(
1161 datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA);
1162 img_flyingsnowball[1] = new Surface(
1163 datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA);
1164 img_flyingsnowball_squished[0] = new Surface(
1165 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1168 for(int i = 0; i < 3; ++i) {
1170 snprintf(num, 4, "%d", i);
1171 img_spiky_left[i] = new Surface(
1172 datadir + "/images/shared/spiky-left-" + num + ".png",
1174 img_spiky_right[i] = new Surface(
1175 datadir + "/images/shared/spiky-right-" + num + ".png",
1180 img_snowball_left[0] = new Surface(datadir + "/images/shared/snowball-left-0.png", USE_ALPHA);
1181 img_snowball_left[1] = new Surface(datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1182 img_snowball_left[2] = new Surface(datadir + "/images/shared/snowball-left-2.png", USE_ALPHA);
1183 img_snowball_left[3] = new Surface(datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1185 img_snowball_right[0] = new Surface(datadir + "/images/shared/snowball-right-0.png", USE_ALPHA);
1186 img_snowball_right[1] = new Surface(datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1187 img_snowball_right[2] = new Surface(datadir + "/images/shared/snowball-right-2.png", USE_ALPHA);
1188 img_snowball_right[3] = new Surface(datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1190 img_snowball_squished_left[0] = new Surface(
1191 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1192 img_snowball_squished_right[0] = new Surface(
1193 datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA);
1197 void free_badguy_gfx()