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();
236 if(dying == DYING_NOT)
239 /* Move left/right: */
240 if (mode == NORMAL || mode == KICK)
243 physic.apply(frame_ratio, base.x, base.y);
244 if (dying != DYING_FALLING)
245 collision_swept_object_map(&old_base,&base);
247 else if (mode == HELD)
248 { /* FIXME: The pbad object shouldn't know about pplayer objects. */
249 /* If we're holding the laptop */
253 base.x = tux.base.x + 16;
254 base.y = tux.base.y + tux.base.height/1.5 - base.height;
256 else /* facing left */
258 base.x = tux.base.x - 16;
259 base.y = tux.base.y + tux.base.height/1.5 - base.height;
261 if(collision_object_map(&base))
264 base.y = tux.base.y + tux.base.height/1.5 - base.height;
267 if(tux.input.fire != DOWN) /* SHOOT! */
276 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
277 physic.set_velocity((dir == LEFT) ? -8 : 8, -8);
278 play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
285 check_horizontal_bump();
286 if(mode == KICK && changed != dir)
288 /* handle stereo sound (number 10 should be tweaked...)*/
289 if (base.x < scroll_x + screen->w/2 - 10)
290 play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
291 else if (base.x > scroll_x + screen->w/2 + 10)
292 play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
294 play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
298 /* Handle mode timer: */
304 set_texture(img_laptop_left, img_laptop_right, 4, 5);
305 physic.set_velocity( (dir == LEFT) ? -1.3 : 1.3, 0);
311 BadGuy::check_horizontal_bump(bool checkcliff)
313 float halfheight = base.height / 2;
314 if (dir == LEFT && issolid( base.x, (int) base.y + halfheight))
317 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
320 if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight))
323 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
327 // don't check for cliffs when we're falling
330 if(!issolid(base.x + base.width/2, base.y + base.height))
333 if(dir == LEFT && !issolid(base.x, (int) base.y + base.height + halfheight))
336 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
339 if(dir == RIGHT && !issolid(base.x + base.width,
340 (int) base.y + base.height + halfheight))
343 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
351 /* Fall if we get off the ground: */
352 if (dying != DYING_FALLING)
354 if (!issolid(base.x+base.width/2, base.y + base.height))
356 // not solid below us? enable gravity
357 physic.enable_gravity(true);
362 if (physic.get_velocity_y() < 0)
364 base.y = int((base.y + base.height)/32) * 32 - base.height;
365 physic.set_velocity(physic.get_velocity_x(), 0);
367 // no gravity anymore please
368 physic.enable_gravity(false);
373 physic.enable_gravity(true);
380 for(std::vector<BadGuy>::iterator i = World::current()->bad_guys.begin();
381 i != World::current()->bad_guys.end(); ++i)
383 if( & (*i) == this) {
384 World::current()->bad_guys.erase(i);
391 BadGuy::action_money(float frame_ratio)
393 Player& tux = *World::current()->get_tux();
395 static const float JUMPV = 6;
398 // jump when on ground
399 if(dying == DYING_NOT && issolid(base.x, base.y+32))
401 physic.set_velocity(physic.get_velocity_x(), JUMPV);
402 physic.enable_gravity(true);
403 set_texture(&img_money_left[1], &img_money_right[1], 1);
406 else if(mode == MONEY_JUMP)
408 set_texture(&img_money_left[0], &img_money_right[0], 1);
412 // set direction based on tux
413 if(tux.base.x > base.x)
419 physic.apply(frame_ratio, base.x, base.y);
420 if(dying == DYING_NOT)
421 collision_swept_object_map(&old_base, &base);
425 BadGuy::action_mrbomb(float frame_ratio)
427 if (dying == DYING_NOT)
428 check_horizontal_bump(true);
432 physic.apply(frame_ratio, base.x, base.y);
433 if (dying != DYING_FALLING)
434 collision_swept_object_map(&old_base,&base);
438 BadGuy::action_bomb(float frame_ratio)
440 static const int TICKINGTIME = 1000;
441 static const int EXPLODETIME = 1000;
447 timer.start(TICKINGTIME);
448 } else if(!timer.check()) {
449 if(mode == BOMB_TICKING) {
451 set_texture(img_mrbomb_explosion, img_mrbomb_explosion, 1);
452 dying = DYING_NOT; // now the bomb hurts
453 timer.start(EXPLODETIME);
454 } else if(mode == BOMB_EXPLODE) {
461 physic.apply(frame_ratio, base.x, base.y);
462 collision_swept_object_map(&old_base,&base);
466 BadGuy::action_stalactite(float frame_ratio)
468 Player& tux = *World::current()->get_tux();
470 static const int SHAKETIME = 800;
471 static const int RANGE = 40;
474 // start shaking when tux is below the stalactite and at least 40 pixels
476 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
477 && tux.base.y + tux.base.height > base.y) {
478 timer.start(SHAKETIME);
479 mode = STALACTITE_SHAKING;
481 } if(mode == STALACTITE_SHAKING) {
482 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
484 mode = STALACTITE_FALL;
486 } else if(mode == STALACTITE_FALL) {
488 /* Destroy if we collides with land */
489 if(issolid(base.x+base.width/2, base.y+base.height))
492 dying = DYING_SQUISHED;
494 set_texture(img_stalactite_broken, img_stalactite_broken, 1);
496 } else if(mode == FLAT) {
501 physic.apply(frame_ratio, base.x, base.y);
503 if(dying == DYING_SQUISHED && !timer.check())
508 BadGuy::action_flame(float frame_ratio)
510 static const float radius = 100;
511 static const float speed = 0.02;
512 base.x = old_base.x + cos(base.ym) * radius;
513 base.y = old_base.y + sin(base.ym) * radius;
515 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
519 BadGuy::action_fish(float frame_ratio)
521 static const float JUMPV = 6;
522 static const int WAITTIME = 1000;
524 // go in wait mode when back in water
525 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
526 && physic.get_velocity_y() <= 0 && mode == NORMAL)
530 physic.set_velocity(0, 0);
531 physic.enable_gravity(false);
532 timer.start(WAITTIME);
534 else if(mode == FISH_WAIT && !timer.check())
537 set_texture(img_fish, img_fish, 2, 1.5);
538 animation_offset = global_frame_counter; // restart animation
540 physic.set_velocity(0, JUMPV);
541 physic.enable_gravity(true);
544 physic.apply(frame_ratio, base.x, base.y);
545 if(dying == DYING_NOT)
546 collision_swept_object_map(&old_base, &base);
550 BadGuy::action_bouncingsnowball(float frame_ratio)
552 static const float JUMPV = 4.5;
556 // jump when on ground
557 if(dying == DYING_NOT && issolid(base.x, base.y+32))
559 physic.set_velocity(physic.get_velocity_x(), JUMPV);
560 physic.enable_gravity(true);
567 // check for right/left collisions
568 check_horizontal_bump();
570 physic.apply(frame_ratio, base.x, base.y);
571 if(dying == DYING_NOT)
572 collision_swept_object_map(&old_base, &base);
574 // Handle dying timer:
575 if (dying == DYING_SQUISHED && !timer.check())
577 /* Remove it if time's up: */
584 BadGuy::action_flyingsnowball(float frame_ratio)
586 static const float FLYINGSPEED = 1;
587 static const int DIRCHANGETIME = 1000;
589 // go into flyup mode if none specified yet
590 if(dying == DYING_NOT && mode == NORMAL) {
592 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
593 timer.start(DIRCHANGETIME/2);
596 if(dying == DYING_NOT && !timer.check()) {
599 physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED);
600 } else if(mode == FLY_DOWN) {
602 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
604 timer.start(DIRCHANGETIME);
607 if(dying != DYING_NOT)
608 physic.enable_gravity(true);
610 physic.apply(frame_ratio, base.x, base.y);
611 if(dying == DYING_NOT || dying == DYING_SQUISHED)
612 collision_swept_object_map(&old_base, &base);
614 // Handle dying timer:
615 if (dying == DYING_SQUISHED && !timer.check())
617 /* Remove it if time's up: */
624 BadGuy::action_spiky(float frame_ratio)
626 if (dying == DYING_NOT)
627 check_horizontal_bump();
631 // jump when we're about to fall
632 if (physic.get_velocity_y() == 0 &&
633 !issolid(base.x+base.width/2, base.y + base.height)) {
634 physic.enable_gravity(true);
635 physic.set_velocity(physic.get_velocity_x(), 2);
639 physic.apply(frame_ratio, base.x, base.y);
640 if (dying != DYING_FALLING)
641 collision_swept_object_map(&old_base,&base);
645 BadGuy::action_snowball(float frame_ratio)
647 if (dying == DYING_NOT)
648 check_horizontal_bump();
652 physic.apply(frame_ratio, base.x, base.y);
653 if (dying != DYING_FALLING)
654 collision_swept_object_map(&old_base,&base);
658 BadGuy::action(float frame_ratio)
660 // Remove if it's far off the screen:
661 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
667 // BadGuy fall below the ground
668 if (base.y > screen->h) {
673 // Once it's on screen, it's activated!
674 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
683 action_bsod(frame_ratio);
687 action_laptop(frame_ratio);
691 action_money(frame_ratio);
695 action_mrbomb(frame_ratio);
699 action_bomb(frame_ratio);
703 action_stalactite(frame_ratio);
707 action_flame(frame_ratio);
711 action_fish(frame_ratio);
714 case BAD_BOUNCINGSNOWBALL:
715 action_bouncingsnowball(frame_ratio);
718 case BAD_FLYINGSNOWBALL:
719 action_flyingsnowball(frame_ratio);
723 action_spiky(frame_ratio);
727 action_snowball(frame_ratio);
735 // Don't try to draw stuff that is outside of the screen
736 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
738 if(texture_left == 0 || texture_right == 0)
741 float global_frame = (float(global_frame_counter - animation_offset) / 10);
742 global_frame *= animation_speed;
743 size_t frame = size_t(global_frame) % animation_length;
744 texture_type* texture =
745 (dir == LEFT) ? &texture_left[frame] : &texture_right[frame];
746 texture_draw(texture, base.x - scroll_x, base.y);
749 fillrect(base.x - scroll_x, base.y, 32, 32, 75,0,75, 150);
753 BadGuy::set_texture(texture_type* left, texture_type* right,
754 int nanimlength, float nanimspeed)
757 if(base.width == 0 && base.height == 0) {
758 base.width = left->w;
759 base.height = left->h;
760 } else if(base.width != left->w || base.height != left->h) {
761 base.x -= (left->w - base.width) / 2;
762 base.y -= left->h - base.height;
763 base.width = left->w;
764 base.height = left->h;
768 base.width = base.height = 0;
771 animation_length = nanimlength;
772 animation_speed = nanimspeed;
773 animation_offset = 0;
775 texture_right = right;
781 if(kind == BAD_BSOD || kind == BAD_LAPTOP || kind == BAD_MRBOMB
782 || kind == BAD_BOUNCINGSNOWBALL) {
788 BadGuy::make_player_jump(Player* player)
790 player->physic.set_velocity(player->physic.get_velocity_x(), 2);
791 player->base.y = base.y - player->base.height - 2;
795 BadGuy::squish_me(Player* player)
797 make_player_jump(player);
799 World::current()->add_score(base.x - scroll_x,
800 base.y, 50 * player_status.score_multiplier);
801 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
802 player_status.score_multiplier++;
804 dying = DYING_SQUISHED;
806 physic.set_velocity(0, 0);
810 BadGuy::squish(Player* player)
812 if(kind == BAD_MRBOMB) {
813 // mrbomb transforms into a bomb now
814 World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
816 make_player_jump(player);
817 World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier);
818 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
819 player_status.score_multiplier++;
824 } else if(kind == BAD_BSOD) {
826 set_texture(img_bsod_squished_left, img_bsod_squished_right, 1);
827 physic.set_velocity(0, physic.get_velocity_y());
830 } else if (kind == BAD_LAPTOP) {
831 if (mode == NORMAL || mode == KICK)
834 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
836 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
837 physic.set_velocity(0, physic.get_velocity_y());
840 } else if (mode == FLAT) {
842 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
844 if (player->base.x < base.x + (base.width/2)) {
845 physic.set_velocity(5, physic.get_velocity_y());
848 physic.set_velocity(-5, physic.get_velocity_y());
853 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
856 make_player_jump(player);
858 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
859 player_status.score_multiplier++;
861 } else if(kind == BAD_FISH) {
862 make_player_jump(player);
864 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
865 player_status.score_multiplier++;
867 // simply remove the fish...
870 } else if(kind == BAD_BOUNCINGSNOWBALL) {
872 set_texture(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1);
874 } else if(kind == BAD_FLYINGSNOWBALL) {
876 set_texture(img_flyingsnowball_squished,img_flyingsnowball_squished,1);
878 } else if(kind == BAD_SNOWBALL) {
880 set_texture(img_snowball_squished_left, img_snowball_squished_right, 1);
888 if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
891 dying = DYING_FALLING;
892 if(kind == BAD_LAPTOP)
893 set_texture(img_laptop_falling_left, img_laptop_falling_right, 1);
894 else if(kind == BAD_BSOD)
895 set_texture(img_bsod_falling_left, img_bsod_falling_right, 1);
897 physic.enable_gravity(true);
898 physic.set_velocity(physic.get_velocity_x(), 0);
900 /* Gain some points: */
901 if (kind == BAD_BSOD)
902 World::current()->add_score(base.x - scroll_x, base.y,
903 50 * player_status.score_multiplier);
905 World::current()->add_score(base.x - scroll_x, base.y,
906 25 * player_status.score_multiplier);
908 /* Play death sound: */
909 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
913 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
915 BadGuy* pbad_c = NULL;
917 if(type == COLLISION_BUMP) {
921 if(type == COLLISION_SQUISH) {
922 Player* player = static_cast<Player*>(p_c_object);
934 pbad_c = (BadGuy*) p_c_object;
935 if(kind == BAD_LAPTOP && mode == KICK &&
936 pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB)
938 /* We're in kick mode, kill the other guy
939 and yourself(wuahaha) : */
947 //---------------------------------------------------------------------------
949 void load_badguy_gfx()
952 texture_load(&img_bsod_left[0], datadir +
953 "/images/shared/bsod-left-0.png",
956 texture_load(&img_bsod_left[1], datadir +
957 "/images/shared/bsod-left-1.png",
960 texture_load(&img_bsod_left[2], datadir +
961 "/images/shared/bsod-left-2.png",
964 texture_load(&img_bsod_left[3], datadir +
965 "/images/shared/bsod-left-3.png",
968 texture_load(&img_bsod_right[0], datadir +
969 "/images/shared/bsod-right-0.png",
972 texture_load(&img_bsod_right[1], datadir +
973 "/images/shared/bsod-right-1.png",
976 texture_load(&img_bsod_right[2], datadir +
977 "/images/shared/bsod-right-2.png",
980 texture_load(&img_bsod_right[3], datadir +
981 "/images/shared/bsod-right-3.png",
984 texture_load(&img_bsod_squished_left[0], datadir +
985 "/images/shared/bsod-squished-left.png",
988 texture_load(&img_bsod_squished_right[0], datadir +
989 "/images/shared/bsod-squished-right.png",
992 texture_load(&img_bsod_falling_left[0], datadir +
993 "/images/shared/bsod-falling-left.png",
996 texture_load(&img_bsod_falling_right[0], datadir +
997 "/images/shared/bsod-falling-right.png",
1003 texture_load(&img_laptop_left[0], datadir + "/images/shared/mriceblock-left-0.png", USE_ALPHA);
1004 texture_load(&img_laptop_left[1], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1005 texture_load(&img_laptop_left[2], datadir + "/images/shared/mriceblock-left-2.png", USE_ALPHA);
1006 texture_load(&img_laptop_left[3], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1008 texture_load(&img_laptop_right[0], datadir + "/images/shared/mriceblock-right-0.png", USE_ALPHA);
1009 texture_load(&img_laptop_right[1], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1010 texture_load(&img_laptop_right[2], datadir + "/images/shared/mriceblock-right-2.png", USE_ALPHA);
1011 texture_load(&img_laptop_right[3], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1013 texture_load(&img_laptop_flat_left[0],
1014 datadir + "/images/shared/laptop-flat-left.png",
1017 texture_load(&img_laptop_flat_right[0], datadir +
1018 "/images/shared/laptop-flat-right.png",
1021 texture_load(&img_laptop_falling_left[0], datadir +
1022 "/images/shared/laptop-falling-left.png",
1025 texture_load(&img_laptop_falling_right[0], datadir +
1026 "/images/shared/laptop-falling-right.png",
1032 texture_load(&img_money_left[0], datadir +
1033 "/images/shared/bag-left-0.png",
1036 texture_load(&img_money_left[1], datadir +
1037 "/images/shared/bag-left-1.png",
1040 texture_load(&img_money_right[0], datadir +
1041 "/images/shared/bag-right-0.png",
1044 texture_load(&img_money_right[1], datadir +
1045 "/images/shared/bag-right-1.png",
1049 for(int i=0; i<4; ++i) {
1051 snprintf(num, 4, "%d", i);
1052 texture_load(&img_mrbomb_left[i],
1053 datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA);
1054 texture_load(&img_mrbomb_right[i],
1055 datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA);
1057 texture_load(&img_mrbomb_ticking_left[0],
1058 datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA);
1059 texture_load(&img_mrbomb_ticking_right[0],
1060 datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA);
1061 texture_load(&img_mrbomb_explosion[0],
1062 datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA);
1065 texture_load(&img_stalactite[0],
1066 datadir + "/images/shared/stalactite.png", USE_ALPHA);
1067 texture_load(&img_stalactite_broken[0],
1068 datadir + "/images/shared/stalactite-broken.png", USE_ALPHA);
1071 texture_load(&img_flame[0],
1072 datadir + "/images/shared/flame-0.png", USE_ALPHA);
1073 texture_load(&img_flame[1],
1074 datadir + "/images/shared/flame-1.png", USE_ALPHA);
1077 texture_load(&img_fish[0],
1078 datadir + "/images/shared/fish-left-0.png", USE_ALPHA);
1079 texture_load(&img_fish[1],
1080 datadir + "/images/shared/fish-left-1.png", USE_ALPHA);
1082 /* bouncing snowball */
1083 for(int i=0; i<6; ++i) {
1085 snprintf(num, 4, "%d", i);
1086 texture_load(&img_bouncingsnowball_left[i],
1087 datadir + "/images/shared/bouncingsnowball-left-" + num + ".png",
1089 texture_load(&img_bouncingsnowball_right[i],
1090 datadir + "/images/shared/bouncingsnowball-right-" + num + ".png",
1093 texture_load(&img_bouncingsnowball_squished[0],
1094 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1096 /* flying snowball */
1097 texture_load(&img_flyingsnowball[0],
1098 datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA);
1099 texture_load(&img_flyingsnowball[1],
1100 datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA);
1101 texture_load(&img_flyingsnowball_squished[0],
1102 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1105 for(int i = 0; i < 3; ++i) {
1107 snprintf(num, 4, "%d", i);
1108 texture_load(&img_spiky_left[i],
1109 datadir + "/images/shared/spiky-left-" + num + ".png",
1111 texture_load(&img_spiky_right[i],
1112 datadir + "/images/shared/spiky-right-" + num + ".png",
1117 texture_load(&img_snowball_left[0], datadir + "/images/shared/snowball-left-0.png", USE_ALPHA);
1118 texture_load(&img_snowball_left[1], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1119 texture_load(&img_snowball_left[2], datadir + "/images/shared/snowball-left-2.png", USE_ALPHA);
1120 texture_load(&img_snowball_left[3], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1122 texture_load(&img_snowball_right[0], datadir + "/images/shared/snowball-right-0.png", USE_ALPHA);
1123 texture_load(&img_snowball_right[1], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1124 texture_load(&img_snowball_right[2], datadir + "/images/shared/snowball-right-2.png", USE_ALPHA);
1125 texture_load(&img_snowball_right[3], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1127 texture_load(&img_snowball_squished_left[0],
1128 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1129 texture_load(&img_snowball_squished_right[0],
1130 datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA);
1133 void free_badguy_gfx()
1135 for (int i = 0; i < 4; i++)
1137 texture_free(&img_bsod_left[i]);
1138 texture_free(&img_bsod_right[i]);
1141 texture_free(&img_bsod_squished_left[0]);
1142 texture_free(&img_bsod_squished_right[0]);
1144 texture_free(&img_bsod_falling_left[0]);
1145 texture_free(&img_bsod_falling_right[0]);
1147 for (int i = 0; i < 4; i++)
1149 texture_free(&img_laptop_left[i]);
1150 texture_free(&img_laptop_right[i]);
1153 texture_free(&img_laptop_flat_left[0]);
1154 texture_free(&img_laptop_flat_right[0]);
1156 texture_free(&img_laptop_falling_left[0]);
1157 texture_free(&img_laptop_falling_right[0]);
1159 for (int i = 0; i < 2; i++)
1161 texture_free(&img_money_left[i]);
1162 texture_free(&img_money_right[i]);
1165 for(int i = 0; i < 4; i++) {
1166 texture_free(&img_mrbomb_left[i]);
1167 texture_free(&img_mrbomb_right[i]);
1170 texture_free(&img_mrbomb_ticking_left[0]);
1171 texture_free(&img_mrbomb_ticking_right[0]);
1172 texture_free(&img_mrbomb_explosion[0]);
1174 texture_free(&img_stalactite[0]);
1175 texture_free(&img_stalactite_broken[0]);
1177 texture_free(&img_flame[0]);
1178 texture_free(&img_flame[1]);
1180 texture_free(&img_fish[0]);
1181 texture_free(&img_fish[1]);
1183 for(int i=0; i<6; ++i) {
1184 texture_free(&img_bouncingsnowball_left[i]);
1185 texture_free(&img_bouncingsnowball_right[i]);
1187 texture_free(&img_bouncingsnowball_squished[0]);
1189 texture_free(&img_flyingsnowball[0]);
1190 texture_free(&img_flyingsnowball[1]);
1191 texture_free(&img_flyingsnowball_squished[0]);
1193 for(int i = 0; i<3; ++i) {
1194 texture_free(&img_spiky_left[i]);
1195 texture_free(&img_spiky_right[i]);
1197 for(int i = 0; i<4; ++i) {
1198 texture_free(&img_snowball_left[i]);
1199 texture_free(&img_snowball_right[i]);
1201 texture_free(&img_snowball_squished_left[0]);
1202 texture_free(&img_snowball_squished_right[0]);