- dest.x = (int)(base.x - scroll_x);
- dest.y = (int)base.y;
- dest.w = 32;
- dest.h = 32;
-
- Level* plevel = World::current()->get_level();
-
- // FIXME: overdrawing hack to clean the tile from the screen to
- // paint it later at on offseted position
- if(plevel->bkgd_image[0] == '\0')
- {
- fillrect(base.x - scroll_x, base.y,
- 32,32,
- plevel->bkgd_top_red, plevel->bkgd_top_green, plevel->bkgd_top_blue, 0);
-// FIXME: doesn't respect the gradient, futhermore is this necessary at all??
- }
- else
- {
- s = (int)scroll_x / 30;
- plevel->img_bkgd->draw_part(dest.x + s, dest.y,
- dest.x, dest.y,dest.w,dest.h);
+ base.y = int((base.y + base.height)/32) * 32 - base.height;
+
+ physic.enable_gravity(false);
+ physic.set_velocity_y(0.0f);
+
+ physic.set_velocity_x(0);
+ }
+ 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 = *Sector::current()->player;
+ 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;
+ }
+
+ if(collision_object_map(base))
+ {
+ base.x = tux.base.x;
+ base.y = tux.base.y + tux.base.height/1.5 - base.height;
+ }
+ }
+
+ physic.apply(frame_ratio, base.x, base.y, Sector::current()->gravity);
+ collision_swept_object_map(&old_base, &base);
+}
+
+void
+Trampoline::collision(const MovingObject&, int)
+{
+ // comes later
+}
+
+void
+Trampoline::collision(void *p_c_object, int c_object, CollisionType type)
+{
+ Player* pplayer_c = NULL;
+ switch (c_object)
+ {
+ case CO_PLAYER:
+ pplayer_c = (Player*) p_c_object;
+
+ if (type == COLLISION_NORMAL)
+ {
+ // Pick up if HELD (done in Player)
+ }
+
+ else if (type == COLLISION_SQUISH)
+ {
+ int squish_amount = (32 - (int)pplayer_c->base.y % 32);
+
+ if (squish_amount < 24)
+ frame = 3;
+ else if (squish_amount < 28)
+ frame = 2;
+ else if (squish_amount < 30)
+ frame = 1;
+ else
+ frame = 0;
+
+ if (squish_amount < 20) {
+ pplayer_c->physic.set_velocity_y(power);
+ pplayer_c->fall_mode = Player::TRAMPOLINE_JUMP;