6 #include "player_status.h"
7 #include "special/sprite_manager.h"
8 #include "video/drawing_context.h"
10 static const float INITIALJUMP = 400;
11 static const float SPEED = 150;
12 static const float JUMPSPEED = 300;
14 Star::Star(const Vector& pos)
17 bbox.set_size(32, 32);
18 sprite = sprite_manager->create("star");
19 physic.set_velocity(SPEED, INITIALJUMP);
28 Star::action(float elapsed_time)
30 movement = physic.get_movement(elapsed_time);
34 Star::draw(DrawingContext& context)
36 sprite->draw(context, get_pos(), LAYER_OBJECTS);
40 Star::collision(GameObject& other, const CollisionHit& hit)
42 if(other.get_flags() & FLAG_SOLID) {
43 if(hit.normal.y < -.5) { // ground
44 physic.set_velocity_y(JUMPSPEED);
45 } else if(hit.normal.y > .5) { // roof
46 physic.set_velocity_y(0);
47 } else { // bumped left or right
48 physic.set_velocity_x(-physic.get_velocity_x());
54 Player* player = dynamic_cast<Player*> (&other);
56 player->make_invincible();