From: Tim Goya Date: Wed, 23 May 2007 15:27:56 +0000 (+0000) Subject: Experimental feature: Allow Tux to throw stuff straight up X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3e86b3d0c8c9ed1137e8716fcecbcd0ca67bea7b;p=supertux.git Experimental feature: Allow Tux to throw stuff straight up SVN-Revision: 5006 --- diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index f616abb5a..cb801b300 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -137,6 +137,10 @@ MrIceBlock::collision_player(Player& player, const CollisionHit& hit) if(ice_state == ICESTATE_GRABBED) return FORCE_MOVE; + if(dir == UP) { + return FORCE_MOVE; + } + // handle kicks from left or right side if(ice_state == ICESTATE_FLAT && get_state() == STATE_ACTIVE) { if(hit.left) { @@ -219,11 +223,16 @@ MrIceBlock::set_state(IceState state) WalkingBadguy::activate(); break; case ICESTATE_FLAT: - sound_manager->play("sounds/stomp.wav", get_pos()); - physic.set_velocity_x(0); - physic.set_velocity_y(0); - - sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); + if(dir == UP) { + physic.set_velocity_y(-KICKSPEED); + bbox.set_size(34, 31.8f); + } else { + sound_manager->play("sounds/stomp.wav", get_pos()); + physic.set_velocity_x(0); + physic.set_velocity_y(0); + + sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); + } flat_timer.start(4); break; case ICESTATE_KICKED: @@ -257,7 +266,7 @@ void MrIceBlock::ungrab(MovingObject& , Direction dir) { this->dir = dir; - set_state(ICESTATE_KICKED); + set_state(dir == UP ? ICESTATE_FLAT : ICESTATE_KICKED); set_group(COLGROUP_MOVING); } diff --git a/src/direction.hpp b/src/direction.hpp index c7bb2e1bc..e665d2073 100644 --- a/src/direction.hpp +++ b/src/direction.hpp @@ -20,6 +20,6 @@ #ifndef SUPERTUX_DIRECTION_H #define SUPERTUX_DIRECTION_H -enum Direction { AUTO, LEFT, RIGHT }; +enum Direction { AUTO, LEFT, RIGHT, UP, DOWN }; #endif diff --git a/src/object/block.cpp b/src/object/block.cpp index de4f31172..395c33b3c 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -32,6 +32,7 @@ #include "video/drawing_context.hpp" #include "lisp/lisp.hpp" #include "gameobjs.hpp" +#include "portable.hpp" #include "specialriser.hpp" #include "growup.hpp" #include "flower.hpp" @@ -73,7 +74,8 @@ Block::collision(GameObject& other, const CollisionHit& ) } } - if(bouncing) { + Portable* portable = dynamic_cast (&other); + if(bouncing && (portable == 0 || portable->is_portable())) { BadGuy* badguy = dynamic_cast (&other); if(badguy) { badguy->kill_fall(); @@ -223,6 +225,13 @@ BonusBlock::collision(GameObject& other, const CollisionHit& hit){ try_open(); } } + Portable* portable = dynamic_cast (&other); + if(portable) { + MovingObject* moving = dynamic_cast (&other); + if(moving->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) { + try_open(); + } + } return Block::collision(other, hit); } @@ -344,6 +353,13 @@ Brick::collision(GameObject& other, const CollisionHit& hit){ try_break(false); } } + Portable* portable = dynamic_cast (&other); + if(portable) { + MovingObject* moving = dynamic_cast (&other); + if(moving->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) { + try_break(); + } + } return Block::collision(other, hit); } diff --git a/src/object/player.cpp b/src/object/player.cpp index 7ce6363da..31cac1807 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -627,12 +627,24 @@ Player::handle_input() if( controller->released( Controller::PEEK_RIGHT ) ) { peeking = AUTO; } + if( controller->released( Controller::UP ) ) { + peeking = AUTO; + } + if( controller->released( Controller::DOWN ) ) { + peeking = AUTO; + } if( controller->pressed( Controller::PEEK_LEFT ) ) { peeking = LEFT; } if( controller->pressed( Controller::PEEK_RIGHT ) ) { peeking = RIGHT; } + if( controller->pressed( Controller::UP ) ) { + peeking = UP; + } + if( controller->pressed( Controller::DOWN ) ) { + peeking = DOWN; + } /* Handle horizontal movement: */ if (!backflipping) handle_horizontal_input(); @@ -674,9 +686,13 @@ Player::handle_input() if(moving_object) { moving_object->set_pos(pos); } else { - log_debug << "Non MovingObjetc grabbed?!?" << std::endl; + log_debug << "Non MovingObject grabbed?!?" << std::endl; + } + if(controller->hold(Controller::UP)) { + grabbed_object->ungrab(*this, UP); + } else { + grabbed_object->ungrab(*this, dir); } - grabbed_object->ungrab(*this, dir); grabbed_object = NULL; } } diff --git a/src/object/rock.cpp b/src/object/rock.cpp index e5f10b37d..f4355788d 100644 --- a/src/object/rock.cpp +++ b/src/object/rock.cpp @@ -117,7 +117,9 @@ Rock::ungrab(MovingObject& , Direction dir) { set_group(COLGROUP_MOVING_STATIC); on_ground = false; - if (last_movement.norm() > 1) { + if(dir == UP) { + physic.set_velocity(0, -500); + } else if (last_movement.norm() > 1) { physic.set_velocity((dir == RIGHT) ? 200 : -200, -200); } else { physic.set_velocity(0, 0);