Race around the city collecting the flags while avoiding those that stand in the way of your mission. Make no mistake you will need to be quick to outwit your opponents, they are smart and will try to box you in. I wrote this game to prove that writing a game with scrolling scenery is possible even with the limited 6kB of RAM available. I had to compromise sound effects for features, I wanted multiple opponents, I wanted to be able to drop smoke bombs to trap the opponents but all this required memory so the sound effects had to take a back seat.

Dependencies:   mbed

GameEngine/Rect.h

Committer:
taylorza
Date:
2015-02-01
Revision:
1:1b8125937f28
Parent:
0:d85c449aca6d

File content as of revision 1:1b8125937f28:

#ifndef __RECT_H__
#define __RECT_H__

#include <algorithm>

struct Rect
{
    int16_t left;
    int16_t top;
    int16_t right;
    int16_t bottom;
    
    Rect() :
        left(0),
        top(0),
        right(0),
        bottom(0)
    {
    }
    
    Rect(int16_t l, int16_t t, int16_t w, int16_t h) :
        left(l),
        top(t),
        right(l + (w - 1)),        
        bottom(t + (h - 1))
    {
    }
    
    Rect Intersection(Rect &rect)
    {
        uint8_t x1 = max(left, rect.left);
        uint8_t y1 = max(top, rect.top);
        uint8_t x2 = min(right, rect.right);
        uint8_t y2 = min(bottom, rect.bottom);
        
        return Rect(x1, y1, x2, y2); 
    }
    
    inline int16_t getWidth() const { return right - left; }
    inline int16_t getHeight() const { return bottom - top; }
};

#endif //__RECT_H__