1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#ifndef BLOCK_INCLUDED
#define BLOCK_INCLUDED
#include "GameObject.h"
class Block : public GameObject {
public:
// inColor must be destroyed by caller
Block( Color *inColor, char inColorCode );
// constructs a block by copying an overlay image
Block( Image *inOverlayImage, const char *inColorSignature );
// constructs a block from a color signature only
Block( const char *inColorSignature );
// constructs a compound block out of 4 sub-blocks
Block( Block *inBlocks[4] );
// constructs a block using a sprite
Block( Sprite *inSprite, const char *inColorSignature );
virtual ~Block();
Block *copy();
virtual char equal( Block *inBlock );
Image *getOverlayImage() {
return mOverlayImage;
}
char *getColorSignature() {
return mColorSignature;
}
// override default draw function
void draw( double inRotation, Vector3D *inPosition,
double inScale,
double inFadeFactor,
Color *inColor );
// override step function
virtual void step();
// shift vertically
void shiftTo( double inY );
// cancel shift, if one is in progress
void stopShifting();
// sets fade to 0 and fades in gradually
void fadeIn();
// must be called before first block is constructed
static void staticInit();
// must be called after last block is destroyed
static void staticFree();
// utility function for creating color signatures
static char *runLengthEncode( const char *inString );
// utility function for decompressing color signatures
static char *runLengthDecode( const char *inString );
protected:
// called by constructors
void initFromOverlay();
char *mColorSignature;
Image *mOverlayImage;
char mDeleteSprite;
Sprite *mSprite;
static Image *sBaseImage;
static Image *sNoiseImage;
char mShifting;
double mShiftTargetY;
char mFadingIn;
};
#endif
|