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 for(std::vector<BadGuy>::iterator i = world.bad_guys.begin();
376 i != world.bad_guys.end(); ++i)
378 if( & (*i) == this) {
379 world.bad_guys.erase(i);
386 BadGuy::action_money()
388 static const float JUMPV = 6;
391 // jump when on ground
392 if(dying == DYING_NOT && issolid(base.x, base.y+32))
394 physic.set_velocity(physic.get_velocity_x(), JUMPV);
395 physic.enable_gravity(true);
396 set_texture(&img_money_left[1], &img_money_right[1], 1);
399 else if(mode == MONEY_JUMP)
401 set_texture(&img_money_left[0], &img_money_right[0], 1);
405 // set direction based on tux
406 if(tux.base.x > base.x)
412 physic.apply(base.x, base.y);
413 if(dying == DYING_NOT)
414 collision_swept_object_map(&old_base, &base);
418 BadGuy::action_mrbomb()
420 if (dying == DYING_NOT)
421 check_horizontal_bump(true);
425 physic.apply(base.x, base.y);
426 if (dying != DYING_FALLING)
427 collision_swept_object_map(&old_base,&base);
431 BadGuy::action_bomb()
433 static const int TICKINGTIME = 1000;
434 static const int EXPLODETIME = 1000;
440 timer_start(&timer, TICKINGTIME);
441 } else if(!timer_check(&timer)) {
442 if(mode == BOMB_TICKING) {
444 set_texture(img_mrbomb_explosion, img_mrbomb_explosion, 1);
445 dying = DYING_NOT; // now the bomb hurts
446 timer_start(&timer, EXPLODETIME);
447 } else if(mode == BOMB_EXPLODE) {
454 physic.apply(base.x, base.y);
455 collision_swept_object_map(&old_base,&base);
459 BadGuy::action_stalactite()
461 static const int SHAKETIME = 800;
462 static const int RANGE = 40;
465 // start shaking when tux is below the stalactite and at least 40 pixels
467 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
468 && tux.base.y + tux.base.height > base.y) {
469 timer_start(&timer, SHAKETIME);
470 mode = STALACTITE_SHAKING;
472 } if(mode == STALACTITE_SHAKING) {
473 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
474 if(!timer_check(&timer)) {
475 mode = STALACTITE_FALL;
477 } else if(mode == STALACTITE_FALL) {
479 /* Destroy if we collides with land */
480 if(issolid(base.x+base.width/2, base.y+base.height))
482 timer_start(&timer, 2000);
483 dying = DYING_SQUISHED;
485 set_texture(img_stalactite_broken, img_stalactite_broken, 1);
487 } else if(mode == FLAT) {
492 physic.apply(base.x, base.y);
494 if(dying == DYING_SQUISHED && !timer_check(&timer))
499 BadGuy::action_flame()
501 static const float radius = 100;
502 static const float speed = 0.02;
503 base.x = old_base.x + cos(base.ym) * radius;
504 base.y = old_base.y + sin(base.ym) * radius;
506 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
510 BadGuy::action_fish()
512 static const float JUMPV = 6;
513 static const int WAITTIME = 1000;
515 // go in wait mode when back in water
516 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
517 && physic.get_velocity_y() <= 0 && mode == NORMAL)
521 physic.set_velocity(0, 0);
522 physic.enable_gravity(false);
523 timer_start(&timer, WAITTIME);
525 else if(mode == FISH_WAIT && !timer_check(&timer))
528 set_texture(img_fish, img_fish, 2, 1.5);
529 animation_offset = global_frame_counter; // restart animation
531 physic.set_velocity(0, JUMPV);
532 physic.enable_gravity(true);
535 physic.apply(base.x, base.y);
536 if(dying == DYING_NOT)
537 collision_swept_object_map(&old_base, &base);
541 BadGuy::action_bouncingsnowball()
543 static const float JUMPV = 4.5;
547 // jump when on ground
548 if(dying == DYING_NOT && issolid(base.x, base.y+32))
550 physic.set_velocity(physic.get_velocity_x(), JUMPV);
551 physic.enable_gravity(true);
558 // check for right/left collisions
559 check_horizontal_bump();
561 physic.apply(base.x, base.y);
562 if(dying == DYING_NOT)
563 collision_swept_object_map(&old_base, &base);
565 // Handle dying timer:
566 if (dying == DYING_SQUISHED && !timer_check(&timer))
568 /* Remove it if time's up: */
575 BadGuy::action_flyingsnowball()
577 static const float FLYINGSPEED = 1;
578 static const int DIRCHANGETIME = 1000;
580 // go into flyup mode if none specified yet
581 if(dying == DYING_NOT && mode == NORMAL) {
583 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
584 timer_start(&timer, DIRCHANGETIME/2);
587 if(dying == DYING_NOT && !timer_check(&timer)) {
590 physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED);
591 } else if(mode == FLY_DOWN) {
593 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
595 timer_start(&timer, DIRCHANGETIME);
598 if(dying != DYING_NOT)
599 physic.enable_gravity(true);
601 physic.apply(base.x, base.y);
602 if(dying == DYING_NOT || dying == DYING_SQUISHED)
603 collision_swept_object_map(&old_base, &base);
605 // Handle dying timer:
606 if (dying == DYING_SQUISHED && !timer_check(&timer))
608 /* Remove it if time's up: */
615 BadGuy::action_spiky()
617 if (dying == DYING_NOT)
618 check_horizontal_bump();
622 // jump when we're about to fall
623 if (physic.get_velocity_y() == 0 &&
624 !issolid(base.x+base.width/2, base.y + base.height)) {
625 physic.enable_gravity(true);
626 physic.set_velocity(physic.get_velocity_x(), 2);
630 physic.apply(base.x, base.y);
631 if (dying != DYING_FALLING)
632 collision_swept_object_map(&old_base,&base);
636 BadGuy::action_snowball()
638 if (dying == DYING_NOT)
639 check_horizontal_bump();
643 physic.apply(base.x, base.y);
644 if (dying != DYING_FALLING)
645 collision_swept_object_map(&old_base,&base);
651 // Remove if it's far off the screen:
652 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
658 // BadGuy fall below the ground
659 if (base.y > screen->h) {
664 // Once it's on screen, it's activated!
665 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
705 case BAD_BOUNCINGSNOWBALL:
706 action_bouncingsnowball();
709 case BAD_FLYINGSNOWBALL:
710 action_flyingsnowball();
726 // Don't try to draw stuff that is outside of the screen
727 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
729 if(texture_left == 0 || texture_right == 0)
732 float global_frame = (float(global_frame_counter - animation_offset) / 10);
733 global_frame *= animation_speed;
734 size_t frame = size_t(global_frame) % animation_length;
735 texture_type* texture =
736 (dir == LEFT) ? &texture_left[frame] : &texture_right[frame];
737 texture_draw(texture, base.x - scroll_x, base.y);
741 BadGuy::set_texture(texture_type* left, texture_type* right,
742 int nanimlength, float nanimspeed)
745 if(base.width == 0 && base.height == 0) {
746 base.width = left->w;
747 base.height = left->h;
748 } else if(base.width != left->w || base.height != left->h) {
749 base.x -= (left->w - base.width) / 2;
750 base.y -= left->h - base.height;
751 base.width = left->w;
752 base.height = left->h;
756 base.width = base.height = 0;
759 animation_length = nanimlength;
760 animation_speed = nanimspeed;
761 animation_offset = 0;
763 texture_right = right;
769 if(kind == BAD_BSOD || kind == BAD_LAPTOP || kind == BAD_MRBOMB
770 || kind == BAD_BOUNCINGSNOWBALL) {
776 BadGuy::make_player_jump(Player* player)
778 player->physic.set_velocity(player->physic.get_velocity_x(), 2);
779 player->base.y = base.y - player->base.height - 2;
783 BadGuy::squish_me(Player* player)
785 make_player_jump(player);
787 world.add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
788 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
791 dying = DYING_SQUISHED;
792 timer_start(&timer, 2000);
793 physic.set_velocity(0, 0);
797 BadGuy::squish(Player* player)
799 if(kind == BAD_MRBOMB) {
800 // mrbomb transforms into a bomb now
801 world.add_bad_guy(base.x, base.y, BAD_BOMB);
803 make_player_jump(player);
804 world.add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
805 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
811 } else if(kind == BAD_BSOD) {
813 set_texture(img_bsod_squished_left, img_bsod_squished_right, 1);
814 physic.set_velocity(0, physic.get_velocity_y());
817 } else if (kind == BAD_LAPTOP) {
818 if (mode == NORMAL || mode == KICK)
821 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
823 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
824 physic.set_velocity(0, physic.get_velocity_y());
826 timer_start(&timer, 4000);
827 } else if (mode == FLAT) {
829 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
831 if (player->base.x < base.x + (base.width/2)) {
832 physic.set_velocity(5, physic.get_velocity_y());
835 physic.set_velocity(-5, physic.get_velocity_y());
840 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
843 make_player_jump(player);
845 world.add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
848 } else if(kind == BAD_FISH) {
849 make_player_jump(player);
851 world.add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
854 // simply remove the fish...
857 } else if(kind == BAD_BOUNCINGSNOWBALL) {
859 set_texture(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1);
861 } else if(kind == BAD_FLYINGSNOWBALL) {
863 set_texture(img_flyingsnowball_squished,img_flyingsnowball_squished,1);
865 } else if(kind == BAD_SNOWBALL) {
867 set_texture(img_snowball_squished_left, img_snowball_squished_right, 1);
875 if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
878 dying = DYING_FALLING;
879 if(kind == BAD_LAPTOP)
880 set_texture(img_laptop_falling_left, img_laptop_falling_right, 1);
881 else if(kind == BAD_BSOD)
882 set_texture(img_bsod_falling_left, img_bsod_falling_right, 1);
884 physic.enable_gravity(true);
885 physic.set_velocity(physic.get_velocity_x(), 0);
887 /* Gain some points: */
888 if (kind == BAD_BSOD)
889 world.add_score(base.x - scroll_x, base.y,
890 50 * score_multiplier);
892 world.add_score(base.x - scroll_x, base.y,
893 25 * score_multiplier);
895 /* Play death sound: */
896 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
900 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
902 BadGuy* pbad_c = NULL;
904 if(type == COLLISION_BUMP) {
908 if(type == COLLISION_SQUISH) {
909 Player* player = static_cast<Player*>(p_c_object);
921 pbad_c = (BadGuy*) p_c_object;
922 if(kind == BAD_LAPTOP && mode == KICK &&
923 pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB)
925 /* We're in kick mode, kill the other guy
926 and yourself(wuahaha) : */
934 //---------------------------------------------------------------------------
936 void load_badguy_gfx()
939 texture_load(&img_bsod_left[0], datadir +
940 "/images/shared/bsod-left-0.png",
943 texture_load(&img_bsod_left[1], datadir +
944 "/images/shared/bsod-left-1.png",
947 texture_load(&img_bsod_left[2], datadir +
948 "/images/shared/bsod-left-2.png",
951 texture_load(&img_bsod_left[3], datadir +
952 "/images/shared/bsod-left-3.png",
955 texture_load(&img_bsod_right[0], datadir +
956 "/images/shared/bsod-right-0.png",
959 texture_load(&img_bsod_right[1], datadir +
960 "/images/shared/bsod-right-1.png",
963 texture_load(&img_bsod_right[2], datadir +
964 "/images/shared/bsod-right-2.png",
967 texture_load(&img_bsod_right[3], datadir +
968 "/images/shared/bsod-right-3.png",
971 texture_load(&img_bsod_squished_left[0], datadir +
972 "/images/shared/bsod-squished-left.png",
975 texture_load(&img_bsod_squished_right[0], datadir +
976 "/images/shared/bsod-squished-right.png",
979 texture_load(&img_bsod_falling_left[0], datadir +
980 "/images/shared/bsod-falling-left.png",
983 texture_load(&img_bsod_falling_right[0], datadir +
984 "/images/shared/bsod-falling-right.png",
990 texture_load(&img_laptop_left[0], datadir + "/images/shared/mriceblock-left-0.png", USE_ALPHA);
991 texture_load(&img_laptop_left[1], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
992 texture_load(&img_laptop_left[2], datadir + "/images/shared/mriceblock-left-2.png", USE_ALPHA);
993 texture_load(&img_laptop_left[3], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
995 texture_load(&img_laptop_right[0], datadir + "/images/shared/mriceblock-right-0.png", USE_ALPHA);
996 texture_load(&img_laptop_right[1], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
997 texture_load(&img_laptop_right[2], datadir + "/images/shared/mriceblock-right-2.png", USE_ALPHA);
998 texture_load(&img_laptop_right[3], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1000 texture_load(&img_laptop_flat_left[0],
1001 datadir + "/images/shared/laptop-flat-left.png",
1004 texture_load(&img_laptop_flat_right[0], datadir +
1005 "/images/shared/laptop-flat-right.png",
1008 texture_load(&img_laptop_falling_left[0], datadir +
1009 "/images/shared/laptop-falling-left.png",
1012 texture_load(&img_laptop_falling_right[0], datadir +
1013 "/images/shared/laptop-falling-right.png",
1019 texture_load(&img_money_left[0], datadir +
1020 "/images/shared/bag-left-0.png",
1023 texture_load(&img_money_left[1], datadir +
1024 "/images/shared/bag-left-1.png",
1027 texture_load(&img_money_right[0], datadir +
1028 "/images/shared/bag-right-0.png",
1031 texture_load(&img_money_right[1], datadir +
1032 "/images/shared/bag-right-1.png",
1036 for(int i=0; i<4; ++i) {
1038 snprintf(num, 4, "%d", i);
1039 texture_load(&img_mrbomb_left[i],
1040 datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA);
1041 texture_load(&img_mrbomb_right[i],
1042 datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA);
1044 texture_load(&img_mrbomb_ticking_left[0],
1045 datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA);
1046 texture_load(&img_mrbomb_ticking_right[0],
1047 datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA);
1048 texture_load(&img_mrbomb_explosion[0],
1049 datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA);
1052 texture_load(&img_stalactite[0],
1053 datadir + "/images/shared/stalactite.png", USE_ALPHA);
1054 texture_load(&img_stalactite_broken[0],
1055 datadir + "/images/shared/stalactite-broken.png", USE_ALPHA);
1058 texture_load(&img_flame[0],
1059 datadir + "/images/shared/flame-0.png", USE_ALPHA);
1060 texture_load(&img_flame[1],
1061 datadir + "/images/shared/flame-1.png", USE_ALPHA);
1064 texture_load(&img_fish[0],
1065 datadir + "/images/shared/fish-left-0.png", USE_ALPHA);
1066 texture_load(&img_fish[1],
1067 datadir + "/images/shared/fish-left-1.png", USE_ALPHA);
1069 /* bouncing snowball */
1070 for(int i=0; i<6; ++i) {
1072 snprintf(num, 4, "%d", i);
1073 texture_load(&img_bouncingsnowball_left[i],
1074 datadir + "/images/shared/bouncingsnowball-left-" + num + ".png",
1076 texture_load(&img_bouncingsnowball_right[i],
1077 datadir + "/images/shared/bouncingsnowball-right-" + num + ".png",
1080 texture_load(&img_bouncingsnowball_squished[0],
1081 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1083 /* flying snowball */
1084 texture_load(&img_flyingsnowball[0],
1085 datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA);
1086 texture_load(&img_flyingsnowball[1],
1087 datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA);
1088 texture_load(&img_flyingsnowball_squished[0],
1089 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1092 for(int i = 0; i < 3; ++i) {
1094 snprintf(num, 4, "%d", i);
1095 texture_load(&img_spiky_left[i],
1096 datadir + "/images/shared/spiky-left-" + num + ".png",
1098 texture_load(&img_spiky_right[i],
1099 datadir + "/images/shared/spiky-right-" + num + ".png",
1104 texture_load(&img_snowball_left[0], datadir + "/images/shared/snowball-left-0.png", USE_ALPHA);
1105 texture_load(&img_snowball_left[1], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1106 texture_load(&img_snowball_left[2], datadir + "/images/shared/snowball-left-2.png", USE_ALPHA);
1107 texture_load(&img_snowball_left[3], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1109 texture_load(&img_snowball_right[0], datadir + "/images/shared/snowball-right-0.png", USE_ALPHA);
1110 texture_load(&img_snowball_right[1], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1111 texture_load(&img_snowball_right[2], datadir + "/images/shared/snowball-right-2.png", USE_ALPHA);
1112 texture_load(&img_snowball_right[3], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1114 texture_load(&img_snowball_squished_left[0],
1115 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1116 texture_load(&img_snowball_squished_right[0],
1117 datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA);
1120 void free_badguy_gfx()
1122 for (int i = 0; i < 4; i++)
1124 texture_free(&img_bsod_left[i]);
1125 texture_free(&img_bsod_right[i]);
1128 texture_free(&img_bsod_squished_left[0]);
1129 texture_free(&img_bsod_squished_right[0]);
1131 texture_free(&img_bsod_falling_left[0]);
1132 texture_free(&img_bsod_falling_right[0]);
1134 for (int i = 0; i < 4; i++)
1136 texture_free(&img_laptop_left[i]);
1137 texture_free(&img_laptop_right[i]);
1140 texture_free(&img_laptop_flat_left[0]);
1141 texture_free(&img_laptop_flat_right[0]);
1143 texture_free(&img_laptop_falling_left[0]);
1144 texture_free(&img_laptop_falling_right[0]);
1146 for (int i = 0; i < 2; i++)
1148 texture_free(&img_money_left[i]);
1149 texture_free(&img_money_right[i]);
1152 for(int i = 0; i < 4; i++) {
1153 texture_free(&img_mrbomb_left[i]);
1154 texture_free(&img_mrbomb_right[i]);
1157 texture_free(&img_mrbomb_ticking_left[0]);
1158 texture_free(&img_mrbomb_ticking_right[0]);
1159 texture_free(&img_mrbomb_explosion[0]);
1161 texture_free(&img_stalactite[0]);
1162 texture_free(&img_stalactite_broken[0]);
1164 texture_free(&img_flame[0]);
1165 texture_free(&img_flame[1]);
1167 texture_free(&img_fish[0]);
1168 texture_free(&img_fish[1]);
1170 for(int i=0; i<6; ++i) {
1171 texture_free(&img_bouncingsnowball_left[i]);
1172 texture_free(&img_bouncingsnowball_right[i]);
1174 texture_free(&img_bouncingsnowball_squished[0]);
1176 texture_free(&img_flyingsnowball[0]);
1177 texture_free(&img_flyingsnowball[1]);
1178 texture_free(&img_flyingsnowball_squished[0]);
1180 for(int i = 0; i<3; ++i) {
1181 texture_free(&img_spiky_left[i]);
1182 texture_free(&img_spiky_right[i]);
1184 for(int i = 0; i<4; ++i) {
1185 texture_free(&img_snowball_left[i]);
1186 texture_free(&img_snowball_right[i]);
1188 texture_free(&img_snowball_squished_left[0]);
1189 texture_free(&img_snowball_squished_right[0]);