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 texture_type img_bsod_squished_left[1];
23 texture_type img_bsod_squished_right[1];
24 texture_type img_bsod_falling_left[1];
25 texture_type img_bsod_falling_right[1];
26 texture_type img_laptop_flat_left[1];
27 texture_type img_laptop_flat_right[1];
28 texture_type img_laptop_falling_left[1];
29 texture_type img_laptop_falling_right[1];
30 texture_type img_bsod_left[4];
31 texture_type img_bsod_right[4];
32 texture_type img_laptop_left[4];
33 texture_type img_laptop_right[4];
34 texture_type img_money_left[2];
35 texture_type img_money_right[2];
36 texture_type img_mrbomb_left[4];
37 texture_type img_mrbomb_right[4];
38 texture_type img_mrbomb_ticking_left[1];
39 texture_type img_mrbomb_ticking_right[1];
40 texture_type img_mrbomb_explosion[1];
41 texture_type img_stalactite[1];
42 texture_type img_stalactite_broken[1];
43 texture_type img_flame[2];
44 texture_type img_fish[2];
45 texture_type img_bouncingsnowball_left[6];
46 texture_type img_bouncingsnowball_right[6];
47 texture_type img_bouncingsnowball_squished[1];
48 texture_type img_flyingsnowball[2];
49 texture_type img_flyingsnowball_squished[1];
50 texture_type img_spiky_left[3];
51 texture_type img_spiky_right[3];
52 texture_type img_snowball_left[4];
53 texture_type img_snowball_right[4];
54 texture_type img_snowball_squished_left[1];
55 texture_type img_snowball_squished_right[1];
57 BadGuyKind badguykind_from_string(const std::string& str)
61 else if (str == "laptop" || str == "mriceblock")
63 else if (str == "bsod")
65 else if (str == "mrbomb")
67 else if (str == "stalactite")
68 return BAD_STALACTITE;
69 else if (str == "flame")
71 else if (str == "fish")
73 else if (str == "bouncingsnowball")
74 return BAD_BOUNCINGSNOWBALL;
75 else if (str == "flyingsnowball")
76 return BAD_FLYINGSNOWBALL;
77 else if (str == "spiky")
79 else if (str == "snowball")
83 printf("Couldn't convert badguy: '%s'\n", str.c_str());
88 std::string badguykind_to_string(BadGuyKind kind)
113 case BAD_BOUNCINGSNOWBALL:
114 return "bouncingsnowball";
116 case BAD_FLYINGSNOWBALL:
117 return "flyingsnowball";
131 BadGuy::init(float x, float y, BadGuyKind kind_)
147 animation_length = 1;
148 animation_offset = 0;
149 texture_left = texture_right = 0;
153 if(kind == BAD_BSOD) {
154 physic.set_velocity(-1.3, 0);
155 set_texture(img_bsod_left, img_bsod_right, 4);
156 } else if(kind == BAD_MRBOMB) {
157 physic.set_velocity(-1.3, 0);
158 set_texture(img_mrbomb_left, img_mrbomb_right, 4);
159 } else if (kind == BAD_LAPTOP) {
160 physic.set_velocity(-1.3, 0);
161 set_texture(img_laptop_left, img_laptop_right, 4, 5);
162 } else if(kind == BAD_MONEY) {
163 set_texture(img_money_left, img_money_right, 1);
164 } else if(kind == BAD_BOMB) {
165 set_texture(img_mrbomb_ticking_left, img_mrbomb_ticking_right, 1);
166 // hack so that the bomb doesn't hurt until it expldes...
167 dying = DYING_SQUISHED;
168 } else if(kind == BAD_FLAME) {
169 base.ym = 0; // we misuse base.ym as angle for the flame
170 physic.enable_gravity(false);
171 set_texture(img_flame, img_flame, 2, 0.5);
172 } else if(kind == BAD_BOUNCINGSNOWBALL) {
173 physic.set_velocity(-1.3, 0);
174 set_texture(img_bouncingsnowball_left, img_bouncingsnowball_right, 6);
175 } else if(kind == BAD_STALACTITE) {
176 physic.enable_gravity(false);
177 set_texture(img_stalactite, img_stalactite, 1);
178 } else if(kind == BAD_FISH) {
179 set_texture(img_fish, img_fish, 2, 1);
180 physic.enable_gravity(true);
181 } else if(kind == BAD_FLYINGSNOWBALL) {
182 set_texture(img_flyingsnowball, img_flyingsnowball, 2, 5);
183 physic.enable_gravity(false);
184 } else if(kind == BAD_SPIKY) {
185 physic.set_velocity(-1.3, 0);
186 set_texture(img_spiky_left, img_spiky_right, 3);
187 } else if(kind == BAD_SNOWBALL) {
188 physic.set_velocity(-1.3, 0);
189 set_texture(img_snowball_left, img_snowball_right, 4, 5);
192 // if we're in a solid tile at start correct that now
193 if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(&base)) {
194 printf("Warning: badguy started in wall!.\n");
195 while(collision_object_map(&base))
201 BadGuy::action_bsod(float frame_ratio)
203 static const float BSODJUMP = 2;
205 if (dying == DYING_NOT)
206 check_horizontal_bump();
210 // jump when we're about to fall
211 if (physic.get_velocity_y() == 0 &&
212 !issolid(base.x+base.width/2, base.y + base.height)) {
213 physic.enable_gravity(true);
214 physic.set_velocity(physic.get_velocity_x(), BSODJUMP);
217 // Handle dying timer:
218 if (dying == DYING_SQUISHED && !timer.check())
220 /* Remove it if time's up: */
226 physic.apply(frame_ratio, base.x, base.y);
227 if(dying != DYING_FALLING)
228 collision_swept_object_map(&old_base, &base);
232 BadGuy::action_laptop(float frame_ratio)
234 Player& tux = *World::current()->get_tux();
238 /* Move left/right: */
239 if (mode == NORMAL || mode == KICK)
242 physic.apply(frame_ratio, base.x, base.y);
243 if (dying != DYING_FALLING)
244 collision_swept_object_map(&old_base,&base);
246 else if (mode == HELD)
247 { /* FIXME: The pbad object shouldn't know about pplayer objects. */
248 /* If we're holding the laptop */
252 base.x = tux.base.x + 16;
253 base.y = tux.base.y + tux.base.height/1.5 - base.height;
255 else /* facing left */
257 base.x = tux.base.x - 16;
258 base.y = tux.base.y + tux.base.height/1.5 - base.height;
260 if(collision_object_map(&base))
263 base.y = tux.base.y + tux.base.height/1.5 - base.height;
266 if(tux.input.fire != DOWN) /* SHOOT! */
275 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
276 physic.set_velocity((dir == LEFT) ? -8 : 8, -8);
277 play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
284 check_horizontal_bump();
285 if(mode == KICK && changed != dir)
287 /* handle stereo sound (number 10 should be tweaked...)*/
288 if (base.x < scroll_x + screen->w/2 - 10)
289 play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
290 else if (base.x > scroll_x + screen->w/2 + 10)
291 play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
293 play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
297 /* Handle mode timer: */
303 set_texture(img_laptop_left, img_laptop_right, 4, 5);
304 physic.set_velocity( (dir == LEFT) ? -1.3 : 1.3, 0);
310 BadGuy::check_horizontal_bump(bool checkcliff)
312 float halfheight = base.height / 2;
313 if (dir == LEFT && issolid( base.x, (int) base.y + halfheight))
316 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
319 if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight))
322 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
326 // don't check for cliffs when we're falling
329 if(!issolid(base.x + base.width/2, base.y + base.height))
332 if(dir == LEFT && !issolid(base.x, (int) base.y + base.height + halfheight))
335 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
338 if(dir == RIGHT && !issolid(base.x + base.width,
339 (int) base.y + base.height + halfheight))
342 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
350 /* Fall if we get off the ground: */
351 if (dying != DYING_FALLING)
353 if (!issolid(base.x+base.width/2, base.y + base.height))
355 // not solid below us? enable gravity
356 physic.enable_gravity(true);
361 if (physic.get_velocity_y() < 0)
363 base.y = int((base.y + base.height)/32) * 32 - base.height;
364 physic.set_velocity(physic.get_velocity_x(), 0);
366 // no gravity anymore please
367 physic.enable_gravity(false);
372 physic.enable_gravity(true);
379 for(std::vector<BadGuy>::iterator i = World::current()->bad_guys.begin();
380 i != World::current()->bad_guys.end(); ++i)
382 if( & (*i) == this) {
383 World::current()->bad_guys.erase(i);
390 BadGuy::action_money(float frame_ratio)
392 Player& tux = *World::current()->get_tux();
394 static const float JUMPV = 6;
397 // jump when on ground
398 if(dying == DYING_NOT && issolid(base.x, base.y+32))
400 physic.set_velocity(physic.get_velocity_x(), JUMPV);
401 physic.enable_gravity(true);
402 set_texture(&img_money_left[1], &img_money_right[1], 1);
405 else if(mode == MONEY_JUMP)
407 set_texture(&img_money_left[0], &img_money_right[0], 1);
411 // set direction based on tux
412 if(tux.base.x > base.x)
418 physic.apply(frame_ratio, base.x, base.y);
419 if(dying == DYING_NOT)
420 collision_swept_object_map(&old_base, &base);
424 BadGuy::action_mrbomb(float frame_ratio)
426 if (dying == DYING_NOT)
427 check_horizontal_bump(true);
431 physic.apply(frame_ratio, base.x, base.y);
432 if (dying != DYING_FALLING)
433 collision_swept_object_map(&old_base,&base);
437 BadGuy::action_bomb(float frame_ratio)
439 static const int TICKINGTIME = 1000;
440 static const int EXPLODETIME = 1000;
446 timer.start(TICKINGTIME);
447 } else if(!timer.check()) {
448 if(mode == BOMB_TICKING) {
450 set_texture(img_mrbomb_explosion, img_mrbomb_explosion, 1);
451 dying = DYING_NOT; // now the bomb hurts
452 timer.start(EXPLODETIME);
453 } else if(mode == BOMB_EXPLODE) {
460 physic.apply(frame_ratio, base.x, base.y);
461 collision_swept_object_map(&old_base,&base);
465 BadGuy::action_stalactite(float frame_ratio)
467 Player& tux = *World::current()->get_tux();
469 static const int SHAKETIME = 800;
470 static const int RANGE = 40;
473 // start shaking when tux is below the stalactite and at least 40 pixels
475 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
476 && tux.base.y + tux.base.height > base.y) {
477 timer.start(SHAKETIME);
478 mode = STALACTITE_SHAKING;
480 } if(mode == STALACTITE_SHAKING) {
481 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
483 mode = STALACTITE_FALL;
485 } else if(mode == STALACTITE_FALL) {
487 /* Destroy if we collides with land */
488 if(issolid(base.x+base.width/2, base.y+base.height))
491 dying = DYING_SQUISHED;
493 set_texture(img_stalactite_broken, img_stalactite_broken, 1);
495 } else if(mode == FLAT) {
500 physic.apply(frame_ratio, base.x, base.y);
502 if(dying == DYING_SQUISHED && !timer.check())
507 BadGuy::action_flame(float frame_ratio)
509 static const float radius = 100;
510 static const float speed = 0.02;
511 base.x = old_base.x + cos(base.ym) * radius;
512 base.y = old_base.y + sin(base.ym) * radius;
514 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
518 BadGuy::action_fish(float frame_ratio)
520 static const float JUMPV = 6;
521 static const int WAITTIME = 1000;
523 // go in wait mode when back in water
524 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
525 && physic.get_velocity_y() <= 0 && mode == NORMAL)
529 physic.set_velocity(0, 0);
530 physic.enable_gravity(false);
531 timer.start(WAITTIME);
533 else if(mode == FISH_WAIT && !timer.check())
536 set_texture(img_fish, img_fish, 2, 1.5);
537 animation_offset = global_frame_counter; // restart animation
539 physic.set_velocity(0, JUMPV);
540 physic.enable_gravity(true);
543 physic.apply(frame_ratio, base.x, base.y);
544 if(dying == DYING_NOT)
545 collision_swept_object_map(&old_base, &base);
549 BadGuy::action_bouncingsnowball(float frame_ratio)
551 static const float JUMPV = 4.5;
555 // jump when on ground
556 if(dying == DYING_NOT && issolid(base.x, base.y+32))
558 physic.set_velocity(physic.get_velocity_x(), JUMPV);
559 physic.enable_gravity(true);
566 // check for right/left collisions
567 check_horizontal_bump();
569 physic.apply(frame_ratio, base.x, base.y);
570 if(dying == DYING_NOT)
571 collision_swept_object_map(&old_base, &base);
573 // Handle dying timer:
574 if (dying == DYING_SQUISHED && !timer.check())
576 /* Remove it if time's up: */
583 BadGuy::action_flyingsnowball(float frame_ratio)
585 static const float FLYINGSPEED = 1;
586 static const int DIRCHANGETIME = 1000;
588 // go into flyup mode if none specified yet
589 if(dying == DYING_NOT && mode == NORMAL) {
591 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
592 timer.start(DIRCHANGETIME/2);
595 if(dying == DYING_NOT && !timer.check()) {
598 physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED);
599 } else if(mode == FLY_DOWN) {
601 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
603 timer.start(DIRCHANGETIME);
606 if(dying != DYING_NOT)
607 physic.enable_gravity(true);
609 physic.apply(frame_ratio, base.x, base.y);
610 if(dying == DYING_NOT || dying == DYING_SQUISHED)
611 collision_swept_object_map(&old_base, &base);
613 // Handle dying timer:
614 if (dying == DYING_SQUISHED && !timer.check())
616 /* Remove it if time's up: */
623 BadGuy::action_spiky(float frame_ratio)
625 if (dying == DYING_NOT)
626 check_horizontal_bump();
630 // jump when we're about to fall
631 if (physic.get_velocity_y() == 0 &&
632 !issolid(base.x+base.width/2, base.y + base.height)) {
633 physic.enable_gravity(true);
634 physic.set_velocity(physic.get_velocity_x(), 2);
638 physic.apply(frame_ratio, base.x, base.y);
639 if (dying != DYING_FALLING)
640 collision_swept_object_map(&old_base,&base);
644 BadGuy::action_snowball(float frame_ratio)
646 if (dying == DYING_NOT)
647 check_horizontal_bump();
651 physic.apply(frame_ratio, base.x, base.y);
652 if (dying != DYING_FALLING)
653 collision_swept_object_map(&old_base,&base);
657 BadGuy::action(float frame_ratio)
659 // Remove if it's far off the screen:
660 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
666 // BadGuy fall below the ground
667 if (base.y > screen->h) {
672 // Once it's on screen, it's activated!
673 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
682 action_bsod(frame_ratio);
686 action_laptop(frame_ratio);
690 action_money(frame_ratio);
694 action_mrbomb(frame_ratio);
698 action_bomb(frame_ratio);
702 action_stalactite(frame_ratio);
706 action_flame(frame_ratio);
710 action_fish(frame_ratio);
713 case BAD_BOUNCINGSNOWBALL:
714 action_bouncingsnowball(frame_ratio);
717 case BAD_FLYINGSNOWBALL:
718 action_flyingsnowball(frame_ratio);
722 action_spiky(frame_ratio);
726 action_snowball(frame_ratio);
734 // Don't try to draw stuff that is outside of the screen
735 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
737 if(texture_left == 0 || texture_right == 0)
740 float global_frame = (float(global_frame_counter - animation_offset) / 10);
741 global_frame *= animation_speed;
742 size_t frame = size_t(global_frame) % animation_length;
743 texture_type* texture =
744 (dir == LEFT) ? &texture_left[frame] : &texture_right[frame];
745 texture_draw(texture, base.x - scroll_x, base.y);
748 fillrect(base.x - scroll_x, base.y, 32, 32, 75,0,75, 150);
752 BadGuy::set_texture(texture_type* left, texture_type* right,
753 int nanimlength, float nanimspeed)
756 if(base.width == 0 && base.height == 0) {
757 base.width = left->w;
758 base.height = left->h;
759 } else if(base.width != left->w || base.height != left->h) {
760 base.x -= (left->w - base.width) / 2;
761 base.y -= left->h - base.height;
762 base.width = left->w;
763 base.height = left->h;
767 base.width = base.height = 0;
770 animation_length = nanimlength;
771 animation_speed = nanimspeed;
772 animation_offset = 0;
774 texture_right = right;
780 if(kind == BAD_BSOD || kind == BAD_LAPTOP || kind == BAD_MRBOMB
781 || kind == BAD_BOUNCINGSNOWBALL) {
787 BadGuy::make_player_jump(Player* player)
789 player->physic.set_velocity(player->physic.get_velocity_x(), 2);
790 player->base.y = base.y - player->base.height - 2;
794 BadGuy::squish_me(Player* player)
796 make_player_jump(player);
798 World::current()->add_score(base.x - scroll_x,
799 base.y, 50 * player_status.score_multiplier);
800 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
801 player_status.score_multiplier++;
803 dying = DYING_SQUISHED;
805 physic.set_velocity(0, 0);
809 BadGuy::squish(Player* player)
811 if(kind == BAD_MRBOMB) {
812 // mrbomb transforms into a bomb now
813 World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
815 make_player_jump(player);
816 World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier);
817 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
818 player_status.score_multiplier++;
823 } else if(kind == BAD_BSOD) {
825 set_texture(img_bsod_squished_left, img_bsod_squished_right, 1);
826 physic.set_velocity(0, physic.get_velocity_y());
829 } else if (kind == BAD_LAPTOP) {
830 if (mode == NORMAL || mode == KICK)
833 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
835 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
836 physic.set_velocity(0, physic.get_velocity_y());
839 } else if (mode == FLAT) {
841 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
843 if (player->base.x < base.x + (base.width/2)) {
844 physic.set_velocity(5, physic.get_velocity_y());
847 physic.set_velocity(-5, physic.get_velocity_y());
852 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
855 make_player_jump(player);
857 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
858 player_status.score_multiplier++;
860 } else if(kind == BAD_FISH) {
861 make_player_jump(player);
863 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
864 player_status.score_multiplier++;
866 // simply remove the fish...
869 } else if(kind == BAD_BOUNCINGSNOWBALL) {
871 set_texture(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1);
873 } else if(kind == BAD_FLYINGSNOWBALL) {
875 set_texture(img_flyingsnowball_squished,img_flyingsnowball_squished,1);
877 } else if(kind == BAD_SNOWBALL) {
879 set_texture(img_snowball_squished_left, img_snowball_squished_right, 1);
887 if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
890 dying = DYING_FALLING;
891 if(kind == BAD_LAPTOP)
892 set_texture(img_laptop_falling_left, img_laptop_falling_right, 1);
893 else if(kind == BAD_BSOD)
894 set_texture(img_bsod_falling_left, img_bsod_falling_right, 1);
896 physic.enable_gravity(true);
897 physic.set_velocity(physic.get_velocity_x(), 0);
899 /* Gain some points: */
900 if (kind == BAD_BSOD)
901 World::current()->add_score(base.x - scroll_x, base.y,
902 50 * player_status.score_multiplier);
904 World::current()->add_score(base.x - scroll_x, base.y,
905 25 * player_status.score_multiplier);
907 /* Play death sound: */
908 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
912 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
914 BadGuy* pbad_c = NULL;
916 if(type == COLLISION_BUMP) {
920 if(type == COLLISION_SQUISH) {
921 Player* player = static_cast<Player*>(p_c_object);
933 pbad_c = (BadGuy*) p_c_object;
934 if(kind == BAD_LAPTOP && mode == KICK &&
935 pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB)
937 /* We're in kick mode, kill the other guy
938 and yourself(wuahaha) : */
946 //---------------------------------------------------------------------------
948 void load_badguy_gfx()
951 texture_load(&img_bsod_left[0], datadir +
952 "/images/shared/bsod-left-0.png",
955 texture_load(&img_bsod_left[1], datadir +
956 "/images/shared/bsod-left-1.png",
959 texture_load(&img_bsod_left[2], datadir +
960 "/images/shared/bsod-left-2.png",
963 texture_load(&img_bsod_left[3], datadir +
964 "/images/shared/bsod-left-3.png",
967 texture_load(&img_bsod_right[0], datadir +
968 "/images/shared/bsod-right-0.png",
971 texture_load(&img_bsod_right[1], datadir +
972 "/images/shared/bsod-right-1.png",
975 texture_load(&img_bsod_right[2], datadir +
976 "/images/shared/bsod-right-2.png",
979 texture_load(&img_bsod_right[3], datadir +
980 "/images/shared/bsod-right-3.png",
983 texture_load(&img_bsod_squished_left[0], datadir +
984 "/images/shared/bsod-squished-left.png",
987 texture_load(&img_bsod_squished_right[0], datadir +
988 "/images/shared/bsod-squished-right.png",
991 texture_load(&img_bsod_falling_left[0], datadir +
992 "/images/shared/bsod-falling-left.png",
995 texture_load(&img_bsod_falling_right[0], datadir +
996 "/images/shared/bsod-falling-right.png",
1002 texture_load(&img_laptop_left[0], datadir + "/images/shared/mriceblock-left-0.png", USE_ALPHA);
1003 texture_load(&img_laptop_left[1], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1004 texture_load(&img_laptop_left[2], datadir + "/images/shared/mriceblock-left-2.png", USE_ALPHA);
1005 texture_load(&img_laptop_left[3], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1007 texture_load(&img_laptop_right[0], datadir + "/images/shared/mriceblock-right-0.png", USE_ALPHA);
1008 texture_load(&img_laptop_right[1], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1009 texture_load(&img_laptop_right[2], datadir + "/images/shared/mriceblock-right-2.png", USE_ALPHA);
1010 texture_load(&img_laptop_right[3], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1012 texture_load(&img_laptop_flat_left[0],
1013 datadir + "/images/shared/laptop-flat-left.png",
1016 texture_load(&img_laptop_flat_right[0], datadir +
1017 "/images/shared/laptop-flat-right.png",
1020 texture_load(&img_laptop_falling_left[0], datadir +
1021 "/images/shared/laptop-falling-left.png",
1024 texture_load(&img_laptop_falling_right[0], datadir +
1025 "/images/shared/laptop-falling-right.png",
1031 texture_load(&img_money_left[0], datadir +
1032 "/images/shared/bag-left-0.png",
1035 texture_load(&img_money_left[1], datadir +
1036 "/images/shared/bag-left-1.png",
1039 texture_load(&img_money_right[0], datadir +
1040 "/images/shared/bag-right-0.png",
1043 texture_load(&img_money_right[1], datadir +
1044 "/images/shared/bag-right-1.png",
1048 for(int i=0; i<4; ++i) {
1050 snprintf(num, 4, "%d", i);
1051 texture_load(&img_mrbomb_left[i],
1052 datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA);
1053 texture_load(&img_mrbomb_right[i],
1054 datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA);
1056 texture_load(&img_mrbomb_ticking_left[0],
1057 datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA);
1058 texture_load(&img_mrbomb_ticking_right[0],
1059 datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA);
1060 texture_load(&img_mrbomb_explosion[0],
1061 datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA);
1064 texture_load(&img_stalactite[0],
1065 datadir + "/images/shared/stalactite.png", USE_ALPHA);
1066 texture_load(&img_stalactite_broken[0],
1067 datadir + "/images/shared/stalactite-broken.png", USE_ALPHA);
1070 texture_load(&img_flame[0],
1071 datadir + "/images/shared/flame-0.png", USE_ALPHA);
1072 texture_load(&img_flame[1],
1073 datadir + "/images/shared/flame-1.png", USE_ALPHA);
1076 texture_load(&img_fish[0],
1077 datadir + "/images/shared/fish-left-0.png", USE_ALPHA);
1078 texture_load(&img_fish[1],
1079 datadir + "/images/shared/fish-left-1.png", USE_ALPHA);
1081 /* bouncing snowball */
1082 for(int i=0; i<6; ++i) {
1084 snprintf(num, 4, "%d", i);
1085 texture_load(&img_bouncingsnowball_left[i],
1086 datadir + "/images/shared/bouncingsnowball-left-" + num + ".png",
1088 texture_load(&img_bouncingsnowball_right[i],
1089 datadir + "/images/shared/bouncingsnowball-right-" + num + ".png",
1092 texture_load(&img_bouncingsnowball_squished[0],
1093 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1095 /* flying snowball */
1096 texture_load(&img_flyingsnowball[0],
1097 datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA);
1098 texture_load(&img_flyingsnowball[1],
1099 datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA);
1100 texture_load(&img_flyingsnowball_squished[0],
1101 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1104 for(int i = 0; i < 3; ++i) {
1106 snprintf(num, 4, "%d", i);
1107 texture_load(&img_spiky_left[i],
1108 datadir + "/images/shared/spiky-left-" + num + ".png",
1110 texture_load(&img_spiky_right[i],
1111 datadir + "/images/shared/spiky-right-" + num + ".png",
1116 texture_load(&img_snowball_left[0], datadir + "/images/shared/snowball-left-0.png", USE_ALPHA);
1117 texture_load(&img_snowball_left[1], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1118 texture_load(&img_snowball_left[2], datadir + "/images/shared/snowball-left-2.png", USE_ALPHA);
1119 texture_load(&img_snowball_left[3], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1121 texture_load(&img_snowball_right[0], datadir + "/images/shared/snowball-right-0.png", USE_ALPHA);
1122 texture_load(&img_snowball_right[1], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1123 texture_load(&img_snowball_right[2], datadir + "/images/shared/snowball-right-2.png", USE_ALPHA);
1124 texture_load(&img_snowball_right[3], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1126 texture_load(&img_snowball_squished_left[0],
1127 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1128 texture_load(&img_snowball_squished_right[0],
1129 datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA);
1132 void free_badguy_gfx()
1134 for (int i = 0; i < 4; i++)
1136 texture_free(&img_bsod_left[i]);
1137 texture_free(&img_bsod_right[i]);
1140 texture_free(&img_bsod_squished_left[0]);
1141 texture_free(&img_bsod_squished_right[0]);
1143 texture_free(&img_bsod_falling_left[0]);
1144 texture_free(&img_bsod_falling_right[0]);
1146 for (int i = 0; i < 4; i++)
1148 texture_free(&img_laptop_left[i]);
1149 texture_free(&img_laptop_right[i]);
1152 texture_free(&img_laptop_flat_left[0]);
1153 texture_free(&img_laptop_flat_right[0]);
1155 texture_free(&img_laptop_falling_left[0]);
1156 texture_free(&img_laptop_falling_right[0]);
1158 for (int i = 0; i < 2; i++)
1160 texture_free(&img_money_left[i]);
1161 texture_free(&img_money_right[i]);
1164 for(int i = 0; i < 4; i++) {
1165 texture_free(&img_mrbomb_left[i]);
1166 texture_free(&img_mrbomb_right[i]);
1169 texture_free(&img_mrbomb_ticking_left[0]);
1170 texture_free(&img_mrbomb_ticking_right[0]);
1171 texture_free(&img_mrbomb_explosion[0]);
1173 texture_free(&img_stalactite[0]);
1174 texture_free(&img_stalactite_broken[0]);
1176 texture_free(&img_flame[0]);
1177 texture_free(&img_flame[1]);
1179 texture_free(&img_fish[0]);
1180 texture_free(&img_fish[1]);
1182 for(int i=0; i<6; ++i) {
1183 texture_free(&img_bouncingsnowball_left[i]);
1184 texture_free(&img_bouncingsnowball_right[i]);
1186 texture_free(&img_bouncingsnowball_squished[0]);
1188 texture_free(&img_flyingsnowball[0]);
1189 texture_free(&img_flyingsnowball[1]);
1190 texture_free(&img_flyingsnowball_squished[0]);
1192 for(int i = 0; i<3; ++i) {
1193 texture_free(&img_spiky_left[i]);
1194 texture_free(&img_spiky_right[i]);
1196 for(int i = 0; i<4; ++i) {
1197 texture_free(&img_snowball_left[i]);
1198 texture_free(&img_snowball_right[i]);
1200 texture_free(&img_snowball_squished_left[0]);
1201 texture_free(&img_snowball_squished_right[0]);