00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "badguy/poisonivy.hpp"
00018 #include "math/random_generator.hpp"
00019 #include "object/sprite_particle.hpp"
00020 #include "supertux/object_factory.hpp"
00021 #include "supertux/sector.hpp"
00022
00023 #include <math.h>
00024
00025 PoisonIvy::PoisonIvy(const Reader& reader)
00026 : WalkingBadguy(reader, "images/creatures/poison_ivy/poison_ivy.sprite", "left", "right")
00027 {
00028 walk_speed = 80;
00029 }
00030
00031 PoisonIvy::PoisonIvy(const Vector& pos, Direction d)
00032 : WalkingBadguy(pos, d, "images/creatures/poison_ivy/poison_ivy.sprite", "left", "right")
00033 {
00034 walk_speed = 80;
00035 }
00036
00037 bool
00038 PoisonIvy::collision_squished(GameObject& object)
00039 {
00040 sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
00041
00042
00043 for (int i = 0; i < 3; i++) {
00044 Vector ppos = bbox.get_middle();
00045 float angle = graphicsRandom.randf(-M_PI_2, M_PI_2);
00046 float velocity = graphicsRandom.randf(350, 400);
00047 float vx = sin(angle)*velocity;
00048 float vy = -cos(angle)*velocity;
00049 Vector pspeed = Vector(vx, vy);
00050 Vector paccel = Vector(0, 100);
00051 Sector::current()->add_object(new SpriteParticle("images/objects/particles/poisonivy.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1));
00052 }
00053 kill_squished(object);
00054 return true;
00055 }
00056
00057