4 // Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
5 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
6 // Copyright (C) 2004 Matthias Braun <matze@braunis.de>
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #include "resources.h"
34 #include "sprite_manager.h"
36 Sprite* img_bsod_squished_left;
37 Sprite* img_bsod_squished_right;
38 Sprite* img_bsod_falling_left;
39 Sprite* img_bsod_falling_right;
40 Sprite* img_laptop_flat_left;
41 Sprite* img_laptop_flat_right;
42 Sprite* img_laptop_falling_left;
43 Sprite* img_laptop_falling_right;
44 Sprite* img_bsod_left;
45 Sprite* img_bsod_right;
46 Sprite* img_laptop_left;
47 Sprite* img_laptop_right;
48 Sprite* img_jumpy_left_up;
49 Sprite* img_jumpy_left_down;
50 Sprite* img_jumpy_left_middle;
51 Sprite* img_mrbomb_left;
52 Sprite* img_mrbomb_right;
53 Sprite* img_mrbomb_ticking_left;
54 Sprite* img_mrbomb_ticking_right;
55 Sprite* img_mrbomb_explosion;
56 Sprite* img_stalactite;
57 Sprite* img_stalactite_broken;
60 Sprite* img_fish_down;
61 Sprite* img_bouncingsnowball_left;
62 Sprite* img_bouncingsnowball_right;
63 Sprite* img_bouncingsnowball_squished;
64 Sprite* img_flyingsnowball;
65 Sprite* img_flyingsnowball_squished;
66 Sprite* img_spiky_left;
67 Sprite* img_spiky_right;
68 Sprite* img_snowball_left;
69 Sprite* img_snowball_right;
70 Sprite* img_snowball_squished_left;
71 Sprite* img_snowball_squished_right;
73 BadGuyKind badguykind_from_string(const std::string& str)
77 else if (str == "laptop" || str == "mriceblock")
79 else if (str == "bsod")
81 else if (str == "mrbomb")
83 else if (str == "stalactite")
84 return BAD_STALACTITE;
85 else if (str == "flame")
87 else if (str == "fish")
89 else if (str == "bouncingsnowball")
90 return BAD_BOUNCINGSNOWBALL;
91 else if (str == "flyingsnowball")
92 return BAD_FLYINGSNOWBALL;
93 else if (str == "spiky")
95 else if (str == "snowball")
99 printf("Couldn't convert badguy: '%s'\n", str.c_str());
104 std::string badguykind_to_string(BadGuyKind kind)
129 case BAD_BOUNCINGSNOWBALL:
130 return "bouncingsnowball";
132 case BAD_FLYINGSNOWBALL:
133 return "flyingsnowball";
147 BadGuy::init(float x, float y, BadGuyKind kind_, bool stay_on_platform_)
156 stay_on_platform = stay_on_platform_;
163 animation_offset = 0;
164 sprite_left = sprite_right = 0;
168 if(kind == BAD_BSOD) {
169 physic.set_velocity(-1.3, 0);
170 set_sprite(img_bsod_left, img_bsod_right);
171 } else if(kind == BAD_MRBOMB) {
172 physic.set_velocity(-1.3, 0);
173 set_sprite(img_mrbomb_left, img_mrbomb_right);
174 } else if (kind == BAD_LAPTOP) {
175 physic.set_velocity(-.8, 0);
176 set_sprite(img_laptop_left, img_laptop_right);
177 } else if(kind == BAD_MONEY) {
178 set_sprite(img_jumpy_left_up, img_jumpy_left_up);
179 } else if(kind == BAD_BOMB) {
180 set_sprite(img_mrbomb_ticking_left, img_mrbomb_ticking_right);
181 // hack so that the bomb doesn't hurt until it expldes...
182 dying = DYING_SQUISHED;
183 } else if(kind == BAD_FLAME) {
184 base.ym = 0; // we misuse base.ym as angle for the flame
185 physic.enable_gravity(false);
186 set_sprite(img_flame, img_flame);
187 } else if(kind == BAD_BOUNCINGSNOWBALL) {
188 physic.set_velocity(-1.3, 0);
189 set_sprite(img_bouncingsnowball_left, img_bouncingsnowball_right);
190 } else if(kind == BAD_STALACTITE) {
191 physic.enable_gravity(false);
192 set_sprite(img_stalactite, img_stalactite);
193 } else if(kind == BAD_FISH) {
194 set_sprite(img_fish, img_fish);
195 physic.enable_gravity(true);
196 } else if(kind == BAD_FLYINGSNOWBALL) {
197 set_sprite(img_flyingsnowball, img_flyingsnowball);
198 physic.enable_gravity(false);
199 } else if(kind == BAD_SPIKY) {
200 physic.set_velocity(-1.3, 0);
201 set_sprite(img_spiky_left, img_spiky_right);
202 } else if(kind == BAD_SNOWBALL) {
203 physic.set_velocity(-1.3, 0);
204 set_sprite(img_snowball_left, img_snowball_right);
207 // if we're in a solid tile at start correct that now
208 if(kind != BAD_FLAME && kind != BAD_FISH && collision_object_map(&base)) {
209 printf("Warning: badguy started in wall!.\n");
210 while(collision_object_map(&base))
216 BadGuy::action_bsod(float frame_ratio)
218 static const float BSODJUMP = 2;
220 if (dying == DYING_NOT)
221 check_horizontal_bump();
225 // jump when we're about to fall
226 if (physic.get_velocity_y() == 0 &&
227 !issolid(base.x+base.width/2, base.y + base.height))
229 physic.enable_gravity(true);
230 physic.set_velocity(physic.get_velocity_x(), BSODJUMP);
233 // Handle dying timer:
234 if (dying == DYING_SQUISHED && !timer.check())
236 /* Remove it if time's up: */
242 physic.apply(frame_ratio, base.x, base.y);
243 if(dying != DYING_FALLING)
244 collision_swept_object_map(&old_base, &base);
248 BadGuy::action_laptop(float frame_ratio)
250 Player& tux = *World::current()->get_tux();
252 if(dying == DYING_NOT)
255 /* Move left/right: */
256 if (mode == NORMAL || mode == KICK)
259 physic.apply(frame_ratio, base.x, base.y);
260 if (dying != DYING_FALLING)
261 collision_swept_object_map(&old_base,&base);
263 else if (mode == HELD)
264 { /* FIXME: The pbad object shouldn't know about pplayer objects. */
265 /* If we're holding the laptop */
269 base.x = tux.base.x + 16;
270 base.y = tux.base.y + tux.base.height/1.5 - base.height;
272 else /* facing left */
274 base.x = tux.base.x - 16;
275 base.y = tux.base.y + tux.base.height/1.5 - base.height;
277 if(collision_object_map(&base))
280 base.y = tux.base.y + tux.base.height/1.5 - base.height;
283 if(tux.input.fire != DOWN) /* SHOOT! */
292 set_sprite(img_laptop_flat_left, img_laptop_flat_right);
293 physic.set_velocity_x((dir == LEFT) ? -3.5 : 3.5);
294 play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
301 check_horizontal_bump();
302 if(mode == KICK && changed != dir)
304 /* handle stereo sound (number 10 should be tweaked...)*/
305 if (base.x < scroll_x + screen->w/2 - 10)
306 play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
307 else if (base.x > scroll_x + screen->w/2 + 10)
308 play_sound(sounds[SND_RICOCHET], SOUND_RIGHT_SPEAKER);
310 play_sound(sounds[SND_RICOCHET], SOUND_CENTER_SPEAKER);
314 /* Handle mode timer: */
320 set_sprite(img_laptop_left, img_laptop_right);
321 physic.set_velocity( (dir == LEFT) ? -.8 : .8, 0);
327 BadGuy::check_horizontal_bump(bool checkcliff)
329 float halfheight = base.height / 2;
330 if (dir == LEFT && issolid( base.x, (int) base.y + halfheight))
333 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
336 if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight))
339 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
343 // don't check for cliffs when we're falling
346 if(!issolid(base.x + base.width/2, base.y + base.height))
349 if(dir == LEFT && !issolid(base.x, (int) base.y + base.height + halfheight))
352 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
355 if(dir == RIGHT && !issolid(base.x + base.width,
356 (int) base.y + base.height + halfheight))
359 physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y());
367 /* Fall if we get off the ground: */
368 if (dying != DYING_FALLING)
370 if (!issolid(base.x+base.width/2, base.y + base.height))
372 // not solid below us? enable gravity
373 physic.enable_gravity(true);
378 if (physic.get_velocity_y() < 0)
380 base.y = int((base.y + base.height)/32) * 32 - base.height;
381 physic.set_velocity_y(0);
383 // no gravity anymore please
384 physic.enable_gravity(false);
386 if (stay_on_platform && mode == NORMAL)
388 if (!issolid(base.x + ((dir == LEFT) ? 0 : base.width),
389 base.y + base.height))
391 physic.set_velocity_x(-physic.get_velocity_x());
402 physic.enable_gravity(true);
409 for(std::vector<BadGuy>::iterator i = World::current()->bad_guys.begin();
410 i != World::current()->bad_guys.end(); ++i)
412 if( & (*i) == this) {
413 World::current()->bad_guys.erase(i);
420 BadGuy::action_money(float frame_ratio)
422 if (fabsf(physic.get_velocity_y()) < 2.5f)
423 set_sprite(img_jumpy_left_middle, img_jumpy_left_middle);
424 else if (physic.get_velocity_y() < 0)
425 set_sprite(img_jumpy_left_up, img_jumpy_left_up);
427 set_sprite(img_jumpy_left_down, img_jumpy_left_down);
429 Player& tux = *World::current()->get_tux();
431 static const float JUMPV = 6;
434 // jump when on ground
435 if(dying == DYING_NOT && issolid(base.x, base.y+32))
437 physic.set_velocity_y(JUMPV);
438 physic.enable_gravity(true);
442 else if(mode == MONEY_JUMP)
447 // set direction based on tux
448 if(tux.base.x > base.x)
454 physic.apply(frame_ratio, base.x, base.y);
455 if(dying == DYING_NOT)
456 collision_swept_object_map(&old_base, &base);
460 BadGuy::action_mrbomb(float frame_ratio)
462 if (dying == DYING_NOT)
463 check_horizontal_bump(true);
467 physic.apply(frame_ratio, base.x, base.y);
468 if (dying != DYING_FALLING)
469 collision_swept_object_map(&old_base,&base);
473 BadGuy::action_bomb(float frame_ratio)
475 static const int TICKINGTIME = 1000;
476 static const int EXPLODETIME = 1000;
482 timer.start(TICKINGTIME);
483 } else if(!timer.check()) {
484 if(mode == BOMB_TICKING) {
486 set_sprite(img_mrbomb_explosion, img_mrbomb_explosion);
487 dying = DYING_NOT; // now the bomb hurts
488 timer.start(EXPLODETIME);
489 } else if(mode == BOMB_EXPLODE) {
496 physic.apply(frame_ratio, base.x, base.y);
497 collision_swept_object_map(&old_base,&base);
501 BadGuy::action_stalactite(float frame_ratio)
503 Player& tux = *World::current()->get_tux();
505 static const int SHAKETIME = 800;
506 static const int RANGE = 40;
509 // start shaking when tux is below the stalactite and at least 40 pixels
511 if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE
512 && tux.base.y + tux.base.height > base.y) {
513 timer.start(SHAKETIME);
514 mode = STALACTITE_SHAKING;
516 } if(mode == STALACTITE_SHAKING) {
517 base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer...
519 mode = STALACTITE_FALL;
521 } else if(mode == STALACTITE_FALL) {
523 /* Destroy if we collides with land */
524 if(issolid(base.x+base.width/2, base.y+base.height))
527 dying = DYING_SQUISHED;
529 set_sprite(img_stalactite_broken, img_stalactite_broken);
531 } else if(mode == FLAT) {
536 physic.apply(frame_ratio, base.x, base.y);
538 if(dying == DYING_SQUISHED && !timer.check())
543 BadGuy::action_flame(float frame_ratio)
545 static const float radius = 100;
546 static const float speed = 0.02;
547 base.x = old_base.x + cos(base.ym) * radius;
548 base.y = old_base.y + sin(base.ym) * radius;
550 base.ym = fmodf(base.ym + frame_ratio * speed, 2*M_PI);
554 BadGuy::action_fish(float frame_ratio)
556 static const float JUMPV = 6;
557 static const int WAITTIME = 1000;
559 // go in wait mode when back in water
560 if(dying == DYING_NOT && gettile(base.x, base.y+ base.height)->water
561 && physic.get_velocity_y() <= 0 && mode == NORMAL)
565 physic.set_velocity(0, 0);
566 physic.enable_gravity(false);
567 timer.start(WAITTIME);
569 else if(mode == FISH_WAIT && !timer.check())
572 set_sprite(img_fish, img_fish);
574 physic.set_velocity(0, JUMPV);
575 physic.enable_gravity(true);
578 physic.apply(frame_ratio, base.x, base.y);
579 if(dying == DYING_NOT)
580 collision_swept_object_map(&old_base, &base);
582 if(physic.get_velocity_y() < 0)
583 set_sprite(img_fish_down, img_fish_down);
587 BadGuy::action_bouncingsnowball(float frame_ratio)
589 static const float JUMPV = 4.5;
593 // jump when on ground
594 if(dying == DYING_NOT && issolid(base.x, base.y+32))
596 physic.set_velocity_y(JUMPV);
597 physic.enable_gravity(true);
604 // check for right/left collisions
605 check_horizontal_bump();
607 physic.apply(frame_ratio, base.x, base.y);
608 if(dying == DYING_NOT)
609 collision_swept_object_map(&old_base, &base);
611 // Handle dying timer:
612 if (dying == DYING_SQUISHED && !timer.check())
614 /* Remove it if time's up: */
621 BadGuy::action_flyingsnowball(float frame_ratio)
623 static const float FLYINGSPEED = 1;
624 static const int DIRCHANGETIME = 1000;
626 // go into flyup mode if none specified yet
627 if(dying == DYING_NOT && mode == NORMAL) {
629 physic.set_velocity_y(FLYINGSPEED);
630 timer.start(DIRCHANGETIME/2);
633 if(dying == DYING_NOT && !timer.check()) {
636 physic.set_velocity_y(-FLYINGSPEED);
637 } else if(mode == FLY_DOWN) {
639 physic.set_velocity_y(FLYINGSPEED);
641 timer.start(DIRCHANGETIME);
644 if(dying != DYING_NOT)
645 physic.enable_gravity(true);
647 physic.apply(frame_ratio, base.x, base.y);
648 if(dying == DYING_NOT || dying == DYING_SQUISHED)
649 collision_swept_object_map(&old_base, &base);
651 // Handle dying timer:
652 if (dying == DYING_SQUISHED && !timer.check())
654 /* Remove it if time's up: */
661 BadGuy::action_spiky(float frame_ratio)
663 if (dying == DYING_NOT)
664 check_horizontal_bump();
668 // jump when we're about to fall
669 if (physic.get_velocity_y() == 0 &&
670 !issolid(base.x+base.width/2, base.y + base.height)) {
671 physic.enable_gravity(true);
672 physic.set_velocity_y(2);
676 physic.apply(frame_ratio, base.x, base.y);
677 if (dying != DYING_FALLING)
678 collision_swept_object_map(&old_base,&base);
682 BadGuy::action_snowball(float frame_ratio)
684 if (dying == DYING_NOT)
685 check_horizontal_bump();
689 physic.apply(frame_ratio, base.x, base.y);
690 if (dying != DYING_FALLING)
691 collision_swept_object_map(&old_base,&base);
695 BadGuy::action(float frame_ratio)
697 // Remove if it's far off the screen:
698 if (base.x < scroll_x - OFFSCREEN_DISTANCE)
704 // BadGuy fall below the ground
705 if (base.y > screen->h) {
710 // Once it's on screen, it's activated!
711 if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
720 action_bsod(frame_ratio);
724 action_laptop(frame_ratio);
728 action_money(frame_ratio);
732 action_mrbomb(frame_ratio);
736 action_bomb(frame_ratio);
740 action_stalactite(frame_ratio);
744 action_flame(frame_ratio);
748 action_fish(frame_ratio);
751 case BAD_BOUNCINGSNOWBALL:
752 action_bouncingsnowball(frame_ratio);
755 case BAD_FLYINGSNOWBALL:
756 action_flyingsnowball(frame_ratio);
760 action_spiky(frame_ratio);
764 action_snowball(frame_ratio);
772 // Don't try to draw stuff that is outside of the screen
773 if(base.x <= scroll_x - base.width || base.x >= scroll_x + screen->w)
776 if(sprite_left == 0 || sprite_right == 0)
781 Sprite* sprite = (dir == LEFT) ? sprite_left : sprite_right;
782 sprite->draw(base.x - scroll_x, base.y);
785 fillrect(base.x - scroll_x, base.y, base.width, base.height, 75,0,75, 150);
789 BadGuy::set_sprite(Sprite* left, Sprite* right)
798 // FIXME: Using the image size for the physics and collision is
799 // a bad idea, since images should always overlap there physical
802 if(base.width == 0 && base.height == 0) {
803 base.width = left->get_width();
804 base.height = left->get_height();
805 } else if(base.width != left->get_width() || base.height != left->get_height()) {
806 base.x -= (left->get_width() - base.width) / 2;
807 base.y -= left->get_height() - base.height;
808 base.width = left->get_width();
809 base.height = left->get_height();
813 base.width = base.height = 0;
817 animation_offset = 0;
819 sprite_right = right;
825 if(kind == BAD_BSOD || kind == BAD_LAPTOP || kind == BAD_MRBOMB
826 || kind == BAD_BOUNCINGSNOWBALL) {
832 BadGuy::make_player_jump(Player* player)
834 player->physic.set_velocity_y(2);
835 player->base.y = base.y - player->base.height - 2;
839 BadGuy::squish_me(Player* player)
841 make_player_jump(player);
843 World::current()->add_score(base.x - scroll_x,
844 base.y, 50 * player_status.score_multiplier);
845 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
846 player_status.score_multiplier++;
848 dying = DYING_SQUISHED;
850 physic.set_velocity(0, 0);
854 BadGuy::squish(Player* player)
856 if(kind == BAD_MRBOMB) {
857 // mrbomb transforms into a bomb now
858 World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
860 make_player_jump(player);
861 World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier);
862 play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
863 player_status.score_multiplier++;
868 } else if(kind == BAD_BSOD) {
870 set_sprite(img_bsod_squished_left, img_bsod_squished_right);
871 physic.set_velocity_x(0);
874 } else if (kind == BAD_LAPTOP) {
875 if (mode == NORMAL || mode == KICK)
878 play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
880 set_sprite(img_laptop_flat_left, img_laptop_flat_right);
881 physic.set_velocity_x(0);
884 } else if (mode == FLAT) {
886 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
888 if (player->base.x < base.x + (base.width/2)) {
889 physic.set_velocity_x(5);
892 physic.set_velocity_x(-5);
897 set_sprite(img_laptop_flat_left, img_laptop_flat_right);
900 make_player_jump(player);
902 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
903 player_status.score_multiplier++;
905 } else if(kind == BAD_FISH) {
906 // fish can only be killed when falling down
907 if(physic.get_velocity_y() >= 0)
910 make_player_jump(player);
912 World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
913 player_status.score_multiplier++;
915 // simply remove the fish...
918 } else if(kind == BAD_BOUNCINGSNOWBALL) {
920 set_sprite(img_bouncingsnowball_squished,img_bouncingsnowball_squished);
922 } else if(kind == BAD_FLYINGSNOWBALL) {
924 set_sprite(img_flyingsnowball_squished,img_flyingsnowball_squished);
926 } else if(kind == BAD_SNOWBALL) {
928 set_sprite(img_snowball_squished_left, img_snowball_squished_right);
936 if(kind == BAD_BOMB || kind == BAD_STALACTITE || kind == BAD_FLAME)
939 dying = DYING_FALLING;
940 if(kind == BAD_LAPTOP)
941 set_sprite(img_laptop_falling_left, img_laptop_falling_right);
942 else if(kind == BAD_BSOD)
943 set_sprite(img_bsod_falling_left, img_bsod_falling_right);
945 physic.enable_gravity(true);
946 physic.set_velocity_y(0);
948 /* Gain some points: */
949 if (kind == BAD_BSOD)
950 World::current()->add_score(base.x - scroll_x, base.y,
951 50 * player_status.score_multiplier);
953 World::current()->add_score(base.x - scroll_x, base.y,
954 25 * player_status.score_multiplier);
956 /* Play death sound: */
957 play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
961 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
963 BadGuy* pbad_c = NULL;
965 if(type == COLLISION_BUMP) {
969 if(type == COLLISION_SQUISH) {
970 Player* player = static_cast<Player*>(p_c_object);
975 /* COLLISION_NORMAL */
983 pbad_c = (BadGuy*) p_c_object;
985 /* If we're a kicked mriceblock, kill any badguys we hit */
986 if(kind == BAD_LAPTOP && mode == KICK &&
987 pbad_c->kind != BAD_FLAME && pbad_c->kind != BAD_BOMB)
992 /* Kill badguys that run into exploding bomb */
993 else if (kind == BAD_BOMB && dying == DYING_NOT)
995 if (pbad_c->kind == BAD_MRBOMB)
997 // FIXME: this is where other MrBombs *should* explode istead of dying
1000 else if (pbad_c->kind != BAD_BOMB)
1006 /* Kill any badguys that get hit by stalactite */
1007 else if (kind == BAD_STALACTITE && dying == DYING_NOT)
1012 /* When enemies run into eachother, make them change directions */
1015 // Jumpy is an exception
1016 if (pbad_c->kind == BAD_MONEY)
1019 // Bounce off of other badguy if we land on top of him
1020 if (base.y + base.height < pbad_c->base.y + pbad_c->base.height)
1022 Direction old_dir = dir;
1023 if (pbad_c->dir == LEFT)
1025 else if (pbad_c->dir == RIGHT)
1029 physic.inverse_velocity_x();
1031 physic.set_velocity(fabs(physic.get_velocity_x()), 2);
1035 else if (base.y + base.height > pbad_c->base.y + pbad_c->base.height)
1040 else if (dir == RIGHT)
1043 physic.inverse_velocity_x();
1049 Player* player = static_cast<Player*>(p_c_object);
1050 /* Get kicked if were flat */
1051 if (mode == FLAT && !dying)
1053 play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
1055 // Hit from left side
1056 if (player->base.x < base.x) {
1057 physic.set_velocity_x(5);
1060 // Hit from right side
1062 physic.set_velocity_x(-5);
1067 set_sprite(img_laptop_flat_left, img_laptop_flat_right);
1074 //---------------------------------------------------------------------------
1076 void load_badguy_gfx()
1078 img_bsod_squished_left = sprite_manager->load("bsod-squished-left");
1079 img_bsod_squished_right = sprite_manager->load("bsod-squished-right");
1080 img_bsod_falling_left = sprite_manager->load("bsod-falling-left");
1081 img_bsod_falling_right = sprite_manager->load("bsod-falling-right");
1082 img_laptop_flat_left = sprite_manager->load("laptop-flat-left");
1083 img_laptop_flat_right = sprite_manager->load("laptop-flat-right");
1084 img_laptop_falling_left = sprite_manager->load("laptop-falling-left");
1085 img_laptop_falling_right = sprite_manager->load("laptop-falling-right");
1086 img_bsod_left = sprite_manager->load("bsod-left");
1087 img_bsod_right = sprite_manager->load("bsod-right");
1088 img_laptop_left = sprite_manager->load("laptop-left");
1089 img_laptop_right = sprite_manager->load("laptop-right");
1090 img_jumpy_left_up = sprite_manager->load("jumpy-left-up");
1091 img_jumpy_left_down = sprite_manager->load("jumpy-left-down");
1092 img_jumpy_left_middle = sprite_manager->load("jumpy-left-middle");
1093 img_mrbomb_left = sprite_manager->load("mrbomb-left");
1094 img_mrbomb_right = sprite_manager->load("mrbomb-right");
1095 img_mrbomb_ticking_left = sprite_manager->load("mrbomb-ticking-left");
1096 img_mrbomb_ticking_right = sprite_manager->load("mrbomb-ticking-right");
1097 img_mrbomb_explosion = sprite_manager->load("mrbomb-explosion");
1098 img_stalactite = sprite_manager->load("stalactite");
1099 img_stalactite_broken = sprite_manager->load("stalactite-broken");
1100 img_flame = sprite_manager->load("flame");
1101 img_fish = sprite_manager->load("fish");
1102 img_fish_down = sprite_manager->load("fish-down");
1103 img_bouncingsnowball_left = sprite_manager->load("bouncingsnowball-left");
1104 img_bouncingsnowball_right = sprite_manager->load("bouncingsnowball-right");
1105 img_bouncingsnowball_squished = sprite_manager->load("bouncingsnowball-squished");
1106 img_flyingsnowball = sprite_manager->load("flyingsnowball");
1107 img_flyingsnowball_squished = sprite_manager->load("flyingsnowball-squished");
1108 img_spiky_left = sprite_manager->load("spiky-left");
1109 img_spiky_right = sprite_manager->load("spiky-right");
1110 img_snowball_left = sprite_manager->load("snowball-left");
1111 img_snowball_right = sprite_manager->load("snowball-right");
1112 img_snowball_squished_left = sprite_manager->load("snowball-squished-left");
1113 img_snowball_squished_right = sprite_manager->load("snowball-squished-right");
1116 img_bsod_left[0] = new Surface(datadir + "/images/shared/bsod-left-0.png", USE_ALPHA);
1118 img_bsod_left[1] = new Surface(datadir +
1119 "/images/shared/bsod-left-1.png",
1122 img_bsod_left[2] = new Surface(datadir +
1123 "/images/shared/bsod-left-2.png",
1126 img_bsod_left[3] = new Surface(datadir +
1127 "/images/shared/bsod-left-3.png",
1130 img_bsod_right[0] = new Surface(datadir +
1131 "/images/shared/bsod-right-0.png",
1134 img_bsod_right[1] = new Surface(datadir +
1135 "/images/shared/bsod-right-1.png",
1138 img_bsod_right[2] = new Surface(datadir +
1139 "/images/shared/bsod-right-2.png",
1142 img_bsod_right[3] = new Surface(datadir +
1143 "/images/shared/bsod-right-3.png",
1146 img_bsod_squished_left[0] = new Surface(datadir +
1147 "/images/shared/bsod-squished-left.png",
1150 img_bsod_squished_right[0] = new Surface(datadir +
1151 "/images/shared/bsod-squished-right.png",
1154 img_bsod_falling_left[0] = new Surface(datadir +
1155 "/images/shared/bsod-falling-left.png",
1158 img_bsod_falling_right[0] = new Surface(datadir +
1159 "/images/shared/bsod-falling-right.png",
1165 img_laptop_left[0] = new Surface(datadir + "/images/shared/mriceblock-left-0.png", USE_ALPHA);
1166 img_laptop_left[1] = new Surface(datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1167 img_laptop_left[2] = new Surface(datadir + "/images/shared/mriceblock-left-2.png", USE_ALPHA);
1168 img_laptop_left[3] = new Surface(datadir + "/images/shared/mriceblock-left-1.png", USE_ALPHA);
1170 img_laptop_right[0] = new Surface(datadir + "/images/shared/mriceblock-right-0.png", USE_ALPHA);
1171 img_laptop_right[1] = new Surface(datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1172 img_laptop_right[2] = new Surface(datadir + "/images/shared/mriceblock-right-2.png", USE_ALPHA);
1173 img_laptop_right[3] = new Surface(datadir + "/images/shared/mriceblock-right-1.png", USE_ALPHA);
1175 img_laptop_flat_left[0] = new Surface(
1176 datadir + "/images/shared/laptop-flat-left.png",
1179 img_laptop_flat_right[0] = new Surface(datadir +
1180 "/images/shared/laptop-flat-right.png",
1183 img_laptop_falling_left[0] = new Surface(datadir +
1184 "/images/shared/laptop-falling-left.png",
1187 img_laptop_falling_right[0] = new Surface(datadir +
1188 "/images/shared/laptop-falling-right.png",
1193 img_jumpy_left_up = new Surface(datadir +
1194 "/images/shared/jumpy-left-up-0.png",
1196 img_jumpy_left_down = new Surface(datadir +
1197 "/images/shared/jumpy-left-down-0.png",
1199 img_jumpy_left_middle = new Surface(datadir +
1200 "/images/shared/jumpy-left-middle-0.png",
1204 for(int i=0; i<4; ++i) {
1206 snprintf(num, 4, "%d", i);
1207 img_mrbomb_left[i] = new Surface(
1208 datadir + "/images/shared/mrbomb-left-" + num + ".png", USE_ALPHA);
1209 img_mrbomb_right[i] = new Surface(
1210 datadir + "/images/shared/mrbomb-right-" + num + ".png", USE_ALPHA);
1212 img_mrbomb_ticking_left[0] = new Surface(
1213 datadir + "/images/shared/mrbombx-left-0.png", USE_ALPHA);
1214 img_mrbomb_ticking_right[0] = new Surface(
1215 datadir + "/images/shared/mrbombx-right-0.png", USE_ALPHA);
1216 img_mrbomb_explosion[0] = new Surface(
1217 datadir + "/images/shared/mrbomb-explosion.png", USE_ALPHA);
1220 img_stalactite[0] = new Surface(
1221 datadir + "/images/shared/stalactite.png", USE_ALPHA);
1222 img_stalactite_broken[0] = new Surface(
1223 datadir + "/images/shared/stalactite-broken.png", USE_ALPHA);
1226 img_flame[0] = new Surface(
1227 datadir + "/images/shared/flame-0.png", USE_ALPHA);
1228 img_flame[1] = new Surface(
1229 datadir + "/images/shared/flame-1.png", USE_ALPHA);
1232 img_fish[0] = new Surface(
1233 datadir + "/images/shared/fish-left-0.png", USE_ALPHA);
1234 img_fish[1] = new Surface(
1235 datadir + "/images/shared/fish-left-1.png", USE_ALPHA);
1236 img_fish_down[0] = new Surface(
1237 datadir + "/images/shared/fish-down-0.png", USE_ALPHA);
1239 /* bouncing snowball */
1240 for(int i=0; i<6; ++i) {
1242 snprintf(num, 4, "%d", i);
1243 img_bouncingsnowball_left[i] = new Surface(
1244 datadir + "/images/shared/bouncingsnowball-left-" + num + ".png",
1246 img_bouncingsnowball_right[i] = new Surface(
1247 datadir + "/images/shared/bouncingsnowball-right-" + num + ".png",
1250 img_bouncingsnowball_squished[0] = new Surface(
1251 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1253 /* flying snowball */
1254 img_flyingsnowball[0] = new Surface(
1255 datadir + "/images/shared/flyingsnowball-left-0.png", USE_ALPHA);
1256 img_flyingsnowball[1] = new Surface(
1257 datadir + "/images/shared/flyingsnowball-left-1.png", USE_ALPHA);
1258 img_flyingsnowball_squished[0] = new Surface(
1259 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1262 for(int i = 0; i < 3; ++i) {
1264 snprintf(num, 4, "%d", i);
1265 img_spiky_left[i] = new Surface(
1266 datadir + "/images/shared/spiky-left-" + num + ".png",
1268 img_spiky_right[i] = new Surface(
1269 datadir + "/images/shared/spiky-right-" + num + ".png",
1274 img_snowball_left[0] = new Surface(datadir + "/images/shared/snowball-left-0.png", USE_ALPHA);
1275 img_snowball_left[1] = new Surface(datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1276 img_snowball_left[2] = new Surface(datadir + "/images/shared/snowball-left-2.png", USE_ALPHA);
1277 img_snowball_left[3] = new Surface(datadir + "/images/shared/snowball-left-1.png", USE_ALPHA);
1279 img_snowball_right[0] = new Surface(datadir + "/images/shared/snowball-right-0.png", USE_ALPHA);
1280 img_snowball_right[1] = new Surface(datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1281 img_snowball_right[2] = new Surface(datadir + "/images/shared/snowball-right-2.png", USE_ALPHA);
1282 img_snowball_right[3] = new Surface(datadir + "/images/shared/snowball-right-1.png", USE_ALPHA);
1284 img_snowball_squished_left[0] = new Surface(
1285 datadir + "/images/shared/bsod-squished-left.png", USE_ALPHA);
1286 img_snowball_squished_right[0] = new Surface(
1287 datadir + "/images/shared/bsod-squished-right.png", USE_ALPHA);
1291 void free_badguy_gfx()