home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
BARNHART
/
SO_WALL.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-21
|
2KB
|
79 lines
// so_wall.cpp - implements objects Wall and Rungs
// Andy Barnhart
// This program is provided as a sample to accompany an article on graphics
// animation using C++
// This seems to work for me and I hope it works for you. No other warranty
// is expressed or implied.
#include <so_all.hpp>
// These objects as very trivial. All they do are create one or more ScreenItem
// objects which are each pieces of the wall, in either a vertical or
// horizontal manner. They are not true aggregate objects, however. The
// objects they create are not "owned", but created in the constructor
// and deleted in the destructor, but left to their own inherent behavior
// during play.
Wall::Wall( char *res, int ix, int iy, int len, int vert)
: ScreenItem( res, ix, iy)
{
SOType = TYPE_WALL;
mems = len;
if( vert)
hmult = len;
else
wmult = len;
dir = vert;
if( len > 1)
{
int i;
for (i = 1; i < len; i++)
{
if( vert)
iy += height;
else
ix += width;
lastmem = new ScreenItem( res, ix, iy);
lastmem->SOType = TYPE_WALL;
}
}
else
{
lastmem = NULL;
}
}
Wall::~Wall( void)
{
if( lastmem != NULL)
{
ScreenItem *cur, *nxt;
cur = (ScreenItem *) Next();
while( cur != lastmem)
{
nxt = (ScreenItem *) cur->Next();
delete( cur);
cur = nxt;
}
delete( lastmem);
}
}
Rungs::Rungs(char *res, int ix, int iy, int len, int vert)
: Wall( res, ix, iy, len, vert)
{
if( lastmem != NULL)
{
ScreenItem *cur;
cur = (ScreenItem *) Next();
while( cur != lastmem)
{
cur->SOType = TYPE_RUNGS;
cur = (ScreenItem *) cur->Next();
}
lastmem->SOType = TYPE_RUNGS;
}
SOType = TYPE_RUNGS;
}