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 __RECT_H__
taylorza 9:34008d8b1cdf 2 #define __RECT_H__
taylorza 9:34008d8b1cdf 3
taylorza 9:34008d8b1cdf 4 #include <algorithm>
taylorza 9:34008d8b1cdf 5
taylorza 9:34008d8b1cdf 6 struct Rect
taylorza 9:34008d8b1cdf 7 {
taylorza 9:34008d8b1cdf 8 uint8_t left;
taylorza 9:34008d8b1cdf 9 uint8_t top;
taylorza 9:34008d8b1cdf 10 uint8_t right;
taylorza 9:34008d8b1cdf 11 uint8_t bottom;
taylorza 9:34008d8b1cdf 12
taylorza 9:34008d8b1cdf 13 Rect() :
taylorza 9:34008d8b1cdf 14 left(0),
taylorza 9:34008d8b1cdf 15 top(0),
taylorza 9:34008d8b1cdf 16 right(0),
taylorza 9:34008d8b1cdf 17 bottom(0)
taylorza 9:34008d8b1cdf 18 {
taylorza 9:34008d8b1cdf 19 }
taylorza 9:34008d8b1cdf 20
taylorza 9:34008d8b1cdf 21 Rect(uint8_t l, uint8_t t, uint8_t w, uint8_t h) :
taylorza 9:34008d8b1cdf 22 left(l),
taylorza 9:34008d8b1cdf 23 top(t),
taylorza 9:34008d8b1cdf 24 right(l + (w - 1)),
taylorza 9:34008d8b1cdf 25 bottom(t + (h - 1))
taylorza 9:34008d8b1cdf 26 {
taylorza 9:34008d8b1cdf 27 }
taylorza 9:34008d8b1cdf 28
taylorza 9:34008d8b1cdf 29 Rect Intersection(Rect &rect)
taylorza 9:34008d8b1cdf 30 {
taylorza 9:34008d8b1cdf 31 uint8_t x1 = max(left, rect.left);
taylorza 9:34008d8b1cdf 32 uint8_t y1 = max(top, rect.top);
taylorza 9:34008d8b1cdf 33 uint8_t x2 = min(right, rect.right);
taylorza 9:34008d8b1cdf 34 uint8_t y2 = min(bottom, rect.bottom);
taylorza 9:34008d8b1cdf 35
taylorza 9:34008d8b1cdf 36 return Rect(x1, y1, x2, y2);
taylorza 9:34008d8b1cdf 37 }
taylorza 9:34008d8b1cdf 38
taylorza 9:34008d8b1cdf 39 inline uint8_t getWidth() const { return right - left; }
taylorza 9:34008d8b1cdf 40 inline uint8_t getHeight() const { return bottom - top; }
taylorza 9:34008d8b1cdf 41 };
taylorza 9:34008d8b1cdf 42
taylorza 9:34008d8b1cdf 43 #endif //__RECT_H__