#include <captainsnowball.hpp>
Inherits WalkingBadguy.
Public Member Functions | |
CaptainSnowball (const Reader &reader) | |
CaptainSnowball (const Vector &pos, Direction d) | |
virtual void | active_update (float elapsed_time) |
called each frame when the badguy is activated. | |
void | collision_solid (const CollisionHit &hit) |
Called when the badguy collided with solid ground. | |
bool | might_climb (int width, int height) |
Protected Member Functions | |
bool | collision_squished (GameObject &object) |
Called when the player hit the badguy from above. |
Definition at line 22 of file captainsnowball.hpp.
CaptainSnowball::CaptainSnowball | ( | const Reader & | reader | ) |
Definition at line 28 of file captainsnowball.cpp.
References BOARDING_SPEED, WalkingBadguy::max_drop_height, BadGuy::physic, Physic::set_velocity_y(), and WalkingBadguy::walk_speed.
00029 : WalkingBadguy(reader, "images/creatures/snowball/cpt-snowball.sprite", "left", "right") 00030 { 00031 walk_speed = BOARDING_SPEED; 00032 max_drop_height = -1; 00033 physic.set_velocity_y(-400); 00034 }
Definition at line 36 of file captainsnowball.cpp.
References BOARDING_SPEED, WalkingBadguy::max_drop_height, BadGuy::physic, Physic::set_velocity_y(), and WalkingBadguy::walk_speed.
00037 : WalkingBadguy(pos, d, "images/creatures/snowball/cpt-snowball.sprite", "left", "right") 00038 { 00039 // Created during game eg. by dispencer. Board the enemy! 00040 walk_speed = BOARDING_SPEED; 00041 max_drop_height = -1; 00042 physic.set_velocity_y(-400); 00043 }
void CaptainSnowball::active_update | ( | float | elapsed_time | ) | [virtual] |
called each frame when the badguy is activated.
Reimplemented from WalkingBadguy.
Definition at line 69 of file captainsnowball.cpp.
References WalkingBadguy::active_update(), BOARDING_SPEED, BadGuy::dir, LEFT, might_climb(), BadGuy::might_fall(), BadGuy::on_ground(), BadGuy::physic, Physic::set_velocity_x(), Physic::set_velocity_y(), and WalkingBadguy::walk_speed.
00070 { 00071 if (on_ground() && might_climb(8, 64)) { 00072 physic.set_velocity_y(-400); 00073 } else if (on_ground() && might_fall(16)) { 00074 physic.set_velocity_y(-400); 00075 walk_speed = BOARDING_SPEED; 00076 physic.set_velocity_x(dir == LEFT ? -walk_speed : walk_speed); 00077 } 00078 WalkingBadguy::active_update(elapsed_time); 00079 }
void CaptainSnowball::collision_solid | ( | const CollisionHit & | hit | ) | [virtual] |
Called when the badguy collided with solid ground.
Reimplemented from WalkingBadguy.
Definition at line 82 of file captainsnowball.cpp.
References BOARDING_SPEED, CAPTAIN_WALK_SPEED, WalkingBadguy::collision_solid(), BadGuy::dir, BadGuy::is_active(), LEFT, BadGuy::physic, Physic::set_velocity_x(), and WalkingBadguy::walk_speed.
00083 { 00084 if (is_active() && (walk_speed == BOARDING_SPEED)) { 00085 walk_speed = CAPTAIN_WALK_SPEED; 00086 physic.set_velocity_x(dir == LEFT ? -walk_speed : walk_speed); 00087 } 00088 WalkingBadguy::collision_solid(hit); 00089 }
bool CaptainSnowball::might_climb | ( | int | width, | |
int | height | |||
) |
Definition at line 46 of file captainsnowball.cpp.
References MovingObject::bbox, Sector::current(), BadGuy::dir, LEFT, Rectf::p1, Rectf::p2, Vector::x, and Vector::y.
Referenced by active_update().
00047 { 00048 // make sure we check for at least a 1-pixel climb 00049 assert(height > 0); 00050 00051 float x1; 00052 float x2; 00053 float y1a = bbox.p1.y + 1; 00054 float y2a = bbox.p2.y - 1; 00055 float y1b = bbox.p1.y + 1 - height; 00056 float y2b = bbox.p2.y - 1 - height; 00057 if (dir == LEFT) { 00058 x1 = bbox.p1.x - width; 00059 x2 = bbox.p1.x - 1; 00060 } else { 00061 x1 = bbox.p2.x + 1; 00062 x2 = bbox.p2.x + width; 00063 } 00064 return ((!Sector::current()->is_free_of_statics(Rectf(x1, y1a, x2, y2a))) && 00065 (Sector::current()->is_free_of_statics(Rectf(x1, y1b, x2, y2b)))); 00066 }
bool CaptainSnowball::collision_squished | ( | GameObject & | object | ) | [protected, virtual] |
Called when the player hit the badguy from above.
You should return true if the badguy was squished, false if squishing wasn't possible
Reimplemented from BadGuy.
Definition at line 92 of file captainsnowball.cpp.
References BadGuy::dir, BadGuy::kill_squished(), LEFT, and MovingSprite::sprite.
00093 { 00094 sprite->set_action(dir == LEFT ? "squished-left" : "squished-right"); 00095 kill_squished(object); 00096 return true; 00097 }