| 1 |
#ifndef _CRECT_ |
| 2 |
#define _CRECT_ |
| 3 |
|
| 4 |
#include "CVector.h" |
| 5 |
#include "SDL.h" |
| 6 |
|
| 7 |
class CRect |
| 8 |
{ |
| 9 |
public: |
| 10 |
enum Side |
| 11 |
{ |
| 12 |
NONE = 0, |
| 13 |
BOTTOM = 1, |
| 14 |
TOP = 2, |
| 15 |
LEFT = 4, |
| 16 |
RIGHT = 8 |
| 17 |
}; |
| 18 |
|
| 19 |
CRect(double x, double y, double width, double height); |
| 20 |
|
| 21 |
double getX(); |
| 22 |
double getY(); |
| 23 |
double getWidth(); |
| 24 |
double getHeight(); |
| 25 |
virtual bool contains(double x, double y); |
| 26 |
virtual bool contains(CVector v); |
| 27 |
virtual bool checkLeft(double x); |
| 28 |
virtual bool checkRight(double x); |
| 29 |
virtual bool checkTop(double y); |
| 30 |
virtual bool checkBottom(double y); |
| 31 |
|
| 32 |
bool operator!=(CRect b); |
| 33 |
bool operator==(CRect b); |
| 34 |
|
| 35 |
void setWidth(double width) { CRect::width = width; } |
| 36 |
void setHeight(double height) { CRect::height = height; } |
| 37 |
private: |
| 38 |
double x, y, width, height; |
| 39 |
}; |
| 40 |
|
| 41 |
#endif |