SBSPSS/source/paul/animtest.cpp

329 lines
6.6 KiB
C++
Raw Normal View History

2001-06-25 20:44:59 +02:00
/*=========================================================================
animtest.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
2001-08-04 20:42:27 +02:00
#if defined(__VERSION_DEBUG__)
2001-06-25 20:44:59 +02:00
2001-06-25 22:25:28 +02:00
#include "paul\animtest.h"
2001-06-25 20:44:59 +02:00
2001-06-25 22:25:28 +02:00
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
2001-06-25 20:44:59 +02:00
#endif
2001-06-25 22:25:28 +02:00
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
2001-06-25 20:44:59 +02:00
#endif
2001-06-25 22:25:28 +02:00
#ifndef __PRIM_HEADER__
#include "gfx\prim.h"
2001-06-25 20:44:59 +02:00
#endif
2001-06-25 22:25:28 +02:00
#ifndef __PAD_PADS_H__
#include "pad\pads.h"
2001-06-25 20:44:59 +02:00
#endif
#ifndef __ACTOR_HEADER__
#include "gfx\actor.h"
#endif
/* Std Lib
------- */
/* Data
---- */
2001-06-25 22:25:28 +02:00
#ifndef __ANIM_SPONGEBOB_HEADER__
#include <ACTOR_SPONGEBOB_Anim.h>
2001-06-25 20:44:59 +02:00
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
CAnimTestScene AnimTestScene;
2001-06-25 22:25:28 +02:00
static CActorGfx *m_actorSpongebob;
// Anim tables from player.cpp
extern s8 s_animMapNet[NUM_PLAYER_ADDONS][NUM_ANIM_SPONGEBOB];
extern FileEquate s_addonActorPoolNames[];
static const char *s_animNames[NUM_ANIM_SPONGEBOB]=
{
"ANIM_SPONGEBOB_BUTTBOUNCEEND",
"ANIM_SPONGEBOB_BUTTBOUNCESTART",
"ANIM_SPONGEBOB_FALL",
"ANIM_SPONGEBOB_GETUP",
"ANIM_SPONGEBOB_HITGROUND",
"ANIM_SPONGEBOB_IDLEBREATH",
"ANIM_SPONGEBOB_JUMPEND",
"ANIM_SPONGEBOB_JUMP",
"ANIM_SPONGEBOB_RUN",
"ANIM_SPONGEBOB_RUNSTOP",
"ANIM_SPONGEBOB_RUNSTART",
"ANIM_SPONGEBOB_TEETERBACK",
"ANIM_SPONGEBOB_TEETERFRONT",
"ANIM_SPONGEBOB_SWIPE",
2001-08-14 23:03:31 +02:00
"ANIM_SPONGEBOB_DEATHTAR",
2001-06-25 22:25:28 +02:00
"ANIM_SPONGEBOB_BALLOONJUMP",
"ANIM_SPONGEBOB_BLOWBUBBLE",
"ANIM_SPONGEBOB_FIREEND",
"ANIM_SPONGEBOB_FIRESTART",
"ANIM_SPONGEBOB_IDLEWEAPON",
"ANIM_SPONGEBOB_WALK",
"ANIM_SPONGEBOB_KARATE",
"ANIM_SPONGEBOB_GETHIT",
"ANIM_SPONGEBOB_CROUCHDOWN",
"ANIM_SPONGEBOB_CROUCHUP",
"ANIM_SPONGEBOB_LOOKUP",
2001-07-27 16:43:39 +02:00
"ANIM_SPONGEBOB_IDLEFACEUPSIDEDOWN",
"ANIM_SPONGEBOB_IDLEBANDAID",
2001-07-03 01:50:22 +02:00
//NOIDLE "ANIM_SPONGEBOB_IDLEINHAT",
2001-07-27 16:43:39 +02:00
"ANIM_SPONGEBOB_IDLEMATURE",
"ANIM_SPONGEBOB_IDLEMOUSTACHE",
"ANIM_SPONGEBOB_IDLENOFACE",
"ANIM_SPONGEBOB_IDLEZORRO",
2001-07-02 22:15:14 +02:00
"ANIM_SPONGEBOB_CELEBRATE",
2001-08-13 23:25:06 +02:00
"ANIM_SPONGEBOB_IDLEBLINK",
2001-08-14 23:03:31 +02:00
"ANIM_SPONGEBOB_ELECTROCUTED",
2001-08-15 22:12:32 +02:00
"ANIM_SPONGEBOB_DEATHBOUNCE",
2001-07-02 22:15:14 +02:00
2001-06-25 22:25:28 +02:00
};
static const char *s_addonNames[NUM_PLAYER_ADDONS]=
{
"NET",
"CORALBLOWER",
"JELLYLAUNCHER",
"BUBBLEWAND",
"JELLYFISHINNET",
"GLOVE",
};
static CActorGfx *s_addonActorGfx[NUM_PLAYER_ADDONS];
2001-06-25 20:44:59 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CAnimTestScene::init()
{
m_font=new ("game over font") ScalableFontBank();
m_font->initialise(&standardFont);
2001-06-25 22:25:28 +02:00
m_font->setJustification(ScalableFontBank::JUST_LEFT);
2001-06-25 20:44:59 +02:00
m_font->setOt(5);
CActorPool::Reset();
m_actorSpongebob=CActorPool::GetActor(ACTORS_SPONGEBOB_SBK);
m_actorSpongebob->SetOtPos(5);
2001-06-25 22:25:28 +02:00
m_animNumber=0;
m_animFrame=0;
m_addonNumber=-1;
for(int i=0;i<NUM_PLAYER_ADDONS;i++)
{
s_addonActorGfx[i]=CActorPool::GetActor(s_addonActorPoolNames[i]);
s_addonActorGfx[i]->SetOtPos(4);
}
2001-06-25 20:44:59 +02:00
CActorPool::SetUpCache();
CActorPool::CleanUpCache();
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CAnimTestScene::render()
{
2001-06-25 22:25:28 +02:00
POLY_F4 *f4;
DVECTOR sbpos={100,130};
char buf[100];
int addonAnimNumber=-1;
f4=GetPrimF4();
setXYWH(f4,0,0,512,256);
setRGB0(f4,110,120,130);
AddPrimToList(f4,15);
if(m_addonNumber!=-1)
{
addonAnimNumber=s_animMapNet[m_addonNumber][m_animNumber];
2001-06-29 17:53:13 +02:00
if(m_animFrame>=s_addonActorGfx[m_addonNumber]->getFrameCount(addonAnimNumber))
{
addonAnimNumber=-2;
}
2001-06-25 22:25:28 +02:00
}
// Actor alone
m_actorSpongebob->Render(sbpos,m_animNumber,m_animFrame,0,0);
sbpos.vx+=150;
// Addon alone
2001-06-29 17:53:13 +02:00
if(addonAnimNumber>=0)
2001-06-25 22:25:28 +02:00
{
s_addonActorGfx[m_addonNumber]->Render(sbpos,addonAnimNumber,m_animFrame,0,0);
}
else
{
2001-06-29 17:53:13 +02:00
if(addonAnimNumber==-2)
{
m_font->setColour(255,0,0);
}
2001-06-25 22:25:28 +02:00
m_font->print(sbpos.vx,sbpos.vy-50,"x");
2001-06-29 17:53:13 +02:00
m_font->setColour(255,255,255);
2001-06-25 22:25:28 +02:00
}
sbpos.vx+=150;
// Actor+Addon
m_actorSpongebob->Render(sbpos,m_animNumber,m_animFrame,0,0);
2001-06-29 17:53:13 +02:00
if(addonAnimNumber>=0)
2001-06-25 22:25:28 +02:00
{
s_addonActorGfx[m_addonNumber]->Render(sbpos,addonAnimNumber,m_animFrame,0,0);
}
2001-06-25 20:44:59 +02:00
CActorPool::CleanUpCache();
2001-06-25 22:25:28 +02:00
sprintf(buf,"Use: Up/Down, Left/Right, L1/L2, Cross and Circle");
m_font->print(20,140,buf);
sprintf(buf,"Anim: %s",s_animNames[m_animNumber]);
m_font->print(20,180,buf);
sprintf(buf,"Frame: %d",m_animFrame);
m_font->print(20,195,buf);
if(m_addonNumber!=-1)
{
sprintf(buf,"Addon: %s",s_addonNames[m_addonNumber]);
m_font->print(20,210,buf);
}
2001-06-25 20:44:59 +02:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CAnimTestScene::think(int _frames)
{
2001-06-25 22:25:28 +02:00
int padRepeat,padHeld,padDown;
padRepeat=PadGetRepeat(0);
padHeld=PadGetHeld(0);
padDown=PadGetDown(0);
if(padRepeat&PAD_UP)
{
if(++m_animNumber==NUM_ANIM_SPONGEBOB)
{
m_animNumber=0;
}
m_animFrame=0;
}
else if(padRepeat&PAD_DOWN)
{
if(--m_animNumber<0)
{
m_animNumber=NUM_ANIM_SPONGEBOB-1;
}
m_animFrame=0;
}
if(padHeld&PAD_CROSS)
{
int fc=m_actorSpongebob->getFrameCount(m_animNumber);
m_animFrame+=_frames;
while(m_animFrame>=fc){m_animFrame-=fc;}
}
else if(padHeld&PAD_CIRCLE)
{
if(padDown&PAD_CIRCLE)
{
m_animFrame=0;
}
else
{
int fc=m_actorSpongebob->getFrameCount(m_animNumber);
m_animFrame+=_frames;
if(m_animFrame>=fc)m_animFrame=fc-1;
}
}
else if(padRepeat&PAD_RIGHT)
{
if(++m_animFrame==m_actorSpongebob->getFrameCount(m_animNumber))
{
m_animFrame=0;
}
}
else if(padRepeat&PAD_LEFT)
{
if(--m_animFrame<0)
{
m_animFrame=m_actorSpongebob->getFrameCount(m_animNumber)-1;
}
}
if(padRepeat&PAD_L1)
{
if(++m_addonNumber==NUM_PLAYER_ADDONS)
{
m_addonNumber=-1;
}
}
else if(padRepeat&PAD_L2)
{
if(--m_addonNumber<-1)
{
m_addonNumber=NUM_PLAYER_ADDONS-1;
}
}
2001-06-25 20:44:59 +02:00
}
2001-08-04 20:42:27 +02:00
#else
void AnimTestDummyStub()
{
}
#endif
2001-06-25 20:44:59 +02:00
/*===========================================================================
2001-06-25 22:25:28 +02:00
end */