From d430b91f9109df7dc10394b728fce8fc7a955382 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 2 May 2001 14:29:10 +0000 Subject: [PATCH] --- source/platform/pbounce.cpp | 122 +++++++++++++++++++++++++++++++++++- source/platform/pbounce.h | 7 ++- 2 files changed, 127 insertions(+), 2 deletions(-) diff --git a/source/platform/pbounce.cpp b/source/platform/pbounce.cpp index 0b8a33581..45ac71109 100644 --- a/source/platform/pbounce.cpp +++ b/source/platform/pbounce.cpp @@ -19,16 +19,136 @@ #include "game\game.h" #endif +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + +#ifndef __UTILS_HEADER__ +#include "utils\utils.h" +#endif + + +void CNpcBouncePlatform::postInit() +{ + m_vertScale = 0; + m_vertVelocity = 0; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcBouncePlatform::think( int _frames ) { if ( m_contact ) { CPlayer *player = GameScene.getPlayer(); - player->springPlayerUp(); + if ( m_vertVelocity > 20 && m_vertScale < -100 ) + { + player->springPlayerUp(); + } + + s16 vertForce = -30 * _frames; + + m_vertVelocity += vertForce; m_contact = false; } + s32 resistance = -( 10 * _frames * m_vertScale ) >> 8; + + if ( m_vertScale > 0 && resistance > -1 ) + { + resistance = -1; + } + else if ( m_vertScale < 0 && resistance < 1 ) + { + resistance = 1; + } + + // get direction of resistance + + m_vertVelocity += resistance; + + m_vertScale += m_vertVelocity; + + if ( m_vertVelocity ) + { + s32 absVertVelocity = abs( m_vertVelocity ); + + m_vertVelocity += -m_vertVelocity / abs( m_vertVelocity ); + + if ( abs( m_vertVelocity ) < 10 ) + { + m_vertVelocity = 0; + } + + if ( m_vertVelocity > 60 ) + { + m_vertVelocity = 60; + } + else if ( m_vertVelocity < -60 ) + { + m_vertVelocity = -60; + } + } + CPlatformThing::think(_frames); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcBouncePlatform::render() +{ + if ( m_isActive ) + { + CPlatformThing::render(); + + // Render + DVECTOR renderPos; + DVECTOR offset = CLevel::getCameraPos(); + + renderPos.vx = Pos.vx - offset.vx; + renderPos.vy = Pos.vy - offset.vy; + + if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() ) + { + if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() ) + { + SVECTOR rotation; + rotation.vx = 0; + rotation.vy = 0; + rotation.vz = 0; + + VECTOR scale; + scale.vx = ONE; + scale.vy = ONE + m_vertScale; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); + +#if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR centre; + int halfLength; + int x1,y1,x2,y2; + + centre=getCollisionCentre(); + halfLength=PLATFORMWIDTH/2; + + x1=-halfLength*mcos(getCollisionAngle()&4095)>>12; + y1=-halfLength*msin(getCollisionAngle()&4095)>>12; + x2=+halfLength*mcos(getCollisionAngle()&4095)>>12; + y2=+halfLength*msin(getCollisionAngle()&4095)>>12; + + centre.vx-=offset.vx; + centre.vy-=offset.vy; + x1+=centre.vx; + y1+=centre.vy; + x2+=centre.vx; + y2+=centre.vy; + + DrawLine(x1,y1,x2,y2,0,255,0,0); +#endif + } + } + } } \ No newline at end of file diff --git a/source/platform/pbounce.h b/source/platform/pbounce.h index d0d20d0de..102e260b3 100644 --- a/source/platform/pbounce.h +++ b/source/platform/pbounce.h @@ -20,8 +20,13 @@ class CNpcBouncePlatform : public CNpcPlatform { -protected: +public: + virtual void postInit(); virtual void think( int _frames ); + virtual void render(); +protected: + s32 m_vertScale; + s32 m_vertVelocity; }; #endif \ No newline at end of file