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

Committer:
taylorza
Date:
Mon Feb 16 03:46:57 2015 +0000
Revision:
16:f9227904afc4
Parent:
9:34008d8b1cdf
Added a 4th game screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
taylorza 9:34008d8b1cdf 1 #ifndef __SPRITE_H__
taylorza 9:34008d8b1cdf 2 #define __SPRITE_H__
taylorza 9:34008d8b1cdf 3
taylorza 9:34008d8b1cdf 4 class Sprite
taylorza 9:34008d8b1cdf 5 {
taylorza 9:34008d8b1cdf 6 public:
taylorza 9:34008d8b1cdf 7 Sprite(const ImageFrame *frames[], uint8_t foregroundColor) :
taylorza 9:34008d8b1cdf 8 _frames(frames),
taylorza 9:34008d8b1cdf 9 _frameCount(0),
taylorza 9:34008d8b1cdf 10 _frameIndex(0),
taylorza 9:34008d8b1cdf 11 _foregroundColor(foregroundColor)
taylorza 9:34008d8b1cdf 12 {
taylorza 9:34008d8b1cdf 13 for(;; _frameCount++)
taylorza 9:34008d8b1cdf 14 {
taylorza 9:34008d8b1cdf 15 if (frames[_frameCount] == NULL) break;
taylorza 9:34008d8b1cdf 16 }
taylorza 9:34008d8b1cdf 17
taylorza 9:34008d8b1cdf 18 }
taylorza 9:34008d8b1cdf 19
taylorza 9:34008d8b1cdf 20 void animate()
taylorza 9:34008d8b1cdf 21 {
taylorza 9:34008d8b1cdf 22 _frameIndex = (_frameIndex + 1) % _frameCount;
taylorza 9:34008d8b1cdf 23 }
taylorza 9:34008d8b1cdf 24
taylorza 9:34008d8b1cdf 25 uint8_t* getBits(int row) const
taylorza 9:34008d8b1cdf 26 {
taylorza 9:34008d8b1cdf 27 return _frames[_frameIndex]->getBits(row);
taylorza 9:34008d8b1cdf 28 }
taylorza 9:34008d8b1cdf 29
taylorza 9:34008d8b1cdf 30 inline uint16_t getForegroundColor() const { return _foregroundColor; }
taylorza 9:34008d8b1cdf 31
taylorza 9:34008d8b1cdf 32 private:
taylorza 9:34008d8b1cdf 33 const ImageFrame **_frames;
taylorza 9:34008d8b1cdf 34 uint8_t _frameCount;
taylorza 9:34008d8b1cdf 35 uint8_t _frameIndex;
taylorza 9:34008d8b1cdf 36 uint8_t _foregroundColor;
taylorza 9:34008d8b1cdf 37 };
taylorza 9:34008d8b1cdf 38
taylorza 9:34008d8b1cdf 39 #endif //__SPRITE_H__
taylorza 9:34008d8b1cdf 40