/******************************/ /*** Health throw out stuff ***/ /******************************/ #include "system\global.h" #include "mem\memory.h" #include "gfx\sprbank.h" #include "utils\utils.h" #include "gfx\prim.h" //#include "gfx\actor.h" #include "game\game.h" #include "player\player.h" #include "gfx\otpos.h" #include "game\healthman.h" #include CHealthManager::sItemTable CHealthManager::ItemTable[]= { {5,256, 255,255,0}, {1,256, 127,127,127}, }; const int CHealthManager::ItemTableSize=sizeof(CHealthManager::ItemTable)/sizeof(CHealthManager::sItemTable); int HealthManGrav=128; int HealthManShift=9; int HealthManPickUpDelay=16; /*****************************************************************************/ void CHealthManager::init() { FrameHdr=CGameScene::getSpriteBank()->getFrameHeader(FRM__SPATULA); for (int i=0; iTPage); ItemList[i].Sprite.clut=FrameHdr->Clut; ItemList[i].Sprite.u0=FrameHdr->U; ItemList[i].Sprite.v0=FrameHdr->V; ItemList[i].Sprite.w=FrameHdr->W; ItemList[i].Sprite.h=FrameHdr->H; } } /*****************************************************************************/ void CHealthManager::shutdown() { } /*****************************************************************************/ const int AngleS=2048+1024+512; void CHealthManager::drop(DVECTOR &Pos,int Amount,int Vel) { int Count=0; int Am=Amount; // Count em for Arc for (int i=0; i=T.Count) { Amount-=T.Count; Count++; } } int Angle=AngleS; int AngleInc=1024/Count; // Split Em Amount=Am; for (int i=0; i=T.Count) { Amount-=T.Count; addItem(Pos,i,Angle,Vel); Angle+=AngleInc; Angle&=4095; } } } /*****************************************************************************/ void CHealthManager::addItem(DVECTOR &Pos,int TableIdx,int Angle,int Vel) { int Idx=0; while (ItemList[Idx].Life) Idx++; ASSERT(Idx>1; ItemList[Idx].Vel.vy=-(mcos(Angle)*Vel); ItemList[Idx].Count=ItemTable[TableIdx].Count; } /*****************************************************************************/ void CHealthManager::checkPlayerCol(CPlayer *Player) { CRECT const &PRect=Player->getCollisionArea(); for (int i=0; iItemList[i].ScrPos.vx+16 || PRect.y2ItemList[i].ScrPos.vy+32) { } else { ItemList[i].Life=0; Player->addSpatula(ItemList[i].Count); } } } } /*****************************************************************************/ /*** think *******************************************************************/ /*****************************************************************************/ void CHealthManager::think(int frames) { CLayerCollision *ColLayer=CGameScene::getCollision(); for (int i=0; i>HealthManShift; ItemList[i].ScrPos.vy=ItemList[i].Pos.vy>>HealthManShift; ItemList[i].Vel.vy+=HealthManGrav; if (ItemList[i].Vel.vy>0) { // Check ground collision int DistY = ColLayer->getHeightFromGround( ItemList[i].ScrPos.vx, ItemList[i].ScrPos.vy, 16 ); if (DistY<=0) { ItemList[i].Vel.vy=-ItemList[i].Vel.vy>>1; ItemList[i].Vel.vx>>=1; // ItemList[i].Pos.vy-=DistY<<(HealthManShift-1); } } int XOfs; if (ItemList[i].Vel.vx>0) { XOfs=+16; } else { XOfs=-16; } // Check X collision int DistX = ColLayer->getHeightFromGround( ItemList[i].ScrPos.vx+XOfs, ItemList[i].ScrPos.vy, 32 ); if (DistX<=0) { ItemList[i].Vel.vx=-ItemList[i].Vel.vx>>1; // ItemList[i].Pos.vy-=DistY<<(HealthManShift-1); } } } } } /*****************************************************************************/ /*** render ******************************************************************/ /*****************************************************************************/ void CHealthManager::render() { sOT *ThisOT=OtPtr;//+OTPOS__PICKUP_POS; DVECTOR const &CamPos=CLevel::getCameraPos(); for (int i=0; i