This commit is contained in:
Paul 2000-11-20 15:31:03 +00:00
parent 645d1c739e
commit acc7bdf7d9
2 changed files with 320 additions and 0 deletions

241
source/gfx/fader.cpp Normal file
View File

@ -0,0 +1,241 @@
/*=========================================================================
fader.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "fader.h"
#ifndef __PRIM_HEADER__
#include "gfx\prim.h"
#endif
#ifndef __GFX_BUBICLES_H__
#include "gfx\bubicles.h"
#endif
/* Std Lib
------- */
/* Data
---- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
int CFader::s_fadeLine=0;
CFader::FADE_MODE CFader::s_fadeMode=FADED_IN;
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
BubicleEmitterData s_fadeBubicleSpawner=
{
0,0,512,40, // m_x,m_y,m_w,m_h
0,0, // m_birthRate,m_birthAmount
0, // m_life
// m_bubicleBase
{
10, // m_life
0,0,0, // m_vx,m_vdx,m_vxmax
-200,0,0, // m_vy,m_vdy,m_vymax
10,7, // m_w,m_h
0, // m_dvSizeChange
0,0, // m_theta,m_vtheta
0,0,0, // m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth
0, // m_ot
{220,220,220} // m_colour
},
// m_bubicleRange;
{
10, // m_life
0,0,0, // m_vx,m_vdx,m_vxmax
50,0,0, // m_vy,m_vdy,m_vymax
3,3, // m_w,m_h
0, // m_dvSizeChange
0,100, // m_theta,m_vtheta
10,0,0, // m_wobbleWidth,m_vwobbleWidth,m_vdwobbleWidth
0, // m_ot
{30,30,30} // m_colour
}
};
void CFader::render()
{
switch(s_fadeMode)
{
case FADED_IN:
return;
case FADING_IN:
{
if(s_fadeLine>0)
{
POLY_F4 *f4;
POLY_G4 *g4;
POLY_FT3 *ft3;
f4=GetPrimF4();
setXYWH(f4,0,-FADE_BORDER_SIZE,512,s_fadeLine-(FADE_SMOOTH_BORDER_SIZE/2)+FADE_BORDER_SIZE);
setRGB0(f4,255,255,255);
AddPrimToList(f4,0);
g4=GetPrimG4();
setXYWH(g4,0,s_fadeLine-(FADE_SMOOTH_BORDER_SIZE/2),512,FADE_SMOOTH_BORDER_SIZE);
setRGB0(g4,255,255,255);
setRGB1(g4,255,255,255);
setRGB2(g4,0,0,0);
setRGB3(g4,0,0,0);
setShadeTex(g4,0);
setSemiTrans(g4,1);
AddPrimToList(g4,0);
ft3=GetPrimFT3();
setShadeTex(ft3,1);
setSemiTrans(ft3,1);
ft3->tpage=(1<<5);
setXY3(ft3,512,512,512,512,512,512);
AddPrimToList(ft3,0);
}
}
break;
case FADING_OUT:
{
POLY_F4 *f4;
POLY_G4 *g4;
POLY_FT3 *ft3;
f4=GetPrimF4();
setXYWH(f4,0,s_fadeLine+(FADE_SMOOTH_BORDER_SIZE/2),512,256-s_fadeLine-(FADE_SMOOTH_BORDER_SIZE/2));
setRGB0(f4,255,255,255);
AddPrimToList(f4,0);
g4=GetPrimG4();
setXYWH(g4,0,s_fadeLine-(FADE_SMOOTH_BORDER_SIZE/2),512,FADE_SMOOTH_BORDER_SIZE);
setRGB0(g4,0,0,0);
setRGB1(g4,0,0,0);
setRGB2(g4,255,255,255);
setRGB3(g4,255,255,255);
setShadeTex(g4,0);
setSemiTrans(g4,1);
AddPrimToList(g4,0);
ft3=GetPrimFT3();
setShadeTex(ft3,1);
setSemiTrans(ft3,1);
ft3->tpage=(1<<5);
setXY3(ft3,512,512,512,512,512,512);
AddPrimToList(ft3,0);
}
break;
case FADED_OUT:
{
POLY_F4 *f4;
f4=GetPrimF4();
setXYWH(f4,0,0,512,256);
setRGB0(f4,255,255,255);
AddPrimToList(f4,1);
return;
}
}
s_fadeBubicleSpawner.m_y=s_fadeLine-20;
for(int i=0;i<BUBBLES_PER_FRAME;i++)
CBubicleFactory::spawnParticle(&s_fadeBubicleSpawner);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::think(int _frames)
{
if(s_fadeMode!=FADED_IN&&s_fadeMode!=FADED_OUT)
{
s_fadeLine-=_frames*FADE_SPEED;
if(s_fadeLine<-FADE_BORDER_SIZE)
{
s_fadeMode=s_fadeMode==FADING_OUT?FADED_OUT:FADED_IN;
}
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::setFadingOut()
{
s_fadeLine=256+FADE_BORDER_SIZE;
s_fadeMode=FADING_OUT;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::setFadingIn()
{
s_fadeLine=256+FADE_BORDER_SIZE;
s_fadeMode=FADING_IN;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CFader::isFading()
{
return s_fadeMode==FADING_IN||s_fadeMode==FADING_OUT;
}
/*===========================================================================
end */

79
source/gfx/fader.h Normal file
View File

@ -0,0 +1,79 @@
/*=========================================================================
fader.h
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
#ifndef __GFX_FADER_H__
#define __GFX_FADER_H__
/*----------------------------------------------------------------------
Includes
-------- */
/* Std Lib
------- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
class CFader
{
public:
static void render();
static void think(int _frames);
static void setFadingOut();
static void setFadingIn();
static int isFading();
private:
enum
{
FADE_BORDER_SIZE=80,
FADE_SMOOTH_BORDER_SIZE=60,
BUBBLES_PER_FRAME=30,
FADE_SPEED=3,
};
typedef enum _fade_mode
{
FADED_IN,
FADING_IN,
FADING_OUT,
FADED_OUT,
} FADE_MODE;
static FADE_MODE s_fadeMode;
static int s_fadeLine;
};
/*----------------------------------------------------------------------
Globals
------- */
/*----------------------------------------------------------------------
Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* __GFX_FADER_H__ */
/*===========================================================================
end */