#include <jumpy.hpp>
Inherits BadGuy.
Public Member Functions | |
Jumpy (const Reader &reader) | |
void | collision_solid (const CollisionHit &hit) |
Called when the badguy collided with solid ground. | |
HitResponse | collision_badguy (BadGuy &other, const CollisionHit &hit) |
Called when the badguy collided with another badguy. | |
void | active_update (float) |
called each frame when the badguy is activated. | |
void | freeze () |
Called when hit by an ice bullet, and is_freezable() returns true. | |
bool | is_freezable () const |
Private Member Functions | |
HitResponse | hit (const CollisionHit &hit) |
Private Attributes | |
Vector | pos_groundhit |
bool | groundhit_pos_set |
Definition at line 22 of file jumpy.hpp.
Jumpy::Jumpy | ( | const Reader & | reader | ) |
Definition at line 27 of file jumpy.cpp.
00027 : 00028 BadGuy(reader, "images/creatures/snowjumpy/snowjumpy.sprite"), 00029 pos_groundhit(), 00030 groundhit_pos_set(false) 00031 { 00032 // TODO create a nice sound for this... 00033 //sound_manager->preload("sounds/skid.wav"); 00034 }
void Jumpy::collision_solid | ( | const CollisionHit & | hit | ) | [virtual] |
HitResponse Jumpy::collision_badguy | ( | BadGuy & | other, | |
const CollisionHit & | hit | |||
) | [virtual] |
void Jumpy::active_update | ( | float | ) | [virtual] |
called each frame when the badguy is activated.
Reimplemented from BadGuy.
Definition at line 69 of file jumpy.cpp.
References BadGuy::active_update(), BadGuy::dir, BadGuy::frozen, BadGuy::get_nearest_player(), MovingObject::get_pos(), groundhit_pos_set, JUMPY_LOW_TOLERANCE, JUMPY_MID_TOLERANCE, LEFT, pos_groundhit, RIGHT, MovingSprite::sprite, Vector::x, and Vector::y.
00070 { 00071 BadGuy::active_update(elapsed_time); 00072 00073 if(frozen) 00074 return; 00075 00076 Player* player = this->get_nearest_player(); 00077 if (player) 00078 { 00079 dir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT; 00080 } 00081 00082 if (!groundhit_pos_set) 00083 { 00084 sprite->set_action(dir == LEFT ? "left-middle" : "right-middle"); 00085 return; 00086 } 00087 00088 if ( get_pos().y < (pos_groundhit.y - JUMPY_MID_TOLERANCE ) ) 00089 sprite->set_action(dir == LEFT ? "left-up" : "right-up"); 00090 else if ( get_pos().y >= (pos_groundhit.y - JUMPY_MID_TOLERANCE) && 00091 get_pos().y < (pos_groundhit.y - JUMPY_LOW_TOLERANCE) ) 00092 sprite->set_action(dir == LEFT ? "left-middle" : "right-middle"); 00093 else 00094 sprite->set_action(dir == LEFT ? "left-down" : "right-down"); 00095 }
void Jumpy::freeze | ( | ) | [virtual] |
Called when hit by an ice bullet, and is_freezable() returns true.
Reimplemented from BadGuy.
Definition at line 98 of file jumpy.cpp.
References BadGuy::dir, BadGuy::freeze(), Physic::get_velocity_y(), LEFT, BadGuy::physic, Physic::set_velocity_y(), and MovingSprite::sprite.
00099 { 00100 BadGuy::freeze(); 00101 physic.set_velocity_y(std::max(0.0f, physic.get_velocity_y())); 00102 sprite->set_action(dir == LEFT ? "left-iced" : "right-iced"); 00103 }
bool Jumpy::is_freezable | ( | ) | const [virtual] |
HitResponse Jumpy::hit | ( | const CollisionHit & | hit | ) | [private] |
Definition at line 49 of file jumpy.cpp.
References CollisionHit::bottom, CONTINUE, BadGuy::frozen, MovingObject::get_pos(), BadGuy::get_state(), groundhit_pos_set, JUMPYSPEED, BadGuy::physic, pos_groundhit, Physic::set_velocity_y(), BadGuy::STATE_FALLING, and CollisionHit::top.
Referenced by collision_badguy(), and collision_solid().
00050 { 00051 if(chit.bottom) { 00052 if (!groundhit_pos_set) 00053 { 00054 pos_groundhit = get_pos(); 00055 groundhit_pos_set = true; 00056 } 00057 00058 physic.set_velocity_y((frozen || get_state() == STATE_FALLING) ? 0 : JUMPYSPEED); 00059 // TODO create a nice sound for this... 00060 //sound_manager->play("sounds/skid.wav"); 00061 } else if(chit.top) { 00062 physic.set_velocity_y(0); 00063 } 00064 00065 return CONTINUE; 00066 }
Vector Jumpy::pos_groundhit [private] |
bool Jumpy::groundhit_pos_set [private] |