Experimental feature: Allow Tux to throw stuff straight up
authorTim Goya <tuxdev103@gmail.com>
Wed, 23 May 2007 15:27:56 +0000 (15:27 +0000)
committerTim Goya <tuxdev103@gmail.com>
Wed, 23 May 2007 15:27:56 +0000 (15:27 +0000)
SVN-Revision: 5006

src/badguy/mriceblock.cpp
src/direction.hpp
src/object/block.cpp
src/object/player.cpp
src/object/rock.cpp

index f616abb..cb801b3 100644 (file)
@@ -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);
 }
 
index c7bb2e1..e665d20 100644 (file)
@@ -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
index de4f311..395c33b 100644 (file)
@@ -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<Portable*> (&other);
+  if(bouncing && (portable == 0 || portable->is_portable())) {
     BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
     if(badguy) {
       badguy->kill_fall();
@@ -223,6 +225,13 @@ BonusBlock::collision(GameObject& other, const CollisionHit& hit){
         try_open();
       }
     }
+    Portable* portable = dynamic_cast<Portable*> (&other);
+    if(portable) {
+      MovingObject* moving = dynamic_cast<MovingObject*> (&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<Portable*> (&other);
+    if(portable) {
+      MovingObject* moving = dynamic_cast<MovingObject*> (&other);
+      if(moving->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) {
+        try_break();
+      }
+    }
    return Block::collision(other, hit);
 }
 
index 7ce6363..31cac18 100644 (file)
@@ -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;
     }
   }
index e5f10b3..f435578 100644 (file)
@@ -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);