This commit is contained in:
Paul 2000-10-18 18:36:52 +00:00
parent a8ae18ffb3
commit dfdce2f340
4 changed files with 377 additions and 232 deletions

View File

@ -34,6 +34,10 @@
#include "gfx\sprbank.h" #include "gfx\sprbank.h"
#endif #endif
#ifndef __SYSTEM_GSTATE_H__
#include "system\gstate.h"
#endif
/* Std Lib /* Std Lib
------- */ ------- */
@ -62,6 +66,25 @@
Vars Vars
---- */ ---- */
int CBubicleFactory::s_initialised=false;
CBubicleEmitter *CBubicleFactory::s_emitters;
CBubicle *CBubicleFactory::s_bubicles;
SpriteBank *CBubicleFactory::s_sprites;
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CBubicleEmitter::create()
{
m_active=false;
}
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Function: Function:
@ -69,22 +92,12 @@
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
static SpriteBank *sprites=NULL;
void CBubicleEmitter::init(BubicleEmitterData *_init) void CBubicleEmitter::init(BubicleEmitterData *_init)
{ {
for(int i=0;i<NUM_BUB;i++)
{
m_bubicles[i]=NULL;
}
m_frameCount=0;
m_data=*_init; m_data=*_init;
m_frameCount=0;
if(sprites==NULL) m_spawnFrameCount=0;
{ m_active=true;
sprites=new ("bubble sprites") SpriteBank();
sprites->load(INGAMEFX_INGAMEFX_SPR);
}
} }
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -93,40 +106,23 @@ if(sprites==NULL)
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CBubicleEmitter::think() void CBubicleEmitter::think(int _frames)
{ {
int birthAmount; m_frameCount+=_frames;
m_spawnFrameCount+=_frames;
if(m_spawnFrameCount>=m_data.m_birthRate)
birthAmount=0;
for(int i=0;i<NUM_BUB;i++)
{ {
if(m_bubicles[i]) for(int i=0;i<m_data.m_birthAmount;i++)
{ {
m_bubicles[i]->think(); if(CBubicleFactory::spawnParticle(&m_data)==NULL)
if(m_bubicles[i]->isDead()) break;
{
delete m_bubicles[i];
m_bubicles[i]=NULL;
}
}
else
{
if(m_frameCount>=m_data.m_birthRate)
{
birthAmount=m_data.m_birthAmount;
m_frameCount=0;
}
if(birthAmount)
{
m_bubicles[i]=createNewBubicle(&m_data);
birthAmount--;
}
} }
m_spawnFrameCount=0;
} }
if(m_data.m_life!=-1&&m_frameCount>m_data.m_life)
m_frameCount++; m_active=false;
} }
@ -136,14 +132,9 @@ void CBubicleEmitter::think()
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
#ifdef SHOW_BUBICLE_EMITTERS
void CBubicleEmitter::render() void CBubicleEmitter::render()
{ {
for(int i=0;i<NUM_BUB;i++)
{
if(m_bubicles[i])
m_bubicles[i]->render();
}
POLY_F4 *f4; POLY_F4 *f4;
f4=GetPrimF4(); f4=GetPrimF4();
setPolyF4(f4); setPolyF4(f4);
@ -153,6 +144,21 @@ void CBubicleEmitter::render()
setRGB0(f4,30,40,50); setRGB0(f4,30,40,50);
AddPrimToList(f4,m_data.m_bubicleBase.m_ot+1); AddPrimToList(f4,m_data.m_bubicleBase.m_ot+1);
} }
#endif
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CBubicleEmitter::kill()
{
ASSERT(m_active);
m_active=false;
}
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -163,6 +169,8 @@ void CBubicleEmitter::render()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CBubicleEmitter::setPos(int _x,int _y) void CBubicleEmitter::setPos(int _x,int _y)
{ {
ASSERT(m_active);
m_data.m_x=_x; m_data.m_x=_x;
m_data.m_y=_y; m_data.m_y=_y;
} }
@ -176,6 +184,8 @@ void CBubicleEmitter::setPos(int _x,int _y)
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CBubicleEmitter::setSize(int _w,int _h) void CBubicleEmitter::setSize(int _w,int _h)
{ {
ASSERT(m_active);
m_data.m_w=_w; m_data.m_w=_w;
m_data.m_h=_h; m_data.m_h=_h;
} }
@ -187,68 +197,11 @@ void CBubicleEmitter::setSize(int _w,int _h)
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int fixed=false; void CBubicle::create()
CBubicle *CBubicleEmitter::createNewBubicle(BubicleEmitterData *_init)
{ {
CBubicle *newBub; m_active=false;
BubicleData newBubData;
int x,y;
newBub=new ("CBubicle") CBubicle();
x=_init->m_x+getRndRange(_init->m_w);
y=_init->m_y+getRndRange(_init->m_h);
if(fixed)
{
newBubData.m_life=_init->m_bubicleBase.m_life;
newBubData.m_vx=_init->m_bubicleBase.m_vx;
newBubData.m_vdx=_init->m_bubicleBase.m_vdx;
newBubData.m_vxmax=_init->m_bubicleBase.m_vxmax;
newBubData.m_vy=_init->m_bubicleBase.m_vy;
newBubData.m_vdy=_init->m_bubicleBase.m_vdy;
newBubData.m_vymax=_init->m_bubicleBase.m_vymax;
newBubData.m_w=_init->m_bubicleBase.m_w;
newBubData.m_h=_init->m_bubicleBase.m_h;
newBubData.m_dvSizeChange=_init->m_bubicleBase.m_dvSizeChange;
newBubData.m_theta=_init->m_bubicleBase.m_theta;
newBubData.m_vtheta=_init->m_bubicleBase.m_vtheta;
newBubData.m_wobbleWidth=_init->m_bubicleBase.m_wobbleWidth;
newBubData.m_vwobbleWidth=_init->m_bubicleBase.m_vwobbleWidth;
newBubData.m_vdwobbleWidth=_init->m_bubicleBase.m_vdwobbleWidth;
newBubData.m_ot=_init->m_bubicleBase.m_ot;
newBubData.m_colour.m_r=_init->m_bubicleBase.m_colour.m_r;
newBubData.m_colour.m_g=_init->m_bubicleBase.m_colour.m_r;
newBubData.m_colour.m_b=_init->m_bubicleBase.m_colour.m_r;
}
else
{
newBubData.m_life=_init->m_bubicleBase.m_life+getRndRange(_init->m_bubicleRange.m_life);
newBubData.m_vx=_init->m_bubicleBase.m_vx+getRndRange(_init->m_bubicleRange.m_vx);
newBubData.m_vdx=_init->m_bubicleBase.m_vdx+getRndRange(_init->m_bubicleRange.m_vdx);
newBubData.m_vxmax=_init->m_bubicleBase.m_vxmax+getRndRange(_init->m_bubicleRange.m_vxmax);
newBubData.m_vy=_init->m_bubicleBase.m_vy+getRndRange(_init->m_bubicleRange.m_vy);
newBubData.m_vdy=_init->m_bubicleBase.m_vdy+getRndRange(_init->m_bubicleRange.m_vdy);
newBubData.m_vymax=_init->m_bubicleBase.m_vymax+getRndRange(_init->m_bubicleRange.m_vymax);
newBubData.m_w=_init->m_bubicleBase.m_w+getRndRange(_init->m_bubicleRange.m_w);
newBubData.m_h=_init->m_bubicleBase.m_h+getRndRange(_init->m_bubicleRange.m_h);
newBubData.m_dvSizeChange=_init->m_bubicleBase.m_dvSizeChange+getRndRange(_init->m_bubicleRange.m_dvSizeChange);
newBubData.m_theta=_init->m_bubicleBase.m_theta+getRndRange(_init->m_bubicleRange.m_theta);
newBubData.m_vtheta=_init->m_bubicleBase.m_vtheta+getRndRange(_init->m_bubicleRange.m_vtheta);
newBubData.m_wobbleWidth=_init->m_bubicleBase.m_wobbleWidth+getRndRange(_init->m_bubicleRange.m_wobbleWidth);
newBubData.m_vwobbleWidth=_init->m_bubicleBase.m_vwobbleWidth+getRndRange(_init->m_bubicleRange.m_vwobbleWidth);
newBubData.m_vdwobbleWidth=_init->m_bubicleBase.m_vdwobbleWidth+getRndRange(_init->m_bubicleRange.m_vdwobbleWidth);
newBubData.m_ot=_init->m_bubicleBase.m_ot+getRndRange(_init->m_bubicleRange.m_ot);
newBubData.m_colour.m_r=_init->m_bubicleBase.m_colour.m_r+getRndRange(_init->m_bubicleRange.m_colour.m_r);
newBubData.m_colour.m_g=_init->m_bubicleBase.m_colour.m_r+getRndRange(_init->m_bubicleRange.m_colour.m_g);
newBubData.m_colour.m_b=_init->m_bubicleBase.m_colour.m_r+getRndRange(_init->m_bubicleRange.m_colour.m_b);
} }
newBub->init(&newBubData,x,y);
return newBub;
}
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Function: Function:
@ -256,9 +209,10 @@ else
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
static int gaycount=0;
void CBubicle::init(BubicleData *_init,int _x,int _y) void CBubicle::init(BubicleData *_init,int _x,int _y)
{ {
static int frameType=0;
m_data=*_init; m_data=*_init;
m_x=(_x-(m_data.m_w>>1))<<ACCURACY_SHIFT; m_x=(_x-(m_data.m_w>>1))<<ACCURACY_SHIFT;
@ -273,10 +227,9 @@ void CBubicle::init(BubicleData *_init,int _x,int _y)
m_vSizeChange=0; m_vSizeChange=0;
m_frameCount=0; m_frameCount=0;
if((gaycount++)&0x31) m_fhBub=CBubicleFactory::getSprites()->getFrameHeader((frameType++)&0x31?FRM__BUBBLE_SMALL:FRM__BUBBLE_FLOWER);
m_fhBub=sprites->getFrameHeader(FRM__BUBBLE_SMALL);
else m_active=true;
m_fhBub=sprites->getFrameHeader(FRM__BUBBLE_FLOWER);
} }
@ -286,9 +239,11 @@ void CBubicle::init(BubicleData *_init,int _x,int _y)
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CBubicle::think() void CBubicle::think(int _frames)
{ {
if(!isDead()) ASSERT(isActive());
for(int i=0;i<_frames;i++) // Good or bad way to do this? Alternative is a bunch of multiplies..
{ {
if(m_x!=m_data.m_vxmax) if(m_x!=m_data.m_vxmax)
{ {
@ -323,9 +278,9 @@ void CBubicle::think()
m_data.m_vy=m_data.m_vymax; m_data.m_vy=m_data.m_vymax;
} }
} }
m_data.m_theta=(m_data.m_theta+m_data.m_vtheta)&4095; m_data.m_theta=(m_data.m_theta+m_data.m_vtheta)&4095;
m_data.m_wobbleWidth+=m_data.m_vwobbleWidth; m_data.m_wobbleWidth+=m_data.m_vwobbleWidth;
m_data.m_vwobbleWidth+=m_data.m_vdwobbleWidth; m_data.m_vwobbleWidth+=m_data.m_vdwobbleWidth;
@ -346,11 +301,13 @@ void CBubicle::think()
m_vSizeChange-=m_data.m_dvSizeChange; m_vSizeChange-=m_data.m_dvSizeChange;
m_data.m_h+=m_vSizeChange; m_data.m_h+=m_vSizeChange;
} }
m_frameCount++; //PKG
} }
}
m_frameCount+=_frames;
if(m_frameCount>m_data.m_life)
m_active=false;
}
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -361,22 +318,104 @@ void CBubicle::think()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CBubicle::render() void CBubicle::render()
{ {
if(!isDead()) ASSERT(isActive());
POLY_FT4 *ft4;
int x,y,w,h;
x=m_x>>ACCURACY_SHIFT;
y=m_y>>ACCURACY_SHIFT;
w=m_data.m_w>>ACCURACY_SHIFT;
h=m_data.m_h>>ACCURACY_SHIFT;
x+=(msin(m_data.m_theta)*(m_data.m_wobbleWidth>>ACCURACY_SHIFT))>>12;
ft4=CBubicleFactory::getSprites()->printFT4(m_fhBub,0,0,0,0,m_data.m_ot);
setXYWH(ft4,x,y,w,h);
setSemiTrans(ft4,1);
setRGB0(ft4,m_data.m_colour.m_r,m_data.m_colour.m_g,m_data.m_colour.m_b);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CBubicleFactory::init()
{
int i;
CBubicleEmitter *emt;
CBubicle *bub;
s_sprites=new ("Bubble Sprites") SpriteBank();
s_sprites->load(INGAMEFX_INGAMEFX_SPR);
emt=s_emitters=(CBubicleEmitter*)MemAlloc(sizeof(CBubicleEmitter)*NUM_EMITTERS,"BubicleEmitters");
for(i=0;i<NUM_EMITTERS;i++,emt++)
emt->create();
bub=s_bubicles=(CBubicle*)MemAlloc(sizeof(CBubicle)*NUM_BUBICLES,"Bubicles");
for(i=0;i<NUM_BUBICLES;i++,bub++)
bub->create();
SYSTEM_DBGMSG("CBubicleFactory::init ( allocated %d bytes )",(sizeof(CBubicleEmitter)*NUM_EMITTERS)+(sizeof(CBubicle)*NUM_BUBICLES));
s_initialised=true;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CBubicleFactory::shutdown()
{
ASSERT(s_initialised);
MemFree(s_emitters);
MemFree(s_bubicles);
s_sprites->dump(); delete s_sprites;
s_initialised=false;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CBubicleFactory::think()
{
ASSERT(s_initialised);
int frames;
int i;
CBubicleEmitter *emt;
CBubicle *bub;
frames=GameState::getFramesSinceLast();
emt=s_emitters;
for(i=0;i<NUM_EMITTERS;i++,emt++)
{ {
POLY_FT4 *ft4; if(emt->isActive())
int x,y,w,h; emt->think(frames);
}
x=m_x>>ACCURACY_SHIFT; bub=s_bubicles;
y=m_y>>ACCURACY_SHIFT; for(i=0;i<NUM_BUBICLES;i++,bub++)
w=m_data.m_w>>ACCURACY_SHIFT; {
h=m_data.m_h>>ACCURACY_SHIFT; if(bub->isActive())
bub->think(frames);
x+=(msin(m_data.m_theta)*(m_data.m_wobbleWidth>>ACCURACY_SHIFT))>>12;
ft4=sprites->printFT4((sFrameHdr*)m_fhBub,0,0,0,0,m_data.m_ot);
setXYWH(ft4,x,y,w,h);
setSemiTrans(ft4,1);
setRGB0(ft4,m_data.m_colour.m_r,m_data.m_colour.m_g,m_data.m_colour.m_b);
} }
} }
@ -387,9 +426,112 @@ void CBubicle::render()
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int CBubicle::isDead() void CBubicleFactory::render()
{ {
return m_frameCount>m_data.m_life||m_y<0; ASSERT(s_initialised);
int i;
CBubicleEmitter *emt;
CBubicle *bub;
#ifdef SHOW_BUBICLE_EMITTERS
emt=s_emitters;
for(i=0;i<NUM_EMITTERS;i++,emt++)
{
if(emt->isActive())
emt->render();
}
#endif
bub=s_bubicles;
for(i=0;i<NUM_BUBICLES;i++,bub++)
{
if(bub->isActive())
bub->render();
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
CBubicleEmitter *CBubicleFactory::spawnEmitter(BubicleEmitterData *_init)
{
ASSERT(s_initialised);
int i;
CBubicleEmitter *emt;
emt=s_emitters;
for(i=0;i<NUM_EMITTERS;i++,emt++)
{
if(!emt->isActive())
{
emt->init(_init);
return emt;
}
}
SYSTEM_DBGMSG("Out of CBubicleEmitters!");
return NULL;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
CBubicle *CBubicleFactory::spawnParticle(BubicleEmitterData *_init)
{
ASSERT(s_initialised);
int i;
CBubicle *bub;
bub=s_bubicles;
for(i=0;i<NUM_BUBICLES;i++,bub++)
{
if(!bub->isActive())
{
BubicleData newBubData;
int x,y;
x=_init->m_x+getRndRange(_init->m_w);
y=_init->m_y+getRndRange(_init->m_h);
newBubData.m_life=_init->m_bubicleBase.m_life+getRndRange(_init->m_bubicleRange.m_life);
newBubData.m_vx=_init->m_bubicleBase.m_vx+getRndRange(_init->m_bubicleRange.m_vx);
newBubData.m_vdx=_init->m_bubicleBase.m_vdx+getRndRange(_init->m_bubicleRange.m_vdx);
newBubData.m_vxmax=_init->m_bubicleBase.m_vxmax+getRndRange(_init->m_bubicleRange.m_vxmax);
newBubData.m_vy=_init->m_bubicleBase.m_vy+getRndRange(_init->m_bubicleRange.m_vy);
newBubData.m_vdy=_init->m_bubicleBase.m_vdy+getRndRange(_init->m_bubicleRange.m_vdy);
newBubData.m_vymax=_init->m_bubicleBase.m_vymax+getRndRange(_init->m_bubicleRange.m_vymax);
newBubData.m_w=_init->m_bubicleBase.m_w+getRndRange(_init->m_bubicleRange.m_w);
newBubData.m_h=_init->m_bubicleBase.m_h+getRndRange(_init->m_bubicleRange.m_h);
newBubData.m_dvSizeChange=_init->m_bubicleBase.m_dvSizeChange+getRndRange(_init->m_bubicleRange.m_dvSizeChange);
newBubData.m_theta=_init->m_bubicleBase.m_theta+getRndRange(_init->m_bubicleRange.m_theta);
newBubData.m_vtheta=_init->m_bubicleBase.m_vtheta+getRndRange(_init->m_bubicleRange.m_vtheta);
newBubData.m_wobbleWidth=_init->m_bubicleBase.m_wobbleWidth+getRndRange(_init->m_bubicleRange.m_wobbleWidth);
newBubData.m_vwobbleWidth=_init->m_bubicleBase.m_vwobbleWidth+getRndRange(_init->m_bubicleRange.m_vwobbleWidth);
newBubData.m_vdwobbleWidth=_init->m_bubicleBase.m_vdwobbleWidth+getRndRange(_init->m_bubicleRange.m_vdwobbleWidth);
newBubData.m_ot=_init->m_bubicleBase.m_ot+getRndRange(_init->m_bubicleRange.m_ot);
newBubData.m_colour.m_r=_init->m_bubicleBase.m_colour.m_r+getRndRange(_init->m_bubicleRange.m_colour.m_r);
newBubData.m_colour.m_g=_init->m_bubicleBase.m_colour.m_r+getRndRange(_init->m_bubicleRange.m_colour.m_g);
newBubData.m_colour.m_b=_init->m_bubicleBase.m_colour.m_r+getRndRange(_init->m_bubicleRange.m_colour.m_b);
bub->init(&newBubData,x,y);
return bub;
}
}
SYSTEM_DBGMSG("Out of CBubicles!");
return NULL;
} }

View File

@ -18,6 +18,11 @@
Includes Includes
-------- */ -------- */
#ifndef __GFX_SPRBANK_H__
#include "gfx\sprbank.h"
#endif
/* Std Lib /* Std Lib
------- */ ------- */
@ -25,104 +30,159 @@
Tyepdefs && Defines Tyepdefs && Defines
------------------- */ ------------------- */
// Uncomment to see the emitters on screen
#ifdef __USER_paul__
#define SHOW_BUBICLE_EMITTERS
#endif
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Structure defintions Structure defintions
-------------------- */ -------------------- */
//
// An individual particle and it's associated data
//
typedef struct RGBPack typedef struct RGBPack
{ {
unsigned char m_r,m_g,m_b; unsigned char m_r,m_g,m_b;
}; };
// particle
typedef struct typedef struct
{ {
int m_life; int m_life;
int m_vx,m_vdx,m_vxmax; int m_vx,m_vdx,m_vxmax;
int m_vy,m_vdy,m_vymax; int m_vy,m_vdy,m_vymax;
int m_w,m_h; int m_w,m_h;
int m_dvSizeChange; int m_dvSizeChange;
int m_theta,m_vtheta; int m_theta,m_vtheta;
int m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth; int m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth;
int m_ot; int m_ot;
RGBPack m_colour; RGBPack m_colour;
} BubicleData; } BubicleData;
class CBubicle class CBubicle
{ {
public: // We don't really want anyone to instantiate this themselves.. only the factory is allowed to
private:
enum enum
{ {
ACCURACY_SHIFT=6, ACCURACY_SHIFT=6,
}; };
CBubicle() {;}
void create();
void init(BubicleData *_init,int _x,int _y); void init(BubicleData *_init,int _x,int _y);
void think(); void think(int _frames);
void render(); void render();
int isDead(); int isActive() {return m_active;}
int m_active;
private:
int m_x; int m_x;
int m_y; int m_y;
int m_typeSizeChange; // 0=Width, 1=Height int m_typeSizeChange; // 0=Width, 1=Height
int m_vSizeChange; int m_vSizeChange;
int m_frameCount; int m_frameCount;
void *m_fhBub; // FFS! Go on.. try and make this an sFrameHdr * sFrameHdr *m_fhBub;
BubicleData m_data; BubicleData m_data;
friend class CBubicleFactory;
friend class CBubicleEmitter;
}; };
// emitter
//
// An emitter
//
typedef struct typedef struct
{ {
int m_x,m_y,m_w,m_h; int m_x,m_y,m_w,m_h;
int m_birthRate,m_birthAmount; int m_birthRate,m_birthAmount;
int m_life; // -1 for infinite life
BubicleData m_bubicleBase; BubicleData m_bubicleBase;
BubicleData m_bubicleRange; BubicleData m_bubicleRange;
} BubicleEmitterData; } BubicleEmitterData;
class CBubicleEmitter class CBubicleEmitter
{ {
public: public:
enum{NUM_BUB=400}; void kill();
void setPos(int _x,int _y);
void setSize(int _w,int _h);
void setPosAndSize(int _x,int _y,int _w,int _h) {setPos(_x,_y);setSize(_w,_h);}
void init(BubicleEmitterData *_init); int isActive() {return m_active;}
void think();
void render();
void setPos(int _x,int _y);
void setSize(int _w,int _h);
void setPosAndSize(int _x,int _y,int _w,int _h) {setPos(_x,_y);setSize(_w,_h);}
private: private:
CBubicleEmitter() {;}
void create();
void init(BubicleEmitterData *_init);
void think(int _frames);
#ifdef SHOW_BUBICLE_EMITTERS
void render();
#endif
static CBubicle *createNewBubicle(BubicleEmitterData *_init); int m_active;
// static void removeBubicle();
BubicleEmitterData m_data; BubicleEmitterData m_data;
int m_x,m_y,m_w,m_h; int m_frameCount;
int m_birthRate; int m_spawnFrameCount;
int m_frameCount;
CBubicle *m_bubicles[NUM_BUB]; friend class CBubicleFactory;
// static int s_numBubble
}; };
//
// Particle factory
//
class CBubicleFactory
{
public:
static void init();
static void shutdown();
static void think();
static void render();
static CBubicleEmitter *spawnEmitter(BubicleEmitterData *_init);
static CBubicle *spawnParticle(BubicleEmitterData *_init);
static SpriteBank *getSprites() {return s_sprites;}
private:
enum
{
NUM_EMITTERS=10,
NUM_BUBICLES=200,
};
CBubicleFactory() {;}
static int s_initialised;
static CBubicleEmitter *s_emitters;
static CBubicle *s_bubicles;
static SpriteBank *s_sprites;
};
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Globals Globals

View File

@ -42,10 +42,6 @@
#include "pad\pads.h" #include "pad\pads.h"
#endif #endif
#ifndef __GFX_BUBICLES__
#include "gfx\bubicles.h"
#endif
#ifndef __GFX_SPRBANK_H__ #ifndef __GFX_SPRBANK_H__
#include "gfx\sprbank.h" #include "gfx\sprbank.h"
#endif #endif
@ -78,7 +74,6 @@
Vars Vars
---- */ ---- */
static FontBank s_fontBank; static FontBank s_fontBank;
char *s_mem[3];
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -89,36 +84,6 @@ char *s_mem[3];
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int ploopid1=0; int ploopid1=0;
int ploopid2=0; int ploopid2=0;
BubicleEmitterData data=
{
206,200,40,40, // m_x,m_y,m_w,m_h
3,1, // m_birthRate,m_birthAmount
{ // m_bubicleBase
100, // m_life
0,0,0, // m_vx,m_vdx,m_vxmax
-40,-15,-200, // m_vy,m_vdy,m_vymax
13,10, // m_w,m_h
10, // m_dvSizeChange
0,100, // m_theta,m_vtheta
100,2,0, // m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth
40, // m_ot
{ 128,128,128, } // m_colour
},
{ // m_bubicleRange
100, // m_life
0,0,0, // m_vx,m_vdx,m_vxmax
20,10,0, // m_vy,m_vdy,m_vymax
5,5, // m_w,m_h
10, // m_dvSizeChange
4095,50, // m_theta,m_vtheta
100,5,0, // m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth
0, // m_ot
{ 0, 64,127, } // m_colour
}
};
CBubicleEmitter tb;
int tbx=64,tby=230;
int tbw=512-128,tbh=20;
static SpriteBank *sprites=NULL; static SpriteBank *sprites=NULL;
@ -139,8 +104,6 @@ void CPaulScene::init()
ploopid1=CSoundMediator::playSfx(0); ploopid1=CSoundMediator::playSfx(0);
ploopid2=CSoundMediator::playSfx(0); ploopid2=CSoundMediator::playSfx(0);
tb.init(&data);
sprites=new ("bg sprite") SpriteBank(); sprites=new ("bg sprite") SpriteBank();
sprites->load(INGAMEFX_INGAMEFX_SPR); sprites->load(INGAMEFX_INGAMEFX_SPR);
} }
@ -177,8 +140,6 @@ void CPaulScene::render()
y+=charHeight; y+=charHeight;
} }
tb.render();
POLY_FT4 *ft4=sprites->printFT4(FRM_BACKGROUND,0,0,0,0,1023); POLY_FT4 *ft4=sprites->printFT4(FRM_BACKGROUND,0,0,0,0,1023);
setXYWH(ft4,20,20,512-40,256-40); setXYWH(ft4,20,20,512-40,256-40);
setRGB0(ft4,64,64,64); setRGB0(ft4,64,64,64);
@ -208,7 +169,6 @@ void CPaulScene::think()
pad=PadGetDown(0); pad=PadGetDown(0);
if(pad&PAD_R1) if(pad&PAD_R1)
{ {
tb.init(&data);
PAUL_DBGMSG("-------------------"); PAUL_DBGMSG("-------------------");
} }
else if(pad&PAD_CROSS) else if(pad&PAD_CROSS)
@ -296,29 +256,11 @@ void CPaulScene::think()
pad=PadGetHeld(1); pad=PadGetHeld(1);
if(pad&PAD_L1) if(pad&PAD_L1)
{ {
if(pad&PAD_UP)
tbh--;
if(pad&PAD_DOWN)
tbh++;
if(pad&PAD_LEFT)
tbw--;
if(pad&PAD_RIGHT)
tbw++;
} }
else else
{ {
if(pad&PAD_UP)
tby-=5;
if(pad&PAD_DOWN)
tby+=5;
if(pad&PAD_LEFT)
tbx-=5;
if(pad&PAD_RIGHT)
tbx+=5;
} }
tb.setPosAndSize(tbx,tby,tbw,tbh);
tb.think();
} }

View File

@ -102,6 +102,7 @@ void GameState::updateTimer()
if (s_timeSinceLast > 4 * 4096) if (s_timeSinceLast > 4 * 4096)
{ {
s_timeSinceLast = 4 * 4096; s_timeSinceLast = 4 * 4096;
SYSTEM_DBGMSG("updateTimer loosing frames!");
} }
} }