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;
151 timer_init(&timer, true);
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()
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(&timer))
220 /* Remove it if time's up: */
226 physic.apply(base.x, base.y);
227 if(dying != DYING_FALLING)
228 collision_swept_object_map(&old_base, &base);
232 BadGuy::action_laptop()
234 Player& tux = *World::current()->get_tux();
238 /* Move left/right: */
239 if (mode == NORMAL || mode == KICK)
242 physic.apply(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! */
274 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
275 physic.set_velocity((dir == LEFT) ? -8 : 8, -8);
276 play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
283 check_horizontal_bump();
284 if(mode == KICK && changed != dir)
286 /* handle stereo sound (number 10 should be tweaked...)*/
287 if (base.x < scroll_x + screen->w/2 - 10)
288 play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
289 else if (base.x > scroll_x + screen->w/2 + 10)
290 play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
292 play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
296 /* Handle mode timer: */
299 if(!timer_check(&timer))
302 set_texture(img_laptop_left, img_laptop_right, 4, 5);
303 physic.set_velocity( (dir == LEFT) ? -1.3 : 1.3, 0);
309 BadGuy::check_horizontal_bump(bool checkcliff)
311 float halfheight = base.height / 2;
312 if (dir == LEFT && issolid( base.x, (int) base.y + halfheight))
315 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
318 if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight))
321 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
325 // don't check for cliffs when we're falling
328 if(!issolid(base.x + base.width/2, base.y + base.height))
331 if(dir == LEFT && !issolid(base.x, (int) base.y + base.height + halfheight))
334 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
337 if(dir == RIGHT && !issolid(base.x + base.width,
338 (int) base.y + base.height + halfheight))
341 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
349 /* Fall if we get off the ground: */
350 if (dying != DYING_FALLING)
352 if (!issolid(base.x+base.width/2, base.y + base.height))
354 // not solid below us? enable gravity
355 physic.enable_gravity(true);
360 if (physic.get_velocity_y() < 0)
362 base.y = int((base.y + base.height)/32) * 32 - base.height;
363 physic.set_velocity(physic.get_velocity_x(), 0);
365 // no gravity anymore please
366 physic.enable_gravity(false);
371 physic.enable_gravity(true);
378 for(std::vector<BadGuy>::iterator i = World::current()->bad_guys.begin();
379 i != World::current()->bad_guys.end(); ++i)
381 if( & (*i) == this) {
382 World::current()->bad_guys.erase(i);
389 BadGuy::action_money()
391 Player& tux = *World::current()->get_tux();
393 static const float JUMPV = 6;
396 // jump when on ground
397 if(dying == DYING_NOT && issolid(base.x, base.y+32))
399 physic.set_velocity(physic.get_velocity_x(), JUMPV);
400 physic.enable_gravity(true);
401 set_texture(&img_money_left[1], &img_money_right[1], 1);
404 else if(mode == MONEY_JUMP)
406 set_texture(&img_money_left[0], &img_money_right[0], 1);
410 // set direction based on tux
411 if(tux.base.x > base.x)
417 physic.apply(base.x, base.y);
418 if(dying == DYING_NOT)
419 collision_swept_object_map(&old_base, &base);
423 BadGuy::action_mrbomb()
425 if (dying == DYING_NOT)
426 check_horizontal_bump(true);
430 physic.apply(base.x, base.y);
431 if (dying != DYING_FALLING)
432 collision_swept_object_map(&old_base,&base);
436 BadGuy::action_bomb()
438 static const int TICKINGTIME = 1000;
439 static const int EXPLODETIME = 1000;
445 timer_start(&timer, TICKINGTIME);
446 } else if(!timer_check(&timer)) {
447 if(mode == BOMB_TICKING) {
449 set_texture(img_mrbomb_explosion, img_mrbomb_explosion, 1);
450 dying = DYING_NOT; // now the bomb hurts
451 timer_start(&timer, EXPLODETIME);
452 } else if(mode == BOMB_EXPLODE) {
459 physic.apply(base.x, base.y);
460 collision_swept_object_map(&old_base,&base);
464 BadGuy::action_stalactite()
466 Player& tux = *World::current()->get_tux();
468 static const int SHAKETIME = 800;
469 static const int RANGE = 40;
472 // start shaking when tux is below the stalactite and at least 40 pixels
474 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
475 && tux.base.y + tux.base.height > base.y) {
476 timer_start(&timer, SHAKETIME);
477 mode = STALACTITE_SHAKING;
479 } if(mode == STALACTITE_SHAKING) {
480 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
481 if(!timer_check(&timer)) {
482 mode = STALACTITE_FALL;
484 } else if(mode == STALACTITE_FALL) {
486 /* Destroy if we collides with land */
487 if(issolid(base.x+base.width/2, base.y+base.height))
489 timer_start(&timer, 2000);
490 dying = DYING_SQUISHED;
492 set_texture(img_stalactite_broken, img_stalactite_broken, 1);
494 } else if(mode == FLAT) {
499 physic.apply(base.x, base.y);
501 if(dying == DYING_SQUISHED && !timer_check(&timer))
506 BadGuy::action_flame()
508 static const float radius = 100;
509 static const float speed = 0.02;
510 base.x = old_base.x + cos(base.ym) * radius;
511 base.y = old_base.y + sin(base.ym) * radius;
513 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
517 BadGuy::action_fish()
519 static const float JUMPV = 6;
520 static const int WAITTIME = 1000;
522 // go in wait mode when back in water
523 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
524 && physic.get_velocity_y() <= 0 && mode == NORMAL)
528 physic.set_velocity(0, 0);
529 physic.enable_gravity(false);
530 timer_start(&timer, WAITTIME);
532 else if(mode == FISH_WAIT && !timer_check(&timer))
535 set_texture(img_fish, img_fish, 2, 1.5);
536 animation_offset = global_frame_counter; // restart animation
538 physic.set_velocity(0, JUMPV);
539 physic.enable_gravity(true);
542 physic.apply(base.x, base.y);
543 if(dying == DYING_NOT)
544 collision_swept_object_map(&old_base, &base);
548 BadGuy::action_bouncingsnowball()
550 static const float JUMPV = 4.5;
554 // jump when on ground
555 if(dying == DYING_NOT && issolid(base.x, base.y+32))
557 physic.set_velocity(physic.get_velocity_x(), JUMPV);
558 physic.enable_gravity(true);
565 // check for right/left collisions
566 check_horizontal_bump();
568 physic.apply(base.x, base.y);
569 if(dying == DYING_NOT)
570 collision_swept_object_map(&old_base, &base);
572 // Handle dying timer:
573 if (dying == DYING_SQUISHED && !timer_check(&timer))
575 /* Remove it if time's up: */
582 BadGuy::action_flyingsnowball()
584 static const float FLYINGSPEED = 1;
585 static const int DIRCHANGETIME = 1000;
587 // go into flyup mode if none specified yet
588 if(dying == DYING_NOT && mode == NORMAL) {
590 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
591 timer_start(&timer, DIRCHANGETIME/2);
594 if(dying == DYING_NOT && !timer_check(&timer)) {
597 physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED);
598 } else if(mode == FLY_DOWN) {
600 physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED);
602 timer_start(&timer, DIRCHANGETIME);
605 if(dying != DYING_NOT)
606 physic.enable_gravity(true);
608 physic.apply(base.x, base.y);
609 if(dying == DYING_NOT || dying == DYING_SQUISHED)
610 collision_swept_object_map(&old_base, &base);
612 // Handle dying timer:
613 if (dying == DYING_SQUISHED && !timer_check(&timer))
615 /* Remove it if time's up: */
622 BadGuy::action_spiky()
624 if (dying == DYING_NOT)
625 check_horizontal_bump();
629 // jump when we're about to fall
630 if (physic.get_velocity_y() == 0 &&
631 !issolid(base.x+base.width/2, base.y + base.height)) {
632 physic.enable_gravity(true);
633 physic.set_velocity(physic.get_velocity_x(), 2);
637 physic.apply(base.x, base.y);
638 if (dying != DYING_FALLING)
639 collision_swept_object_map(&old_base,&base);
643 BadGuy::action_snowball()
645 if (dying == DYING_NOT)
646 check_horizontal_bump();
650 physic.apply(base.x, base.y);
651 if (dying != DYING_FALLING)
652 collision_swept_object_map(&old_base,&base);
658 // Remove if it's far off the screen:
659 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
665 // BadGuy fall below the ground
666 if (base.y > screen->h) {
671 // Once it's on screen, it's activated!
672 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
712 case BAD_BOUNCINGSNOWBALL:
713 action_bouncingsnowball();
716 case BAD_FLYINGSNOWBALL:
717 action_flyingsnowball();
733 // Don't try to draw stuff that is outside of the screen
734 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
736 if(texture_left == 0 || texture_right == 0)
739 float global_frame = (float(global_frame_counter - animation_offset) / 10);
740 global_frame *= animation_speed;
741 size_t frame = size_t(global_frame) % animation_length;
742 texture_type* texture =
743 (dir == LEFT) ? &texture_left[frame] : &texture_right[frame];
744 texture_draw(texture, base.x - scroll_x, base.y);
748 BadGuy::set_texture(texture_type* left, texture_type* right,
749 int nanimlength, float nanimspeed)
752 if(base.width == 0 && base.height == 0) {
753 base.width = left->w;
754 base.height = left->h;
755 } else if(base.width != left->w || base.height != left->h) {
756 base.x -= (left->w - base.width) / 2;
757 base.y -= left->h - base.height;
758 base.width = left->w;
759 base.height = left->h;
763 base.width = base.height = 0;
766 animation_length = nanimlength;
767 animation_speed = nanimspeed;
768 animation_offset = 0;
770 texture_right = right;
776 if(kind == BAD_BSOD || kind == BAD_LAPTOP || kind == BAD_MRBOMB
777 || kind == BAD_BOUNCINGSNOWBALL) {
783 BadGuy::make_player_jump(Player* player)
785 player->physic.set_velocity(player->physic.get_velocity_x(), 2);
786 player->base.y = base.y - player->base.height - 2;
790 BadGuy::squish_me(Player* player)
792 make_player_jump(player);
794 World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
795 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
798 dying = DYING_SQUISHED;
799 timer_start(&timer, 2000);
800 physic.set_velocity(0, 0);
804 BadGuy::squish(Player* player)
806 if(kind == BAD_MRBOMB) {
807 // mrbomb transforms into a bomb now
808 World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
810 make_player_jump(player);
811 World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
812 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
818 } else if(kind == BAD_BSOD) {
820 set_texture(img_bsod_squished_left, img_bsod_squished_right, 1);
821 physic.set_velocity(0, physic.get_velocity_y());
824 } else if (kind == BAD_LAPTOP) {
825 if (mode == NORMAL || mode == KICK)
828 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
830 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
831 physic.set_velocity(0, physic.get_velocity_y());
833 timer_start(&timer, 4000);
834 } else if (mode == FLAT) {
836 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
838 if (player->base.x < base.x + (base.width/2)) {
839 physic.set_velocity(5, physic.get_velocity_y());
842 physic.set_velocity(-5, physic.get_velocity_y());
847 set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
850 make_player_jump(player);
852 World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
855 } else if(kind == BAD_FISH) {
856 make_player_jump(player);
858 World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
861 // simply remove the fish...
864 } else if(kind == BAD_BOUNCINGSNOWBALL) {
866 set_texture(img_bouncingsnowball_squished,img_bouncingsnowball_squished,1);
868 } else if(kind == BAD_FLYINGSNOWBALL) {
870 set_texture(img_flyingsnowball_squished,img_flyingsnowball_squished,1);
872 } else if(kind == BAD_SNOWBALL) {
874 set_texture(img_snowball_squished_left, img_snowball_squished_right, 1);
882 if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
885 dying = DYING_FALLING;
886 if(kind == BAD_LAPTOP)
887 set_texture(img_laptop_falling_left, img_laptop_falling_right, 1);
888 else if(kind == BAD_BSOD)
889 set_texture(img_bsod_falling_left, img_bsod_falling_right, 1);
891 physic.enable_gravity(true);
892 physic.set_velocity(physic.get_velocity_x(), 0);
894 /* Gain some points: */
895 if (kind == BAD_BSOD)
896 World::current()->add_score(base.x - scroll_x, base.y,
897 50 * score_multiplier);
899 World::current()->add_score(base.x - scroll_x, base.y,
900 25 * score_multiplier);
902 /* Play death sound: */
903 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
907 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
909 BadGuy* pbad_c = NULL;
911 if(type == COLLISION_BUMP) {
915 if(type == COLLISION_SQUISH) {
916 Player* player = static_cast<Player*>(p_c_object);
928 pbad_c = (BadGuy*) p_c_object;
929 if(kind == BAD_LAPTOP && mode == KICK &&
930 pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB)
932 /* We're in kick mode, kill the other guy
933 and yourself(wuahaha) : */
941 //---------------------------------------------------------------------------
943 void load_badguy_gfx()
946 texture_load(&img_bsod_left[0], datadir +
947 "/images/shared/bsod-left-0.png",
950 texture_load(&img_bsod_left[1], datadir +
951 "/images/shared/bsod-left-1.png",
954 texture_load(&img_bsod_left[2], datadir +
955 "/images/shared/bsod-left-2.png",
958 texture_load(&img_bsod_left[3], datadir +
959 "/images/shared/bsod-left-3.png",
962 texture_load(&img_bsod_right[0], datadir +
963 "/images/shared/bsod-right-0.png",
966 texture_load(&img_bsod_right[1], datadir +
967 "/images/shared/bsod-right-1.png",
970 texture_load(&img_bsod_right[2], datadir +
971 "/images/shared/bsod-right-2.png",
974 texture_load(&img_bsod_right[3], datadir +
975 "/images/shared/bsod-right-3.png",
978 texture_load(&img_bsod_squished_left[0], datadir +
979 "/images/shared/bsod-squished-left.png",
982 texture_load(&img_bsod_squished_right[0], datadir +
983 "/images/shared/bsod-squished-right.png",
986 texture_load(&img_bsod_falling_left[0], datadir +
987 "/images/shared/bsod-falling-left.png",
990 texture_load(&img_bsod_falling_right[0], datadir +
991 "/images/shared/bsod-falling-right.png",
997 texture_load(&img_laptop_left[0], datadir + "/images/shared/mriceblock-left-0.png", USE_ALPHA);
998 texture_load(&img_laptop_left[1], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
999 texture_load(&img_laptop_left[2], datadir + "/images/shared/mriceblock-left-2.png", USE_ALPHA);
1000 texture_load(&img_laptop_left[3], datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1002 texture_load(&img_laptop_right[0], datadir + "/images/shared/mriceblock-right-0.png", USE_ALPHA);
1003 texture_load(&img_laptop_right[1], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1004 texture_load(&img_laptop_right[2], datadir + "/images/shared/mriceblock-right-2.png", USE_ALPHA);
1005 texture_load(&img_laptop_right[3], datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1007 texture_load(&img_laptop_flat_left[0],
1008 datadir + "/images/shared/laptop-flat-left.png",
1011 texture_load(&img_laptop_flat_right[0], datadir +
1012 "/images/shared/laptop-flat-right.png",
1015 texture_load(&img_laptop_falling_left[0], datadir +
1016 "/images/shared/laptop-falling-left.png",
1019 texture_load(&img_laptop_falling_right[0], datadir +
1020 "/images/shared/laptop-falling-right.png",
1026 texture_load(&img_money_left[0], datadir +
1027 "/images/shared/bag-left-0.png",
1030 texture_load(&img_money_left[1], datadir +
1031 "/images/shared/bag-left-1.png",
1034 texture_load(&img_money_right[0], datadir +
1035 "/images/shared/bag-right-0.png",
1038 texture_load(&img_money_right[1], datadir +
1039 "/images/shared/bag-right-1.png",
1043 for(int i=0; i<4; ++i) {
1045 snprintf(num, 4, "%d", i);
1046 texture_load(&img_mrbomb_left[i],
1047 datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA);
1048 texture_load(&img_mrbomb_right[i],
1049 datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA);
1051 texture_load(&img_mrbomb_ticking_left[0],
1052 datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA);
1053 texture_load(&img_mrbomb_ticking_right[0],
1054 datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA);
1055 texture_load(&img_mrbomb_explosion[0],
1056 datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA);
1059 texture_load(&img_stalactite[0],
1060 datadir + "/images/shared/stalactite.png", USE_ALPHA);
1061 texture_load(&img_stalactite_broken[0],
1062 datadir + "/images/shared/stalactite-broken.png", USE_ALPHA);
1065 texture_load(&img_flame[0],
1066 datadir + "/images/shared/flame-0.png", USE_ALPHA);
1067 texture_load(&img_flame[1],
1068 datadir + "/images/shared/flame-1.png", USE_ALPHA);
1071 texture_load(&img_fish[0],
1072 datadir + "/images/shared/fish-left-0.png", USE_ALPHA);
1073 texture_load(&img_fish[1],
1074 datadir + "/images/shared/fish-left-1.png", USE_ALPHA);
1076 /* bouncing snowball */
1077 for(int i=0; i<6; ++i) {
1079 snprintf(num, 4, "%d", i);
1080 texture_load(&img_bouncingsnowball_left[i],
1081 datadir + "/images/shared/bouncingsnowball-left-" + num + ".png",
1083 texture_load(&img_bouncingsnowball_right[i],
1084 datadir + "/images/shared/bouncingsnowball-right-" + num + ".png",
1087 texture_load(&img_bouncingsnowball_squished[0],
1088 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1090 /* flying snowball */
1091 texture_load(&img_flyingsnowball[0],
1092 datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA);
1093 texture_load(&img_flyingsnowball[1],
1094 datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA);
1095 texture_load(&img_flyingsnowball_squished[0],
1096 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1099 for(int i = 0; i < 3; ++i) {
1101 snprintf(num, 4, "%d", i);
1102 texture_load(&img_spiky_left[i],
1103 datadir + "/images/shared/spiky-left-" + num + ".png",
1105 texture_load(&img_spiky_right[i],
1106 datadir + "/images/shared/spiky-right-" + num + ".png",
1111 texture_load(&img_snowball_left[0], datadir + "/images/shared/snowball-left-0.png", USE_ALPHA);
1112 texture_load(&img_snowball_left[1], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1113 texture_load(&img_snowball_left[2], datadir + "/images/shared/snowball-left-2.png", USE_ALPHA);
1114 texture_load(&img_snowball_left[3], datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1116 texture_load(&img_snowball_right[0], datadir + "/images/shared/snowball-right-0.png", USE_ALPHA);
1117 texture_load(&img_snowball_right[1], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1118 texture_load(&img_snowball_right[2], datadir + "/images/shared/snowball-right-2.png", USE_ALPHA);
1119 texture_load(&img_snowball_right[3], datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1121 texture_load(&img_snowball_squished_left[0],
1122 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1123 texture_load(&img_snowball_squished_right[0],
1124 datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA);
1127 void free_badguy_gfx()
1129 for (int i = 0; i < 4; i++)
1131 texture_free(&img_bsod_left[i]);
1132 texture_free(&img_bsod_right[i]);
1135 texture_free(&img_bsod_squished_left[0]);
1136 texture_free(&img_bsod_squished_right[0]);
1138 texture_free(&img_bsod_falling_left[0]);
1139 texture_free(&img_bsod_falling_right[0]);
1141 for (int i = 0; i < 4; i++)
1143 texture_free(&img_laptop_left[i]);
1144 texture_free(&img_laptop_right[i]);
1147 texture_free(&img_laptop_flat_left[0]);
1148 texture_free(&img_laptop_flat_right[0]);
1150 texture_free(&img_laptop_falling_left[0]);
1151 texture_free(&img_laptop_falling_right[0]);
1153 for (int i = 0; i < 2; i++)
1155 texture_free(&img_money_left[i]);
1156 texture_free(&img_money_right[i]);
1159 for(int i = 0; i < 4; i++) {
1160 texture_free(&img_mrbomb_left[i]);
1161 texture_free(&img_mrbomb_right[i]);
1164 texture_free(&img_mrbomb_ticking_left[0]);
1165 texture_free(&img_mrbomb_ticking_right[0]);
1166 texture_free(&img_mrbomb_explosion[0]);
1168 texture_free(&img_stalactite[0]);
1169 texture_free(&img_stalactite_broken[0]);
1171 texture_free(&img_flame[0]);
1172 texture_free(&img_flame[1]);
1174 texture_free(&img_fish[0]);
1175 texture_free(&img_fish[1]);
1177 for(int i=0; i<6; ++i) {
1178 texture_free(&img_bouncingsnowball_left[i]);
1179 texture_free(&img_bouncingsnowball_right[i]);
1181 texture_free(&img_bouncingsnowball_squished[0]);
1183 texture_free(&img_flyingsnowball[0]);
1184 texture_free(&img_flyingsnowball[1]);
1185 texture_free(&img_flyingsnowball_squished[0]);
1187 for(int i = 0; i<3; ++i) {
1188 texture_free(&img_spiky_left[i]);
1189 texture_free(&img_spiky_right[i]);
1191 for(int i = 0; i<4; ++i) {
1192 texture_free(&img_snowball_left[i]);
1193 texture_free(&img_snowball_right[i]);
1195 texture_free(&img_snowball_squished_left[0]);
1196 texture_free(&img_snowball_squished_right[0]);