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
21 texture_type img_bsod_squished_left[1];
22 texture_type img_bsod_squished_right[1];
23 texture_type img_bsod_falling_left[1];
24 texture_type img_bsod_falling_right[1];
25 texture_type img_laptop_flat_left[1];
26 texture_type img_laptop_flat_right[1];
27 texture_type img_laptop_falling_left[1];
28 texture_type img_laptop_falling_right[1];
29 texture_type img_bsod_left[4];
30 texture_type img_bsod_right[4];
31 texture_type img_laptop_left[4];
32 texture_type img_laptop_right[4];
33 texture_type img_money_left[2];
34 texture_type img_money_right[2];
35 texture_type img_mrbomb_left[4];
36 texture_type img_mrbomb_right[4];
37 texture_type img_mrbomb_ticking_left[1];
38 texture_type img_mrbomb_ticking_right[1];
39 texture_type img_mrbomb_explosion[1];
40 texture_type img_stalactite[1];
41 texture_type img_stalactite_broken[1];
42 texture_type img_flame[2];
43 texture_type img_fish[2];
44 texture_type img_bouncingsnowball_left[6];
45 texture_type img_bouncingsnowball_right[6];
46 texture_type img_bouncingsnowball_squished[1];
47 texture_type img_flyingsnowball[2];
48 texture_type img_flyingsnowball_squished[1];
49 texture_type img_spiky_left[3];
50 texture_type img_spiky_right[3];
51 texture_type img_snowball_left[4];
52 texture_type img_snowball_right[4];
53 texture_type img_snowball_squished_left[1];
54 texture_type img_snowball_squished_right[1];
56 BadGuyKind badguykind_from_string(const std::string& str)
60 else if (str == "laptop" || str == "mriceblock")
62 else if (str == "bsod")
64 else if (str == "mrbomb")
66 else if (str == "stalactite")
67 return BAD_STALACTITE;
68 else if (str == "flame")
70 else if (str == "fish")
72 else if (str == "bouncingsnowball")
73 return BAD_BOUNCINGSNOWBALL;
74 else if (str == "flyingsnowball")
75 return BAD_FLYINGSNOWBALL;
76 else if (str == "spiky")
78 else if (str == "snowball")
82 printf("Couldn't convert badguy: '%s'\n", str.c_str());
87 std::string badguykind_to_string(BadGuyKind kind)
112 case BAD_BOUNCINGSNOWBALL:
113 return "bouncingsnowball";
115 case BAD_FLYINGSNOWBALL:
116 return "flyingsnowball";
130 BadGuy::init(float x, float y, BadGuyKind kind_)
146 animation_length = 1;
147 animation_offset = 0;
148 texture_left = texture_right = 0;
150 timer_init(&timer, true);
152 if(kind == BAD_BSOD) {
153 physic.set_velocity(-1.3, 0);
154 set_texture(img_bsod_left, img_bsod_right, 4);
155 } else if(kind == BAD_MRBOMB) {
156 physic.set_velocity(-1.3, 0);
157 set_texture(img_mrbomb_left, img_mrbomb_right, 4);
158 } else if (kind == BAD_LAPTOP) {
159 physic.set_velocity(-1.3, 0);
160 set_texture(img_laptop_left, img_laptop_right, 4, 5);
161 } else if(kind == BAD_MONEY) {
162 set_texture(img_money_left, img_money_right, 1);
163 } else if(kind == BAD_BOMB) {
164 set_texture(img_mrbomb_ticking_left, img_mrbomb_ticking_right, 1);
165 // hack so that the bomb doesn't hurt until it expldes...
166 dying = DYING_SQUISHED;
167 } else if(kind == BAD_FLAME) {
168 base.ym = 0; // we misuse base.ym as angle for the flame
169 physic.enable_gravity(false);
170 set_texture(img_flame, img_flame, 2, 0.5);
171 } else if(kind == BAD_BOUNCINGSNOWBALL) {
172 physic.set_velocity(-1.3, 0);
173 set_texture(img_bouncingsnowball_left, img_bouncingsnowball_right, 6);
174 } else if(kind == BAD_STALACTITE) {
175 physic.enable_gravity(false);
176 set_texture(img_stalactite, img_stalactite, 1);
177 } else if(kind == BAD_FISH) {
178 set_texture(img_fish, img_fish, 2, 1);
179 physic.enable_gravity(true);
180 } else if(kind == BAD_FLYINGSNOWBALL) {
181 set_texture(img_flyingsnowball, img_flyingsnowball, 2, 5);
182 physic.enable_gravity(false);
183 } else if(kind == BAD_SPIKY) {
184 physic.set_velocity(-1.3, 0);
185 set_texture(img_spiky_left, img_spiky_right, 3);
186 } else if(kind == BAD_SNOWBALL) {
187 physic.set_velocity(-1.3, 0);
188 set_texture(img_snowball_left, img_snowball_right, 4, 5);
191 // if we're in a solid tile at start correct that now
192 if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(&base)) {
193 printf("Warning: badguy started in wall!.\n");
194 while(collision_object_map(&base))
200 BadGuy::action_bsod()
202 static const float BSODJUMP = 2;
204 if (dying == DYING_NOT)
205 check_horizontal_bump();
209 // jump when we're about to fall
210 if (physic.get_velocity_y() == 0 &&
211 !issolid(base.x+base.width/2, base.y + base.height)) {
212 physic.enable_gravity(true);
213 physic.set_velocity(physic.get_velocity_x(), BSODJUMP);
216 // Handle dying timer:
217 if (dying == DYING_SQUISHED && !timer_check(&timer))
219 /* Remove it if time's up: */
225 physic.apply(base.x, base.y);
226 if(dying != DYING_FALLING)
227 collision_swept_object_map(&old_base, &base);
231 BadGuy::action_laptop()
235 /* Move left/right: */
236 if (mode == NORMAL || mode == KICK)
239 physic.apply(base.x, base.y);
240 if (dying != DYING_FALLING)
241 collision_swept_object_map(&old_base,&base);
243 else if (mode == HELD)
244 { /* FIXME: The pbad object shouldn't know about pplayer objects. */
245 /* If we're holding the laptop */
249 base.x = tux.base.x + 16;
250 base.y = tux.base.y + tux.base.height/1.5 - base.height;
252 else /* facing left */
254 base.x = tux.base.x - 16;
255 base.y = tux.base.y + tux.base.height/1.5 - base.height;
257 if(collision_object_map(&base))
260 base.y = tux.base.y + tux.base.height/1.5 - base.height;
263 if(tux.input.fire != DOWN) /* SHOOT! */
271 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
272 physic.set_velocity((dir == LEFT) ? -8 : 8, -8);
273 play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
280 check_horizontal_bump();
281 if(mode == KICK && changed != dir)
283 /* handle stereo sound (number 10 should be tweaked...)*/
284 if (base.x < scroll_x + screen->w/2 - 10)
285 play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
286 else if (base.x > scroll_x + screen->w/2 + 10)
287 play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
289 play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
293 /* Handle mode timer: */
296 if(!timer_check(&timer))
299 set_texture(img_laptop_left, img_laptop_right, 4, 5);
300 physic.set_velocity( (dir == LEFT) ? -1.3 : 1.3, 0);
306 BadGuy::check_horizontal_bump(bool checkcliff)
308 float halfheight = base.height / 2;
309 if (dir == LEFT && issolid( base.x, (int) base.y + halfheight))
312 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
315 if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight))
318 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
322 // don't check for cliffs when we're falling
325 if(!issolid(base.x + base.width/2, base.y + base.height))
328 if(dir == LEFT && !issolid(base.x, (int) base.y + base.height + halfheight))
331 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
334 if(dir == RIGHT && !issolid(base.x + base.width,
335 (int) base.y + base.height + halfheight))
338 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
346 /* Fall if we get off the ground: */
347 if (dying != DYING_FALLING)
349 if (!issolid(base.x+base.width/2, base.y + base.height))
351 // not solid below us? enable gravity
352 physic.enable_gravity(true);
357 if (physic.get_velocity_y() < 0)
359 base.y = int((base.y + base.height)/32) * 32 - base.height;
360 physic.set_velocity(physic.get_velocity_x(), 0);
362 // no gravity anymore please
363 physic.enable_gravity(false);
368 physic.enable_gravity(true);
375 std::vector<BadGuy>::iterator i;
376 for(i = bad_guys.begin(); i != bad_guys.end(); ++i) {
377 if( & (*i) == this) {
385 BadGuy::action_money()
387 static const float JUMPV = 6;
390 // jump when on ground
391 if(dying == DYING_NOT && issolid(base.x, base.y+32))
393 physic.set_velocity(physic.get_velocity_x(), JUMPV);
394 physic.enable_gravity(true);
395 set_texture(&img_money_left[1], &img_money_right[1], 1);
398 else if(mode == MONEY_JUMP)
400 set_texture(&img_money_left[0], &img_money_right[0], 1);
404 // set direction based on tux
405 if(tux.base.x > base.x)
411 physic.apply(base.x, base.y);
412 if(dying == DYING_NOT)
413 collision_swept_object_map(&old_base, &base);
417 BadGuy::action_mrbomb()
419 if (dying == DYING_NOT)
420 check_horizontal_bump(true);
424 physic.apply(base.x, base.y);
425 if (dying != DYING_FALLING)
426 collision_swept_object_map(&old_base,&base);
430 BadGuy::action_bomb()
432 static const int TICKINGTIME = 1000;
433 static const int EXPLODETIME = 1000;
439 timer_start(&timer, TICKINGTIME);
440 } else if(!timer_check(&timer)) {
441 if(mode == BOMB_TICKING) {
443 set_texture(img_mrbomb_explosion, img_mrbomb_explosion, 1);
444 dying = DYING_NOT; // now the bomb hurts
445 timer_start(&timer, EXPLODETIME);
446 } else if(mode == BOMB_EXPLODE) {
453 physic.apply(base.x, base.y);
454 collision_swept_object_map(&old_base,&base);
458 BadGuy::action_stalactite()
460 static const int SHAKETIME = 800;
461 static const int RANGE = 40;
464 // start shaking when tux is below the stalactite and at least 40 pixels
466 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
467 && tux.base.y + tux.base.height > base.y) {
468 timer_start(&timer, SHAKETIME);
469 mode = STALACTITE_SHAKING;
471 } if(mode == STALACTITE_SHAKING) {
472 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
473 if(!timer_check(&timer)) {
474 mode = STALACTITE_FALL;
476 } else if(mode == STALACTITE_FALL) {
478 /* Destroy if we collides with land */
479 if(issolid(base.x+base.width/2, base.y+base.height))
481 timer_start(&timer, 2000);
482 dying = DYING_SQUISHED;
484 set_texture(img_stalactite_broken, img_stalactite_broken, 1);
486 } else if(mode == FLAT) {
491 physic.apply(base.x, base.y);
493 if(dying == DYING_SQUISHED && !timer_check(&timer))
498 BadGuy::action_flame()
500 static const float radius = 100;
501 static const float speed = 0.02;
502 base.x = old_base.x + cos(base.ym) * radius;
503 base.y = old_base.y + sin(base.ym) * radius;
505 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
509 BadGuy::action_fish()
511 static const float JUMPV = 6;
512 static const int WAITTIME = 1000;
514 // go in wait mode when back in water
515 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
516 && physic.get_velocity_y() <= 0 && mode == NORMAL)
520 physic.set_velocity(0, 0);
521 physic.enable_gravity(false);
522 timer_start(&timer, WAITTIME);
524 else if(mode == FISH_WAIT && !timer_check(&timer))
527 set_texture(img_fish, img_fish, 2, 1.5);
528 animation_offset = global_frame_counter; // restart animation
530 physic.set_velocity(0, JUMPV);
531 physic.enable_gravity(true);
534 physic.apply(base.x, base.y);
535 if(dying == DYING_NOT)
536 collision_swept_object_map(&old_base, &base);
540 BadGuy::action_bouncingsnowball()
542 static const float JUMPV = 4.5;
546 // jump when on ground
547 if(dying == DYING_NOT && issolid(base.x, base.y+32))
549 physic.set_velocity(physic.get_velocity_x(), JUMPV);
550 physic.enable_gravity(true);
557 // check for right/left collisions
558 check_horizontal_bump();
560 physic.apply(base.x, base.y);
561 if(dying == DYING_NOT)
562 collision_swept_object_map(&old_base, &base);
564 // Handle dying timer:
565 if (dying == DYING_SQUISHED && !timer_check(&timer))
567 /* Remove it if time's up: */
574 BadGuy::action_flyingsnowball()
576 static const float FLYINGSPEED = 1;
577 static const int DIRCHANGETIME = 1000;
579 // go into flyup mode if none specified yet
580 if(dying == DYING_NOT && mode == NORMAL) {
582 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
583 timer_start(&timer, DIRCHANGETIME/2);
586 if(dying == DYING_NOT && !timer_check(&timer)) {
589 physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED);
590 } else if(mode == FLY_DOWN) {
592 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
594 timer_start(&timer, DIRCHANGETIME);
597 if(dying != DYING_NOT)
598 physic.enable_gravity(true);
600 physic.apply(base.x, base.y);
601 if(dying == DYING_NOT || dying == DYING_SQUISHED)
602 collision_swept_object_map(&old_base, &base);
604 // Handle dying timer:
605 if (dying == DYING_SQUISHED && !timer_check(&timer))
607 /* Remove it if time's up: */
614 BadGuy::action_spiky()
616 if (dying == DYING_NOT)
617 check_horizontal_bump();
621 // jump when we're about to fall
622 if (physic.get_velocity_y() == 0 &&
623 !issolid(base.x+base.width/2, base.y + base.height)) {
624 physic.enable_gravity(true);
625 physic.set_velocity(physic.get_velocity_x(), 2);
629 physic.apply(base.x, base.y);
630 if (dying != DYING_FALLING)
631 collision_swept_object_map(&old_base,&base);
635 BadGuy::action_snowball()
637 if (dying == DYING_NOT)
638 check_horizontal_bump();
642 physic.apply(base.x, base.y);
643 if (dying != DYING_FALLING)
644 collision_swept_object_map(&old_base,&base);
650 // Remove if it's far off the screen:
651 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
657 // BadGuy fall below the ground
658 if (base.y > screen->h) {
663 // Once it's on screen, it's activated!
664 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
704 case BAD_BOUNCINGSNOWBALL:
705 action_bouncingsnowball();
708 case BAD_FLYINGSNOWBALL:
709 action_flyingsnowball();
725 // Don't try to draw stuff that is outside of the screen
726 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
728 if(texture_left == 0 || texture_right == 0)
731 float global_frame = (float(global_frame_counter - animation_offset) / 10);
732 global_frame *= animation_speed;
733 size_t frame = size_t(global_frame) % animation_length;
734 texture_type* texture =
735 (dir == LEFT) ? &texture_left[frame] : &texture_right[frame];
736 texture_draw(texture, base.x - scroll_x, base.y);
740 BadGuy::set_texture(texture_type* left, texture_type* right,
741 int nanimlength, float nanimspeed)
744 if(base.width == 0 && base.height == 0) {
745 base.width = left->w;
746 base.height = left->h;
747 } else if(base.width != left->w || base.height != left->h) {
748 base.x -= (left->w - base.width) / 2;
749 base.y -= left->h - base.height;
750 base.width = left->w;
751 base.height = left->h;
755 base.width = base.height = 0;
758 animation_length = nanimlength;
759 animation_speed = nanimspeed;
760 animation_offset = 0;
762 texture_right = right;
768 if(kind == BAD_BSOD || kind == BAD_LAPTOP || kind == BAD_MRBOMB
769 || kind == BAD_BOUNCINGSNOWBALL) {
775 BadGuy::make_player_jump(Player* player)
777 player->physic.set_velocity(player->physic.get_velocity_x(), 2);
778 player->base.y = base.y - player->base.height - 2;
782 BadGuy::squish_me(Player* player)
784 make_player_jump(player);
786 add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
787 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
790 dying = DYING_SQUISHED;
791 timer_start(&timer, 2000);
792 physic.set_velocity(0, 0);
796 BadGuy::squish(Player* player)
798 if(kind == BAD_MRBOMB) {
799 // mrbomb transforms into a bomb now
800 add_bad_guy(base.x, base.y, BAD_BOMB);
802 make_player_jump(player);
803 add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
804 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
810 } else if(kind == BAD_BSOD) {
812 set_texture(img_bsod_squished_left, img_bsod_squished_right, 1);
813 physic.set_velocity(0, physic.get_velocity_y());
816 } else if (kind == BAD_LAPTOP) {
817 if (mode == NORMAL || mode == KICK)
820 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
822 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
823 physic.set_velocity(0, physic.get_velocity_y());
825 timer_start(&timer, 4000);
826 } else if (mode == FLAT) {
828 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
830 if (player->base.x < base.x + (base.width/2)) {
831 physic.set_velocity(5, physic.get_velocity_y());
834 physic.set_velocity(-5, physic.get_velocity_y());
839 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
842 make_player_jump(player);
844 add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
847 } else if(kind == BAD_FISH) {
848 make_player_jump(player);
850 add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
853 // simply remove the fish...
856 } else if(kind == BAD_BOUNCINGSNOWBALL) {
858 set_texture(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1);
860 } else if(kind == BAD_FLYINGSNOWBALL) {
862 set_texture(img_flyingsnowball_squished,img_flyingsnowball_squished,1);
864 } else if(kind == BAD_SNOWBALL) {
866 set_texture(img_snowball_squished_left, img_snowball_squished_right, 1);
874 if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
877 dying = DYING_FALLING;
878 if(kind == BAD_LAPTOP)
879 set_texture(img_laptop_falling_left, img_laptop_falling_right, 1);
880 else if(kind == BAD_BSOD)
881 set_texture(img_bsod_falling_left, img_bsod_falling_right, 1);
883 physic.enable_gravity(true);
884 physic.set_velocity(physic.get_velocity_x(), 0);
886 /* Gain some points: */
887 if (kind == BAD_BSOD)
888 add_score(base.x - scroll_x, base.y,
889 50 * score_multiplier);
891 add_score(base.x - scroll_x, base.y,
892 25 * score_multiplier);
894 /* Play death sound: */
895 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
899 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
901 BadGuy* pbad_c = NULL;
903 if(type == COLLISION_BUMP) {
907 if(type == COLLISION_SQUISH) {
908 Player* player = static_cast<Player*>(p_c_object);
920 pbad_c = (BadGuy*) p_c_object;
921 if(kind == BAD_LAPTOP && mode == KICK &&
922 pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB)
924 /* We're in kick mode, kill the other guy
925 and yourself(wuahaha) : */
933 //---------------------------------------------------------------------------
935 void load_badguy_gfx()
938 texture_load(&img_bsod_left[0], datadir +
939 "/images/shared/bsod-left-0.png",
942 texture_load(&img_bsod_left[1], datadir +
943 "/images/shared/bsod-left-1.png",
946 texture_load(&img_bsod_left[2], datadir +
947 "/images/shared/bsod-left-2.png",
950 texture_load(&img_bsod_left[3], datadir +
951 "/images/shared/bsod-left-3.png",
954 texture_load(&img_bsod_right[0], datadir +
955 "/images/shared/bsod-right-0.png",
958 texture_load(&img_bsod_right[1], datadir +
959 "/images/shared/bsod-right-1.png",
962 texture_load(&img_bsod_right[2], datadir +
963 "/images/shared/bsod-right-2.png",
966 texture_load(&img_bsod_right[3], datadir +
967 "/images/shared/bsod-right-3.png",
970 texture_load(&img_bsod_squished_left[0], datadir +
971 "/images/shared/bsod-squished-left.png",
974 texture_load(&img_bsod_squished_right[0], datadir +
975 "/images/shared/bsod-squished-right.png",
978 texture_load(&img_bsod_falling_left[0], datadir +
979 "/images/shared/bsod-falling-left.png",
982 texture_load(&img_bsod_falling_right[0], datadir +
983 "/images/shared/bsod-falling-right.png",
989 texture_load(&img_laptop_left[0], datadir + "/images/shared/mriceblock-left-0.png", USE_ALPHA);
990 texture_load(&img_laptop_left[1], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
991 texture_load(&img_laptop_left[2], datadir + "/images/shared/mriceblock-left-2.png", USE_ALPHA);
992 texture_load(&img_laptop_left[3], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
994 texture_load(&img_laptop_right[0], datadir + "/images/shared/mriceblock-right-0.png", USE_ALPHA);
995 texture_load(&img_laptop_right[1], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
996 texture_load(&img_laptop_right[2], datadir + "/images/shared/mriceblock-right-2.png", USE_ALPHA);
997 texture_load(&img_laptop_right[3], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
999 texture_load(&img_laptop_flat_left[0],
1000 datadir + "/images/shared/laptop-flat-left.png",
1003 texture_load(&img_laptop_flat_right[0], datadir +
1004 "/images/shared/laptop-flat-right.png",
1007 texture_load(&img_laptop_falling_left[0], datadir +
1008 "/images/shared/laptop-falling-left.png",
1011 texture_load(&img_laptop_falling_right[0], datadir +
1012 "/images/shared/laptop-falling-right.png",
1018 texture_load(&img_money_left[0], datadir +
1019 "/images/shared/bag-left-0.png",
1022 texture_load(&img_money_left[1], datadir +
1023 "/images/shared/bag-left-1.png",
1026 texture_load(&img_money_right[0], datadir +
1027 "/images/shared/bag-right-0.png",
1030 texture_load(&img_money_right[1], datadir +
1031 "/images/shared/bag-right-1.png",
1035 for(int i=0; i<4; ++i) {
1037 snprintf(num, 4, "%d", i);
1038 texture_load(&img_mrbomb_left[i],
1039 datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA);
1040 texture_load(&img_mrbomb_right[i],
1041 datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA);
1043 texture_load(&img_mrbomb_ticking_left[0],
1044 datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA);
1045 texture_load(&img_mrbomb_ticking_right[0],
1046 datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA);
1047 texture_load(&img_mrbomb_explosion[0],
1048 datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA);
1051 texture_load(&img_stalactite[0],
1052 datadir + "/images/shared/stalactite.png", USE_ALPHA);
1053 texture_load(&img_stalactite_broken[0],
1054 datadir + "/images/shared/stalactite-broken.png", USE_ALPHA);
1057 texture_load(&img_flame[0],
1058 datadir + "/images/shared/flame-0.png", USE_ALPHA);
1059 texture_load(&img_flame[1],
1060 datadir + "/images/shared/flame-1.png", USE_ALPHA);
1063 texture_load(&img_fish[0],
1064 datadir + "/images/shared/fish-left-0.png", USE_ALPHA);
1065 texture_load(&img_fish[1],
1066 datadir + "/images/shared/fish-left-1.png", USE_ALPHA);
1068 /* bouncing snowball */
1069 for(int i=0; i<6; ++i) {
1071 snprintf(num, 4, "%d", i);
1072 texture_load(&img_bouncingsnowball_left[i],
1073 datadir + "/images/shared/bouncingsnowball-left-" + num + ".png",
1075 texture_load(&img_bouncingsnowball_right[i],
1076 datadir + "/images/shared/bouncingsnowball-right-" + num + ".png",
1079 texture_load(&img_bouncingsnowball_squished[0],
1080 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1082 /* flying snowball */
1083 texture_load(&img_flyingsnowball[0],
1084 datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA);
1085 texture_load(&img_flyingsnowball[1],
1086 datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA);
1087 texture_load(&img_flyingsnowball_squished[0],
1088 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1091 for(int i = 0; i < 3; ++i) {
1093 snprintf(num, 4, "%d", i);
1094 texture_load(&img_spiky_left[i],
1095 datadir + "/images/shared/spiky-left-" + num + ".png",
1097 texture_load(&img_spiky_right[i],
1098 datadir + "/images/shared/spiky-right-" + num + ".png",
1103 texture_load(&img_snowball_left[0], datadir + "/images/shared/snowball-left-0.png", USE_ALPHA);
1104 texture_load(&img_snowball_left[1], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1105 texture_load(&img_snowball_left[2], datadir + "/images/shared/snowball-left-2.png", USE_ALPHA);
1106 texture_load(&img_snowball_left[3], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1108 texture_load(&img_snowball_right[0], datadir + "/images/shared/snowball-right-0.png", USE_ALPHA);
1109 texture_load(&img_snowball_right[1], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1110 texture_load(&img_snowball_right[2], datadir + "/images/shared/snowball-right-2.png", USE_ALPHA);
1111 texture_load(&img_snowball_right[3], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1113 texture_load(&img_snowball_squished_left[0],
1114 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1115 texture_load(&img_snowball_squished_right[0],
1116 datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA);
1119 void free_badguy_gfx()
1121 for (int i = 0; i < 4; i++)
1123 texture_free(&img_bsod_left[i]);
1124 texture_free(&img_bsod_right[i]);
1127 texture_free(&img_bsod_squished_left[0]);
1128 texture_free(&img_bsod_squished_right[0]);
1130 texture_free(&img_bsod_falling_left[0]);
1131 texture_free(&img_bsod_falling_right[0]);
1133 for (int i = 0; i < 4; i++)
1135 texture_free(&img_laptop_left[i]);
1136 texture_free(&img_laptop_right[i]);
1139 texture_free(&img_laptop_flat_left[0]);
1140 texture_free(&img_laptop_flat_right[0]);
1142 texture_free(&img_laptop_falling_left[0]);
1143 texture_free(&img_laptop_falling_right[0]);
1145 for (int i = 0; i < 2; i++)
1147 texture_free(&img_money_left[i]);
1148 texture_free(&img_money_right[i]);
1151 for(int i = 0; i < 4; i++) {
1152 texture_free(&img_mrbomb_left[i]);
1153 texture_free(&img_mrbomb_right[i]);
1156 texture_free(&img_mrbomb_ticking_left[0]);
1157 texture_free(&img_mrbomb_ticking_right[0]);
1158 texture_free(&img_mrbomb_explosion[0]);
1160 texture_free(&img_stalactite[0]);
1161 texture_free(&img_stalactite_broken[0]);
1163 texture_free(&img_flame[0]);
1164 texture_free(&img_flame[1]);
1166 texture_free(&img_fish[0]);
1167 texture_free(&img_fish[1]);
1169 for(int i=0; i<6; ++i) {
1170 texture_free(&img_bouncingsnowball_left[i]);
1171 texture_free(&img_bouncingsnowball_right[i]);
1173 texture_free(&img_bouncingsnowball_squished[0]);
1175 texture_free(&img_flyingsnowball[0]);
1176 texture_free(&img_flyingsnowball[1]);
1177 texture_free(&img_flyingsnowball_squished[0]);
1179 for(int i = 0; i<3; ++i) {
1180 texture_free(&img_spiky_left[i]);
1181 texture_free(&img_spiky_right[i]);
1183 for(int i = 0; i<4; ++i) {
1184 texture_free(&img_snowball_left[i]);
1185 texture_free(&img_snowball_right[i]);
1187 texture_free(&img_snowball_squished_left[0]);
1188 texture_free(&img_snowball_squished_right[0]);