From 470ce0c433a316972734787d4c065525b0a1f735 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 16 May 2006 18:53:16 +0000 Subject: [PATCH] fix mriceblock grabbing SVN-Revision: 3540 --- src/badguy/badguy.cpp | 2 +- src/badguy/mriceblock.cpp | 7 ++----- src/object/player.cpp | 16 ++++++++++------ src/object/player.hpp | 5 +++++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 8718b1918..57bf79b60 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -146,7 +146,7 @@ BadGuy::collision(GameObject& other, const CollisionHit& hit) return collision_solid(other, hit); BadGuy* badguy = dynamic_cast (&other); - if(badguy && badguy->state == STATE_ACTIVE) + if(badguy && badguy->state == STATE_ACTIVE && badguy->get_group() == COLGROUP_MOVING) return collision_badguy(*badguy, hit); Player* player = dynamic_cast (&other); diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index 60dd66cca..a7a785688 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -141,15 +141,12 @@ MrIceBlock::collision_player(Player& player, const CollisionHit& hit) // handle kicks from left or right side if(ice_state == ICESTATE_FLAT && get_state() == STATE_ACTIVE) { // hit from left side - if(hit.normal.x > 0.7 && - !player.get_controller()->hold(Controller::ACTION)) { + if(hit.normal.x > 0.7) { dir = RIGHT; player.kick(); set_state(ICESTATE_KICKED); return FORCE_MOVE; - } - else if(hit.normal.x < -0.7 && - !player.get_controller()->hold(Controller::ACTION)) { + } else if(hit.normal.x < -0.7) { dir = LEFT; player.kick(); set_state(ICESTATE_KICKED); diff --git a/src/object/player.cpp b/src/object/player.cpp index a7643b79d..14c20e3b0 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -102,7 +102,7 @@ TuxBodyParts::draw(DrawingContext& context, const Vector& pos, int layer) } Player::Player(PlayerStatus* _player_status) - : player_status(_player_status), grabbed_object(0) + : player_status(_player_status), grabbed_object(NULL) { controller = main_controller; smalltux_gameover = sprite_manager->create("images/creatures/tux_small/smalltux-gameover.sprite"); @@ -150,7 +150,7 @@ Player::init() visible = true; on_ground_flag = false; - grabbed_object = 0; + grabbed_object = NULL; floor_normal = Vector(0,-1); @@ -195,15 +195,16 @@ Player::update(float elapsed_time) movement = physic.get_movement(elapsed_time); - if(grabbed_object != 0 && !dying ) { + if(grabbed_object != NULL && !dying) { Vector pos = get_pos() + Vector(dir == LEFT ? -16 : 16, bbox.get_height()*0.66666 - 32); grabbed_object->grab(*this, pos, dir); } - if(grabbed_object != 0 && dying){ + if(grabbed_object != NULL && dying){ grabbed_object->ungrab(*this, dir); + grabbed_object = NULL; } on_ground_flag = false; @@ -480,7 +481,7 @@ Player::handle_input() log_debug << "Non MovingObjetc grabbed?!?" << std::endl; } grabbed_object->ungrab(*this, dir); - grabbed_object = 0; + grabbed_object = NULL; } } @@ -764,9 +765,12 @@ Player::collision(GameObject& other, const CollisionHit& hit) if(other.get_flags() & FLAG_PORTABLE) { Portable* portable = dynamic_cast (&other); - if(portable && grabbed_object == 0 && controller->hold(Controller::ACTION) + assert(portable != NULL); + if(portable && grabbed_object == NULL + && controller->hold(Controller::ACTION) && fabsf(hit.normal.x) > .9) { grabbed_object = portable; + grabbed_object->grab(*this, get_pos(), dir); return CONTINUE; } } diff --git a/src/object/player.hpp b/src/object/player.hpp index 3d7a239a3..2581c9f4a 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -178,6 +178,11 @@ public: bool on_ground(); + Portable* get_grabbed_object() const + { + return grabbed_object; + } + private: void handle_input(); bool deactivated; -- 2.11.0