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
22 Surface* img_bsod_squished_left[1];
23 Surface* img_bsod_squished_right[1];
24 Surface* img_bsod_falling_left[1];
25 Surface* img_bsod_falling_right[1];
26 Surface* img_laptop_flat_left[1];
27 Surface* img_laptop_flat_right[1];
28 Surface* img_laptop_falling_left[1];
29 Surface* img_laptop_falling_right[1];
30 Surface* img_bsod_left[4];
31 Surface* img_bsod_right[4];
32 Surface* img_laptop_left[4];
33 Surface* img_laptop_right[4];
34 Surface* img_money_left[2];
35 Surface* img_money_right[2];
36 Surface* img_mrbomb_left[4];
37 Surface* img_mrbomb_right[4];
38 Surface* img_mrbomb_ticking_left[1];
39 Surface* img_mrbomb_ticking_right[1];
40 Surface* img_mrbomb_explosion[1];
41 Surface* img_stalactite[1];
42 Surface* img_stalactite_broken[1];
43 Surface* img_flame[2];
45 Surface* img_fish_down[1];
46 Surface* img_bouncingsnowball_left[6];
47 Surface* img_bouncingsnowball_right[6];
48 Surface* img_bouncingsnowball_squished[1];
49 Surface* img_flyingsnowball[2];
50 Surface* img_flyingsnowball_squished[1];
51 Surface* img_spiky_left[3];
52 Surface* img_spiky_right[3];
53 Surface* img_snowball_left[4];
54 Surface* img_snowball_right[4];
55 Surface* img_snowball_squished_left[1];
56 Surface* img_snowball_squished_right[1];
58 BadGuyKind badguykind_from_string(const std::string& str)
62 else if (str == "laptop" || str == "mriceblock")
64 else if (str == "bsod")
66 else if (str == "mrbomb")
68 else if (str == "stalactite")
69 return BAD_STALACTITE;
70 else if (str == "flame")
72 else if (str == "fish")
74 else if (str == "bouncingsnowball")
75 return BAD_BOUNCINGSNOWBALL;
76 else if (str == "flyingsnowball")
77 return BAD_FLYINGSNOWBALL;
78 else if (str == "spiky")
80 else if (str == "snowball")
84 printf("Couldn't convert badguy: '%s'\n", str.c_str());
89 std::string badguykind_to_string(BadGuyKind kind)
114 case BAD_BOUNCINGSNOWBALL:
115 return "bouncingsnowball";
117 case BAD_FLYINGSNOWBALL:
118 return "flyingsnowball";
132 BadGuy::init(float x, float y, BadGuyKind kind_)
148 animation_length = 1;
149 animation_offset = 0;
150 texture_left = texture_right = 0;
154 if(kind == BAD_BSOD) {
155 physic.set_velocity(-1.3, 0);
156 set_texture(img_bsod_left, img_bsod_right, 4);
157 } else if(kind == BAD_MRBOMB) {
158 physic.set_velocity(-1.3, 0);
159 set_texture(img_mrbomb_left, img_mrbomb_right, 4);
160 } else if (kind == BAD_LAPTOP) {
161 physic.set_velocity(-1.3, 0);
162 set_texture(img_laptop_left, img_laptop_right, 4, 5);
163 } else if(kind == BAD_MONEY) {
164 set_texture(img_money_left, img_money_right, 1);
165 } else if(kind == BAD_BOMB) {
166 set_texture(img_mrbomb_ticking_left, img_mrbomb_ticking_right, 1);
167 // hack so that the bomb doesn't hurt until it expldes...
168 dying = DYING_SQUISHED;
169 } else if(kind == BAD_FLAME) {
170 base.ym = 0; // we misuse base.ym as angle for the flame
171 physic.enable_gravity(false);
172 set_texture(img_flame, img_flame, 2, 0.5);
173 } else if(kind == BAD_BOUNCINGSNOWBALL) {
174 physic.set_velocity(-1.3, 0);
175 set_texture(img_bouncingsnowball_left, img_bouncingsnowball_right, 6);
176 } else if(kind == BAD_STALACTITE) {
177 physic.enable_gravity(false);
178 set_texture(img_stalactite, img_stalactite, 1);
179 } else if(kind == BAD_FISH) {
180 set_texture(img_fish, img_fish, 2, 1);
181 physic.enable_gravity(true);
182 } else if(kind == BAD_FLYINGSNOWBALL) {
183 set_texture(img_flyingsnowball, img_flyingsnowball, 2, 5);
184 physic.enable_gravity(false);
185 } else if(kind == BAD_SPIKY) {
186 physic.set_velocity(-1.3, 0);
187 set_texture(img_spiky_left, img_spiky_right, 3);
188 } else if(kind == BAD_SNOWBALL) {
189 physic.set_velocity(-1.3, 0);
190 set_texture(img_snowball_left, img_snowball_right, 4, 5);
193 // if we're in a solid tile at start correct that now
194 if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(&base)) {
195 printf("Warning: badguy started in wall!.\n");
196 while(collision_object_map(&base))
202 BadGuy::action_bsod(float frame_ratio)
204 static const float BSODJUMP = 2;
206 if (dying == DYING_NOT)
207 check_horizontal_bump();
211 // jump when we're about to fall
212 if (physic.get_velocity_y() == 0 &&
213 !issolid(base.x+base.width/2, base.y + base.height)) {
214 physic.enable_gravity(true);
215 physic.set_velocity(physic.get_velocity_x(), BSODJUMP);
218 // Handle dying timer:
219 if (dying == DYING_SQUISHED && !timer.check())
221 /* Remove it if time's up: */
227 physic.apply(frame_ratio, base.x, base.y);
228 if(dying != DYING_FALLING)
229 collision_swept_object_map(&old_base, &base);
233 BadGuy::action_laptop(float frame_ratio)
235 Player& tux = *World::current()->get_tux();
237 if(dying == DYING_NOT)
240 /* Move left/right: */
241 if (mode == NORMAL || mode == KICK)
244 physic.apply(frame_ratio, base.x, base.y);
245 if (dying != DYING_FALLING)
246 collision_swept_object_map(&old_base,&base);
248 else if (mode == HELD)
249 { /* FIXME: The pbad object shouldn't know about pplayer objects. */
250 /* If we're holding the laptop */
254 base.x = tux.base.x + 16;
255 base.y = tux.base.y + tux.base.height/1.5 - base.height;
257 else /* facing left */
259 base.x = tux.base.x - 16;
260 base.y = tux.base.y + tux.base.height/1.5 - base.height;
262 if(collision_object_map(&base))
265 base.y = tux.base.y + tux.base.height/1.5 - base.height;
268 if(tux.input.fire != DOWN) /* SHOOT! */
277 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
278 physic.set_velocity((dir == LEFT) ? -8 : 8, -8);
279 play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
286 check_horizontal_bump();
287 if(mode == KICK && changed != dir)
289 /* handle stereo sound (number 10 should be tweaked...)*/
290 if (base.x < scroll_x + screen->w/2 - 10)
291 play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
292 else if (base.x > scroll_x + screen->w/2 + 10)
293 play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
295 play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
299 /* Handle mode timer: */
305 set_texture(img_laptop_left, img_laptop_right, 4, 5);
306 physic.set_velocity( (dir == LEFT) ? -1.3 : 1.3, 0);
312 BadGuy::check_horizontal_bump(bool checkcliff)
314 float halfheight = base.height / 2;
315 if (dir == LEFT && issolid( base.x, (int) base.y + halfheight))
318 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
321 if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight))
324 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
328 // don't check for cliffs when we're falling
331 if(!issolid(base.x + base.width/2, base.y + base.height))
334 if(dir == LEFT && !issolid(base.x, (int) base.y + base.height + halfheight))
337 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
340 if(dir == RIGHT && !issolid(base.x + base.width,
341 (int) base.y + base.height + halfheight))
344 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
352 /* Fall if we get off the ground: */
353 if (dying != DYING_FALLING)
355 if (!issolid(base.x+base.width/2, base.y + base.height))
357 // not solid below us? enable gravity
358 physic.enable_gravity(true);
363 if (physic.get_velocity_y() < 0)
365 base.y = int((base.y + base.height)/32) * 32 - base.height;
366 physic.set_velocity(physic.get_velocity_x(), 0);
368 // no gravity anymore please
369 physic.enable_gravity(false);
374 physic.enable_gravity(true);
381 for(std::vector<BadGuy>::iterator i = World::current()->bad_guys.begin();
382 i != World::current()->bad_guys.end(); ++i)
384 if( & (*i) == this) {
385 World::current()->bad_guys.erase(i);
392 BadGuy::action_money(float frame_ratio)
394 Player& tux = *World::current()->get_tux();
396 static const float JUMPV = 6;
399 // jump when on ground
400 if(dying == DYING_NOT && issolid(base.x, base.y+32))
402 physic.set_velocity(physic.get_velocity_x(), JUMPV);
403 physic.enable_gravity(true);
404 set_texture(&img_money_left[1], &img_money_right[1], 1);
407 else if(mode == MONEY_JUMP)
409 set_texture(&img_money_left[0], &img_money_right[0], 1);
413 // set direction based on tux
414 if(tux.base.x > base.x)
420 physic.apply(frame_ratio, base.x, base.y);
421 if(dying == DYING_NOT)
422 collision_swept_object_map(&old_base, &base);
426 BadGuy::action_mrbomb(float frame_ratio)
428 if (dying == DYING_NOT)
429 check_horizontal_bump(true);
433 physic.apply(frame_ratio, base.x, base.y);
434 if (dying != DYING_FALLING)
435 collision_swept_object_map(&old_base,&base);
439 BadGuy::action_bomb(float frame_ratio)
441 static const int TICKINGTIME = 1000;
442 static const int EXPLODETIME = 1000;
448 timer.start(TICKINGTIME);
449 } else if(!timer.check()) {
450 if(mode == BOMB_TICKING) {
452 set_texture(img_mrbomb_explosion, img_mrbomb_explosion, 1);
453 dying = DYING_NOT; // now the bomb hurts
454 timer.start(EXPLODETIME);
455 } else if(mode == BOMB_EXPLODE) {
462 physic.apply(frame_ratio, base.x, base.y);
463 collision_swept_object_map(&old_base,&base);
467 BadGuy::action_stalactite(float frame_ratio)
469 Player& tux = *World::current()->get_tux();
471 static const int SHAKETIME = 800;
472 static const int RANGE = 40;
475 // start shaking when tux is below the stalactite and at least 40 pixels
477 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
478 && tux.base.y + tux.base.height > base.y) {
479 timer.start(SHAKETIME);
480 mode = STALACTITE_SHAKING;
482 } if(mode == STALACTITE_SHAKING) {
483 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
485 mode = STALACTITE_FALL;
487 } else if(mode == STALACTITE_FALL) {
489 /* Destroy if we collides with land */
490 if(issolid(base.x+base.width/2, base.y+base.height))
493 dying = DYING_SQUISHED;
495 set_texture(img_stalactite_broken, img_stalactite_broken, 1);
497 } else if(mode == FLAT) {
502 physic.apply(frame_ratio, base.x, base.y);
504 if(dying == DYING_SQUISHED && !timer.check())
509 BadGuy::action_flame(float frame_ratio)
511 static const float radius = 100;
512 static const float speed = 0.02;
513 base.x = old_base.x + cos(base.ym) * radius;
514 base.y = old_base.y + sin(base.ym) * radius;
516 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
520 BadGuy::action_fish(float frame_ratio)
522 static const float JUMPV = 6;
523 static const int WAITTIME = 1000;
525 // go in wait mode when back in water
526 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
527 && physic.get_velocity_y() <= 0 && mode == NORMAL)
531 physic.set_velocity(0, 0);
532 physic.enable_gravity(false);
533 timer.start(WAITTIME);
535 else if(mode == FISH_WAIT && !timer.check())
538 set_texture(img_fish, img_fish, 2, 2);
539 animation_offset = global_frame_counter; // restart animation
541 physic.set_velocity(0, JUMPV);
542 physic.enable_gravity(true);
545 physic.apply(frame_ratio, base.x, base.y);
546 if(dying == DYING_NOT)
547 collision_swept_object_map(&old_base, &base);
549 if(physic.get_velocity_y() < 0)
550 set_texture(img_fish_down, img_fish_down);
554 BadGuy::action_bouncingsnowball(float frame_ratio)
556 static const float JUMPV = 4.5;
560 // jump when on ground
561 if(dying == DYING_NOT && issolid(base.x, base.y+32))
563 physic.set_velocity(physic.get_velocity_x(), JUMPV);
564 physic.enable_gravity(true);
571 // check for right/left collisions
572 check_horizontal_bump();
574 physic.apply(frame_ratio, base.x, base.y);
575 if(dying == DYING_NOT)
576 collision_swept_object_map(&old_base, &base);
578 // Handle dying timer:
579 if (dying == DYING_SQUISHED && !timer.check())
581 /* Remove it if time's up: */
588 BadGuy::action_flyingsnowball(float frame_ratio)
590 static const float FLYINGSPEED = 1;
591 static const int DIRCHANGETIME = 1000;
593 // go into flyup mode if none specified yet
594 if(dying == DYING_NOT && mode == NORMAL) {
596 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
597 timer.start(DIRCHANGETIME/2);
600 if(dying == DYING_NOT && !timer.check()) {
603 physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED);
604 } else if(mode == FLY_DOWN) {
606 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
608 timer.start(DIRCHANGETIME);
611 if(dying != DYING_NOT)
612 physic.enable_gravity(true);
614 physic.apply(frame_ratio, base.x, base.y);
615 if(dying == DYING_NOT || dying == DYING_SQUISHED)
616 collision_swept_object_map(&old_base, &base);
618 // Handle dying timer:
619 if (dying == DYING_SQUISHED && !timer.check())
621 /* Remove it if time's up: */
628 BadGuy::action_spiky(float frame_ratio)
630 if (dying == DYING_NOT)
631 check_horizontal_bump();
635 // jump when we're about to fall
636 if (physic.get_velocity_y() == 0 &&
637 !issolid(base.x+base.width/2, base.y + base.height)) {
638 physic.enable_gravity(true);
639 physic.set_velocity(physic.get_velocity_x(), 2);
643 physic.apply(frame_ratio, base.x, base.y);
644 if (dying != DYING_FALLING)
645 collision_swept_object_map(&old_base,&base);
649 BadGuy::action_snowball(float frame_ratio)
651 if (dying == DYING_NOT)
652 check_horizontal_bump();
656 physic.apply(frame_ratio, base.x, base.y);
657 if (dying != DYING_FALLING)
658 collision_swept_object_map(&old_base,&base);
662 BadGuy::action(float frame_ratio)
664 // Remove if it's far off the screen:
665 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
671 // BadGuy fall below the ground
672 if (base.y > screen->h) {
677 // Once it's on screen, it's activated!
678 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
687 action_bsod(frame_ratio);
691 action_laptop(frame_ratio);
695 action_money(frame_ratio);
699 action_mrbomb(frame_ratio);
703 action_bomb(frame_ratio);
707 action_stalactite(frame_ratio);
711 action_flame(frame_ratio);
715 action_fish(frame_ratio);
718 case BAD_BOUNCINGSNOWBALL:
719 action_bouncingsnowball(frame_ratio);
722 case BAD_FLYINGSNOWBALL:
723 action_flyingsnowball(frame_ratio);
727 action_spiky(frame_ratio);
731 action_snowball(frame_ratio);
739 // Don't try to draw stuff that is outside of the screen
740 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
742 if(texture_left == 0 || texture_right == 0)
745 float global_frame = (float(global_frame_counter - animation_offset) / 10);
746 global_frame *= animation_speed;
747 size_t frame = size_t(global_frame) % animation_length;
749 (dir == LEFT) ? texture_left[frame] : texture_right[frame];
750 texture->draw(base.x - scroll_x, base.y);
753 fillrect(base.x - scroll_x, base.y, 32, 32, 75,0,75, 150);
757 BadGuy::set_texture(Surface** left, Surface** right,
758 int nanimlength, float nanimspeed)
761 if(base.width == 0 && base.height == 0) {
762 base.width = left[0]->w;
763 base.height = left[0]->h;
764 } else if(base.width != left[0]->w || base.height != left[0]->h) {
765 base.x -= (left[0]->w - base.width) / 2;
766 base.y -= left[0]->h - base.height;
767 base.width = left[0]->w;
768 base.height = left[0]->h;
772 base.width = base.height = 0;
775 animation_length = nanimlength;
776 animation_speed = nanimspeed;
777 animation_offset = 0;
779 texture_right = right;
785 if(kind == BAD_BSOD || kind == BAD_LAPTOP || kind == BAD_MRBOMB
786 || kind == BAD_BOUNCINGSNOWBALL) {
792 BadGuy::make_player_jump(Player* player)
794 player->physic.set_velocity(player->physic.get_velocity_x(), 2);
795 player->base.y = base.y - player->base.height - 2;
799 BadGuy::squish_me(Player* player)
801 make_player_jump(player);
803 World::current()->add_score(base.x - scroll_x,
804 base.y, 50 * player_status.score_multiplier);
805 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
806 player_status.score_multiplier++;
808 dying = DYING_SQUISHED;
810 physic.set_velocity(0, 0);
814 BadGuy::squish(Player* player)
816 if(kind == BAD_MRBOMB) {
817 // mrbomb transforms into a bomb now
818 World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
820 make_player_jump(player);
821 World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier);
822 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
823 player_status.score_multiplier++;
828 } else if(kind == BAD_BSOD) {
830 set_texture(img_bsod_squished_left, img_bsod_squished_right, 1);
831 physic.set_velocity(0, physic.get_velocity_y());
834 } else if (kind == BAD_LAPTOP) {
835 if (mode == NORMAL || mode == KICK)
838 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
840 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
841 physic.set_velocity(0, physic.get_velocity_y());
844 } else if (mode == FLAT) {
846 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
848 if (player->base.x < base.x + (base.width/2)) {
849 physic.set_velocity(5, physic.get_velocity_y());
852 physic.set_velocity(-5, physic.get_velocity_y());
857 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
860 make_player_jump(player);
862 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
863 player_status.score_multiplier++;
865 } else if(kind == BAD_FISH) {
866 // fish can only be killed when falling down
867 if(physic.get_velocity_y() >= 0)
870 make_player_jump(player);
872 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
873 player_status.score_multiplier++;
875 // simply remove the fish...
878 } else if(kind == BAD_BOUNCINGSNOWBALL) {
880 set_texture(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1);
882 } else if(kind == BAD_FLYINGSNOWBALL) {
884 set_texture(img_flyingsnowball_squished,img_flyingsnowball_squished,1);
886 } else if(kind == BAD_SNOWBALL) {
888 set_texture(img_snowball_squished_left, img_snowball_squished_right, 1);
896 if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
899 dying = DYING_FALLING;
900 if(kind == BAD_LAPTOP)
901 set_texture(img_laptop_falling_left, img_laptop_falling_right, 1);
902 else if(kind == BAD_BSOD)
903 set_texture(img_bsod_falling_left, img_bsod_falling_right, 1);
905 physic.enable_gravity(true);
906 physic.set_velocity(physic.get_velocity_x(), 0);
908 /* Gain some points: */
909 if (kind == BAD_BSOD)
910 World::current()->add_score(base.x - scroll_x, base.y,
911 50 * player_status.score_multiplier);
913 World::current()->add_score(base.x - scroll_x, base.y,
914 25 * player_status.score_multiplier);
916 /* Play death sound: */
917 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
921 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
923 BadGuy* pbad_c = NULL;
925 if(type == COLLISION_BUMP) {
929 if(type == COLLISION_SQUISH) {
930 Player* player = static_cast<Player*>(p_c_object);
942 pbad_c = (BadGuy*) p_c_object;
943 if(kind == BAD_LAPTOP && mode == KICK &&
944 pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB)
946 /* We're in kick mode, kill the other guy
947 and yourself(wuahaha) : */
955 //---------------------------------------------------------------------------
957 void load_badguy_gfx()
960 img_bsod_left[0] = new Surface(datadir + "/images/shared/bsod-left-0.png", USE_ALPHA);
962 img_bsod_left[1] = new Surface(datadir +
963 "/images/shared/bsod-left-1.png",
966 img_bsod_left[2] = new Surface(datadir +
967 "/images/shared/bsod-left-2.png",
970 img_bsod_left[3] = new Surface(datadir +
971 "/images/shared/bsod-left-3.png",
974 img_bsod_right[0] = new Surface(datadir +
975 "/images/shared/bsod-right-0.png",
978 img_bsod_right[1] = new Surface(datadir +
979 "/images/shared/bsod-right-1.png",
982 img_bsod_right[2] = new Surface(datadir +
983 "/images/shared/bsod-right-2.png",
986 img_bsod_right[3] = new Surface(datadir +
987 "/images/shared/bsod-right-3.png",
990 img_bsod_squished_left[0] = new Surface(datadir +
991 "/images/shared/bsod-squished-left.png",
994 img_bsod_squished_right[0] = new Surface(datadir +
995 "/images/shared/bsod-squished-right.png",
998 img_bsod_falling_left[0] = new Surface(datadir +
999 "/images/shared/bsod-falling-left.png",
1002 img_bsod_falling_right[0] = new Surface(datadir +
1003 "/images/shared/bsod-falling-right.png",
1009 img_laptop_left[0] = new Surface(datadir + "/images/shared/mriceblock-left-0.png", USE_ALPHA);
1010 img_laptop_left[1] = new Surface(datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1011 img_laptop_left[2] = new Surface(datadir + "/images/shared/mriceblock-left-2.png", USE_ALPHA);
1012 img_laptop_left[3] = new Surface(datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1014 img_laptop_right[0] = new Surface(datadir + "/images/shared/mriceblock-right-0.png", USE_ALPHA);
1015 img_laptop_right[1] = new Surface(datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1016 img_laptop_right[2] = new Surface(datadir + "/images/shared/mriceblock-right-2.png", USE_ALPHA);
1017 img_laptop_right[3] = new Surface(datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1019 img_laptop_flat_left[0] = new Surface(
1020 datadir + "/images/shared/laptop-flat-left.png",
1023 img_laptop_flat_right[0] = new Surface(datadir +
1024 "/images/shared/laptop-flat-right.png",
1027 img_laptop_falling_left[0] = new Surface(datadir +
1028 "/images/shared/laptop-falling-left.png",
1031 img_laptop_falling_right[0] = new Surface(datadir +
1032 "/images/shared/laptop-falling-right.png",
1038 img_money_left[0] = new Surface(datadir +
1039 "/images/shared/bag-left-0.png",
1042 img_money_left[1] = new Surface(datadir +
1043 "/images/shared/bag-left-1.png",
1046 img_money_right[0] = new Surface(datadir +
1047 "/images/shared/bag-right-0.png",
1050 img_money_right[1] = new Surface(datadir +
1051 "/images/shared/bag-right-1.png",
1055 for(int i=0; i<4; ++i) {
1057 snprintf(num, 4, "%d", i);
1058 img_mrbomb_left[i] = new Surface(
1059 datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA);
1060 img_mrbomb_right[i] = new Surface(
1061 datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA);
1063 img_mrbomb_ticking_left[0] = new Surface(
1064 datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA);
1065 img_mrbomb_ticking_right[0] = new Surface(
1066 datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA);
1067 img_mrbomb_explosion[0] = new Surface(
1068 datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA);
1071 img_stalactite[0] = new Surface(
1072 datadir + "/images/shared/stalactite.png", USE_ALPHA);
1073 img_stalactite_broken[0] = new Surface(
1074 datadir + "/images/shared/stalactite-broken.png", USE_ALPHA);
1077 img_flame[0] = new Surface(
1078 datadir + "/images/shared/flame-0.png", USE_ALPHA);
1079 img_flame[1] = new Surface(
1080 datadir + "/images/shared/flame-1.png", USE_ALPHA);
1083 img_fish[0] = new Surface(
1084 datadir + "/images/shared/fish-left-0.png", USE_ALPHA);
1085 img_fish[1] = new Surface(
1086 datadir + "/images/shared/fish-left-1.png", USE_ALPHA);
1087 img_fish_down[0] = new Surface(
1088 datadir + "/images/shared/fish-down-0.png", USE_ALPHA);
1090 /* bouncing snowball */
1091 for(int i=0; i<6; ++i) {
1093 snprintf(num, 4, "%d", i);
1094 img_bouncingsnowball_left[i] = new Surface(
1095 datadir + "/images/shared/bouncingsnowball-left-" + num + ".png",
1097 img_bouncingsnowball_right[i] = new Surface(
1098 datadir + "/images/shared/bouncingsnowball-right-" + num + ".png",
1101 img_bouncingsnowball_squished[0] = new Surface(
1102 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1104 /* flying snowball */
1105 img_flyingsnowball[0] = new Surface(
1106 datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA);
1107 img_flyingsnowball[1] = new Surface(
1108 datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA);
1109 img_flyingsnowball_squished[0] = new Surface(
1110 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1113 for(int i = 0; i < 3; ++i) {
1115 snprintf(num, 4, "%d", i);
1116 img_spiky_left[i] = new Surface(
1117 datadir + "/images/shared/spiky-left-" + num + ".png",
1119 img_spiky_right[i] = new Surface(
1120 datadir + "/images/shared/spiky-right-" + num + ".png",
1125 img_snowball_left[0] = new Surface(datadir + "/images/shared/snowball-left-0.png", USE_ALPHA);
1126 img_snowball_left[1] = new Surface(datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1127 img_snowball_left[2] = new Surface(datadir + "/images/shared/snowball-left-2.png", USE_ALPHA);
1128 img_snowball_left[3] = new Surface(datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1130 img_snowball_right[0] = new Surface(datadir + "/images/shared/snowball-right-0.png", USE_ALPHA);
1131 img_snowball_right[1] = new Surface(datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1132 img_snowball_right[2] = new Surface(datadir + "/images/shared/snowball-right-2.png", USE_ALPHA);
1133 img_snowball_right[3] = new Surface(datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1135 img_snowball_squished_left[0] = new Surface(
1136 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1137 img_snowball_squished_right[0] = new Surface(
1138 datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA);
1141 void free_badguy_gfx()
1143 for (int i = 0; i < 4; i++)
1145 delete img_bsod_left[i];
1146 delete img_bsod_right[i];
1149 delete img_bsod_squished_left[0];
1150 delete img_bsod_squished_right[0];
1152 delete img_bsod_falling_left[0];
1153 delete img_bsod_falling_right[0];
1155 for (int i = 0; i < 4; i++)
1157 delete img_laptop_left[i];
1158 delete img_laptop_right[i];
1161 delete img_laptop_flat_left[0];
1162 delete img_laptop_flat_right[0];
1164 delete img_laptop_falling_left[0];
1165 delete img_laptop_falling_right[0];
1167 for (int i = 0; i < 2; i++)
1169 delete img_money_left[i];
1170 delete img_money_right[i];
1173 for(int i = 0; i < 4; i++) {
1174 delete img_mrbomb_left[i];
1175 delete img_mrbomb_right[i];
1178 delete img_mrbomb_ticking_left[0];
1179 delete img_mrbomb_ticking_right[0];
1180 delete img_mrbomb_explosion[0];
1182 delete img_stalactite[0];
1183 delete img_stalactite_broken[0];
1185 delete img_flame[0];
1186 delete img_flame[1];
1190 delete img_fish_down[0];
1192 for(int i=0; i<6; ++i) {
1193 delete img_bouncingsnowball_left[i];
1194 delete img_bouncingsnowball_right[i];
1196 delete img_bouncingsnowball_squished[0];
1198 delete img_flyingsnowball[0];
1199 delete img_flyingsnowball[1];
1200 delete img_flyingsnowball_squished[0];
1202 for(int i = 0; i<3; ++i) {
1203 delete img_spiky_left[i];
1204 delete img_spiky_right[i];
1206 for(int i = 0; i<4; ++i) {
1207 delete img_snowball_left[i];
1208 delete img_snowball_right[i];
1210 delete img_snowball_squished_left[0];
1211 delete img_snowball_squished_right[0];