#include "gameobjs.h"
#include "sprite_manager.h"
#include "resources.h"
+#include "level.h"
void
BouncyDistro::init(float x, float y)
{
base.x = x;
base.y = y;
-
base.width = 32;
base.height = 32;
frame = 0;
+ mode = M_NORMAL;
+ physic.reset();
}
void
physic.apply(frame_ratio, base.x, base.y);
// Falling
- if (issolid(base.x + base.width/2, base.y + base.height))
+ if (mode != M_HELD)
{
- base.y = int((base.y + base.height)/32) * 32 - base.height;
+ if (issolid(base.x + base.width/2, base.y + base.height))
+ {
+ base.y = int((base.y + base.height)/32) * 32 - base.height;
+
+ physic.enable_gravity(false);
+ physic.set_velocity_y(0.0f);
- physic.enable_gravity(false);
- physic.set_velocity_y(0.0f);
+ physic.set_velocity_x(0);
+ }
+ else
+ {
+ physic.enable_gravity(true);
+ }
}
- else
- physic.enable_gravity(true);
+ else // Player is carrying us around
+ {
+ /* FIXME: The trampoline object shouldn't know about pplayer objects. */
+ /* If we're holding the iceblock */
+ Player& tux = *World::current()->get_tux();
+ Direction dir = tux.dir;
-}
+ if(dir == RIGHT)
+ {
+ base.x = tux.base.x + 16;
+ base.y = tux.base.y + tux.base.height/1.5 - base.height;
+ }
+ else /* facing left */
+ {
+ base.x = tux.base.x - 16;
+ base.y = tux.base.y + tux.base.height/1.5 - base.height;
+ }
-// TODO:
-// If HELD
-// - move with tux
-// If jumped on
-// - compress springs (reduce height)
+ if(collision_object_map(base))
+ {
+ base.x = tux.base.x;
+ base.y = tux.base.y + tux.base.height/1.5 - base.height;
+ }
+ }
+}
void
Trampoline::collision(void *p_c_object, int c_object, CollisionType type)
if (type == COLLISION_NORMAL)
{
- // TODO: Pick up if HELD
+ // Pick up if HELD (done in Player)
}
else if (type == COLLISION_SQUISH)
{
- // TODO: compress springs
- // TODO: launch tux, if necessary
-
int squish_amount = (32 - (int)pplayer_c->base.y % 32);
if (squish_amount < 24)
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <math.h>
+#include <iostream>
+#include <iostream>
#include <cassert>
#include "gameloop.h"
#include "globals.h"
case CO_TRAMPOLINE:
ptramp_c = (Trampoline*) p_c_object;
- if (physic.get_velocity_x() > 0) // RIGHT
+ // Pick up trampoline
+ if (ptramp_c->mode != Trampoline::M_HELD && input.fire == DOWN && !holding_something)
{
- physic.set_velocity_x(0);
- base.x = ptramp_c->base.x - base.width;
+ holding_something = true;
+ ptramp_c->mode = Trampoline::M_HELD;
+ ptramp_c->base.y -= 8;
}
- else if (physic.get_velocity_x() < 0) // LEFT
+ // Set down trampoline
+ else if (ptramp_c->mode == Trampoline::M_HELD && input.fire != DOWN)
{
- physic.set_velocity_x(0);
- base.x = ptramp_c->base.x + ptramp_c->base.width;
+ holding_something = false;
+ ptramp_c->mode = Trampoline::M_NORMAL;
+ ptramp_c->base.y += 8;
+ ptramp_c->physic.set_velocity(physic.get_velocity_x(), physic.get_velocity_y());
+
+ //if (dir == RIGHT)
+ // ptramp_c->base.x = base.x + base.width+1;
+ //else /* LEFT */
+ // ptramp_c->base.x = base.x - base.width-1;
}
- else
+/*
+ // Don't let tux walk through trampoline
+ else if (ptramp_c->mode != Trampoline::M_HELD && on_ground())
{
+ if (physic.get_velocity_x() > 0) // RIGHT
+ {
+ physic.set_velocity_x(0);
+ base.x = ptramp_c->base.x - base.width;
+ }
+ else if (physic.get_velocity_x() < 0) // LEFT
+ {
+ physic.set_velocity_x(0);
+ base.x = ptramp_c->base.x + ptramp_c->base.width;
+ }
}
+*/
+
break;
default: