From 2ce4909f783ed774bc49b0c7cb193310b70cde68 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 16 Jul 2001 15:33:38 +0000 Subject: [PATCH] --- source/platform/pbounce.cpp | 66 ++++++++++++++++++++++++++++++++++++- source/platform/pbounce.h | 2 ++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/source/platform/pbounce.cpp b/source/platform/pbounce.cpp index 66cce5695..69f624df7 100644 --- a/source/platform/pbounce.cpp +++ b/source/platform/pbounce.cpp @@ -134,4 +134,68 @@ void CNpcBouncePlatform::render() } } -} \ No newline at end of file +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcBouncePlatform::collidedWith( CThing *_thisThing ) +{ + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + CPlayer *player; + DVECTOR playerPos; + CRECT collisionArea; + CRECT playerCollisionArea; + + // Only interested in SBs feet colliding with the box (pkg) + player=(CPlayer*)_thisThing; + playerPos=player->getPos(); + playerCollisionArea = player->getCollisionArea(); + collisionArea=getCollisionArea(); + + s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); + + if ( threshold > 16 ) + { + threshold = 16; + } + + //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) + { + if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) + { + player->setPlatform( this ); + + m_contact = true; + } + else + { + if( playerPos.vy >= collisionArea.y1 && playerPos.vy <= collisionArea.y2 ) + { + int height = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy ); + + if ( height >= -threshold && height < 1 ) + { + player->setPlatform( this ); + + m_contact = true; + } + } + } + } + + break; + } + + case TYPE_NPC: + case TYPE_HAZARD: + break; + + default: + ASSERT(0); + break; + } +} diff --git a/source/platform/pbounce.h b/source/platform/pbounce.h index 16249d1c4..093ec55a0 100644 --- a/source/platform/pbounce.h +++ b/source/platform/pbounce.h @@ -25,6 +25,8 @@ public: void think( int _frames ); void render(); protected: + virtual void collidedWith(CThing *_thisThing); + s32 m_vertScale; s32 m_vertVelocity; };