Platform game written for the GHI/OutrageousCircuits RETRO game device. Navigate the caves collecting all the pickups and avoiding the creatures and haunted mine carts that patrol the caves. Oh and remember to watch out for the poisonous plants... This game demonstrates the ability to have multiple animated sprites where the sprites can overlap the background environment. See how the player moves past the fence and climbs the wall in the 3rd screen.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Sprite.h Source File

Sprite.h

00001 #ifndef __SPRITE_H__
00002 #define __SPRITE_H__
00003 
00004 class Sprite
00005 {
00006     public:
00007         Sprite(const ImageFrame *frames[], uint8_t foregroundColor) :
00008             _frames(frames),
00009             _frameCount(0),
00010             _frameIndex(0),            
00011             _foregroundColor(foregroundColor)
00012         {            
00013             for(;; _frameCount++)
00014             {
00015                 if (frames[_frameCount] == NULL) break;
00016             }
00017             
00018         }
00019         
00020         void animate()
00021         {
00022             _frameIndex = (_frameIndex + 1) % _frameCount;  
00023         }
00024         
00025         uint8_t* getBits(int row) const
00026         {
00027             return _frames[_frameIndex]->getBits(row);
00028         }
00029         
00030         inline uint16_t getForegroundColor() const { return _foregroundColor; }
00031         
00032     private:
00033         const ImageFrame **_frames;
00034         uint8_t     _frameCount;
00035         uint8_t     _frameIndex;        
00036         uint8_t     _foregroundColor;                                
00037 };
00038 
00039 #endif //__SPRITE_H__
00040