X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fbadguy%2Fskullyhop.cpp;h=fb12d75193c4c3ee6d238d5364d06fd9fded65f7;hb=6e7c8fafae2311b22c78b1ea597a408396873560;hp=6dc1074dae047561e8297cd93452351019b1f3ef;hpb=b51a3e05e9212c00c3bf7d00c6c2bf33fe8e2970;p=supertux.git diff --git a/src/badguy/skullyhop.cpp b/src/badguy/skullyhop.cpp index 6dc1074da..fb12d7519 100644 --- a/src/badguy/skullyhop.cpp +++ b/src/badguy/skullyhop.cpp @@ -23,27 +23,21 @@ #include "random_generator.hpp" namespace { - const float VERTICAL_SPEED = 450; /**< y-speed when jumping */ + const float VERTICAL_SPEED = -450; /**< y-speed when jumping */ const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */ const float MIN_RECOVER_TIME = 0.1; /**< minimum time to stand still before starting a (new) jump */ const float MAX_RECOVER_TIME = 1.0; /**< maximum time to stand still before starting a (new) jump */ } SkullyHop::SkullyHop(const lisp::Lisp& reader) + : BadGuy(reader, "images/creatures/skullyhop/skullyhop.sprite") { - reader.get("x", start_position.x); - reader.get("y", start_position.y); - sprite = sprite_manager->create("images/creatures/skullyhop/skullyhop.sprite"); - bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); has_initial_direction = false; } -SkullyHop::SkullyHop(float pos_x, float pos_y, Direction d) +SkullyHop::SkullyHop(const Vector& pos, Direction d) + : BadGuy(pos, "images/creatures/skullyhop/skullyhop.sprite") { - start_position.x = pos_x; - start_position.y = pos_y; - sprite = sprite_manager->create("images/creatures/skullyhop/skullyhop.sprite"); - bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); has_initial_direction = true; initial_direction = d; } @@ -105,12 +99,12 @@ SkullyHop::collision_solid(GameObject& , const CollisionHit& hit) if(state != JUMPING) return CONTINUE; // check if we hit the floor while falling - if ((hit.normal.y < 0) && (physic.get_velocity_y() < 0)) { + if ((hit.normal.y < 0) && (physic.get_velocity_y() > 0)) { set_state(STANDING); } // check if we hit the roof while climbing - if ((hit.normal.y > 0) && (physic.get_velocity_y() > 0)) { + if ((hit.normal.y > 0) && (physic.get_velocity_y() < 0)) { physic.set_velocity_y(0); }