home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
BARNHART
/
SCENES.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-15
|
3KB
|
164 lines
// scenes.cpp
// this file sets up the scenes for the game, of which there are currently
// only two
// Scenes _should_ be an object, but are not for an obscure reason having
// more to do with time of night it was begun than anything else...
#include <so_all.hpp>
extern int WinX, WinY, WinSX, WinSY;
typedef void INITFUNC( void);
typedef INITFUNC *IFPTR;
#define NUMSCENES 2
void Scene1( void);
void Scene2( void);
// An array of function pointers, one per scene
static IFPTR ifptrs[NUMSCENES] =
{
Scene1,
Scene2
};
static BOOL SceneShown = FALSE;
// An array is kept for each type with a count of current created
static int nWalls = 0;
static int cWall = 0;
static Wall * walls[64];
static int nRungs = 0;
static Rungs * rungs[64];
static int nCreepers = 0;
static Creeper * creepers[16];
static int nMotions = 0;
static StillMotion * motions[32];
static int nDoors = 0;
static Door * doors[8];
static int nPrizes = 0;
static Prize * prizes[32];
// Initialize the scene, cleaning up after last if necessary
BOOL InitScene( int scene)
{
if( scene > NUMSCENES ) return FALSE;
if( SceneShown) DeleteScene();
SceneShown = TRUE;
ifptrs[scene - 1]();
return TRUE;
}
// Show all items in the scene except the missiles
void ShowScene( void)
{
ScreenObj * nso;
InvalidateRect( ScreenObj::hWnd, NULL, FALSE);
WinSX = 0;
WinSY = 0;
SetWindowOrg( ScreenObj::hDC, WinSX, WinSY);
for( nso = ScreenObj::Background; nso != NULL; nso = nso->Next())
if( nso->SOType != TYPE_MISSILE)
nso->Show( TRUE);
}
// Delete all the ScreenItems
void DeleteScene( void)
{
while(nWalls)
delete walls[--nWalls];
while(nRungs)
delete rungs[--nRungs];
while(nCreepers)
delete creepers[--nCreepers];
while(nMotions)
delete motions[--nMotions];
while(nDoors)
delete doors[--nDoors];
while(nPrizes)
delete prizes[--nPrizes];
}
// Create objects - these are not just convenient, but required in our
// current scheme
StillMotion * AddMotion( char *res, int ix, int iy, int nframes, int per)
{
StillMotion * sm;
sm = new StillMotion( res, ix, iy, nframes, per);
motions[nMotions++] = sm;
return( sm);
}
Wall * AddWall( char *res, int ix, int iy, int len, int vert)
{
Wall *w;
w = new Wall( res, ix, iy, len, vert);
walls[nWalls++] = w;
return( w);
}
Wall * FirstWall( void)
{
cWall = -1;
return( NextWall());
}
Wall * NextWall( void)
{
cWall++;
if( (cWall < 0) || (cWall >= nWalls) ) return( NULL);
else return (walls[cWall]);
}
Rungs * AddRungs( char *res, int ix, int iy, int len, int vert)
{
Rungs * r;
r = new Rungs( res, ix, iy, len, vert);
rungs[nRungs++] = r;
return( r);
}
Creeper * AddCreeper( char *res, Wall *wall, int ibx, int iex)
{
Creeper *c;
c = new Creeper( res, wall, ibx, iex);
creepers[nCreepers++] = c;
return( c);
}
Door * AddDoor( char *res, int ix, int iy, long nfo)
{
Door *d;
d = new Door( res, ix, iy, nfo);
doors[nDoors++] = d;
return( d);
}
Prize * AddPrize( char *res, int ix, int iy, long nfo)
{
Prize *p;
p = new Prize( res, ix, iy, nfo);
prizes[nPrizes++] = p;
return ( p);
}