From 25f9d115085bfd46757a5aa46951c243f748d9be Mon Sep 17 00:00:00 2001 From: Ryan Flegel Date: Sun, 16 May 2004 16:49:13 +0000 Subject: [PATCH] - trampoline stuff SVN-Revision: 1213 --- src/gameobjs.cpp | 25 ++++++++++++++++++------- src/gameobjs.h | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index 3f23894f8..04b8a59ed 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -235,12 +235,16 @@ Trampoline::init(float x, float y) base.width = 32; base.height = 32; + + frame = 0; } void Trampoline::draw() { - img_trampoline[0]->draw((int)base.x, (int)base.y); + img_trampoline[frame]->draw((int)base.x, (int)base.y); + + frame = 0; if (debug_mode) fillrect(base.x - scroll_x, base.y - scroll_y, base.width, base.height, 75, 75, 0, 150); @@ -251,7 +255,7 @@ Trampoline::action(double frame_ratio) { physic.apply(frame_ratio, base.x, base.y); - + // Falling if (issolid(base.x + base.width/2, base.y + base.height)) { base.y = int((base.y + base.height)/32) * 32 - base.height; @@ -289,12 +293,19 @@ Trampoline::collision(void *p_c_object, int c_object, CollisionType type) // TODO: compress springs // TODO: launch tux, if necessary - base.y = pplayer_c->base.y + pplayer_c->base.height; - base.height = (32 - (int)pplayer_c->base.y % 32); - if (base.height < 16) - { - base.height = 32; + 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 < 24) + { pplayer_c->physic.set_velocity_y(8); } } diff --git a/src/gameobjs.h b/src/gameobjs.h index 97a25b711..660d2f60d 100644 --- a/src/gameobjs.h +++ b/src/gameobjs.h @@ -134,6 +134,7 @@ class Trampoline : public GameObject private: int power; + unsigned int frame; }; -- 2.11.0