This commit is contained in:
parent
a8ae18ffb3
commit
dfdce2f340
4 changed files with 377 additions and 232 deletions
|
@ -18,6 +18,11 @@
|
|||
Includes
|
||||
-------- */
|
||||
|
||||
#ifndef __GFX_SPRBANK_H__
|
||||
#include "gfx\sprbank.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
||||
|
@ -25,104 +30,159 @@
|
|||
Tyepdefs && Defines
|
||||
------------------- */
|
||||
|
||||
// Uncomment to see the emitters on screen
|
||||
#ifdef __USER_paul__
|
||||
#define SHOW_BUBICLE_EMITTERS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
|
||||
//
|
||||
// An individual particle and it's associated data
|
||||
//
|
||||
|
||||
typedef struct RGBPack
|
||||
{
|
||||
unsigned char m_r,m_g,m_b;
|
||||
};
|
||||
|
||||
|
||||
// particle
|
||||
typedef struct
|
||||
{
|
||||
int m_life;
|
||||
int m_vx,m_vdx,m_vxmax;
|
||||
int m_vy,m_vdy,m_vymax;
|
||||
int m_w,m_h;
|
||||
int m_dvSizeChange;
|
||||
int m_theta,m_vtheta;
|
||||
int m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth;
|
||||
int m_ot;
|
||||
RGBPack m_colour;
|
||||
int m_life;
|
||||
int m_vx,m_vdx,m_vxmax;
|
||||
int m_vy,m_vdy,m_vymax;
|
||||
int m_w,m_h;
|
||||
int m_dvSizeChange;
|
||||
int m_theta,m_vtheta;
|
||||
int m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth;
|
||||
int m_ot;
|
||||
RGBPack m_colour;
|
||||
} BubicleData;
|
||||
|
||||
|
||||
class CBubicle
|
||||
{
|
||||
public:
|
||||
// We don't really want anyone to instantiate this themselves.. only the factory is allowed to
|
||||
private:
|
||||
enum
|
||||
{
|
||||
ACCURACY_SHIFT=6,
|
||||
};
|
||||
|
||||
CBubicle() {;}
|
||||
|
||||
void create();
|
||||
void init(BubicleData *_init,int _x,int _y);
|
||||
|
||||
void think();
|
||||
void think(int _frames);
|
||||
void render();
|
||||
|
||||
int isDead();
|
||||
int isActive() {return m_active;}
|
||||
|
||||
|
||||
int m_active;
|
||||
|
||||
private:
|
||||
int m_x;
|
||||
int m_y;
|
||||
int m_typeSizeChange; // 0=Width, 1=Height
|
||||
int m_vSizeChange;
|
||||
int m_frameCount;
|
||||
void *m_fhBub; // FFS! Go on.. try and make this an sFrameHdr *
|
||||
sFrameHdr *m_fhBub;
|
||||
|
||||
BubicleData m_data;
|
||||
|
||||
|
||||
friend class CBubicleFactory;
|
||||
friend class CBubicleEmitter;
|
||||
};
|
||||
|
||||
|
||||
// emitter
|
||||
|
||||
//
|
||||
// An emitter
|
||||
//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int m_x,m_y,m_w,m_h;
|
||||
int m_birthRate,m_birthAmount;
|
||||
int m_x,m_y,m_w,m_h;
|
||||
int m_birthRate,m_birthAmount;
|
||||
int m_life; // -1 for infinite life
|
||||
|
||||
BubicleData m_bubicleBase;
|
||||
BubicleData m_bubicleRange;
|
||||
BubicleData m_bubicleBase;
|
||||
BubicleData m_bubicleRange;
|
||||
} BubicleEmitterData;
|
||||
|
||||
class CBubicleEmitter
|
||||
{
|
||||
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);
|
||||
|
||||
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);}
|
||||
int isActive() {return m_active;}
|
||||
|
||||
|
||||
private:
|
||||
CBubicleEmitter() {;}
|
||||
|
||||
void create();
|
||||
void init(BubicleEmitterData *_init);
|
||||
|
||||
void think(int _frames);
|
||||
#ifdef SHOW_BUBICLE_EMITTERS
|
||||
void render();
|
||||
#endif
|
||||
|
||||
|
||||
static CBubicle *createNewBubicle(BubicleEmitterData *_init);
|
||||
// static void removeBubicle();
|
||||
|
||||
|
||||
int m_active;
|
||||
BubicleEmitterData m_data;
|
||||
int m_x,m_y,m_w,m_h;
|
||||
int m_birthRate;
|
||||
int m_frameCount;
|
||||
int m_frameCount;
|
||||
int m_spawnFrameCount;
|
||||
|
||||
CBubicle *m_bubicles[NUM_BUB];
|
||||
// static int s_numBubble
|
||||
friend class CBubicleFactory;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue