Elements used in the Balls and Things games for the RETRO.
Dependents: RETRO_BallsAndPaddle RETRO_BallAndHoles
Diff: Shapes.h
- Revision:
- 0:3d0db4e183ee
- Child:
- 3:441dc90d10ce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Shapes.h Fri Feb 06 09:51:06 2015 +0000 @@ -0,0 +1,64 @@ +#pragma once +#include "mbed.h" +#include "Vector.h" + +class Point +{ +protected : + int x1, y1; + +public : + Point(); + Point(int x, int y); + int getX(); + int getY(); + void set(int x, int y); +}; + +class Rectangle +{ +protected : + int x1, x2, y1, y2; + +public : + Rectangle(int x,int y, int x2, int y2); + Rectangle(Point pt1, Point pt2); + bool collides(Point pt); + bool collides(Rectangle r); + + void set(Rectangle rNew); + + Point get1(); + Point get2(); + Point get3(); + Point get4(); + Point getCenter(); + + int getX1(); + int getX2(); + int getY1(); + int getY2(); + int getCenterX(); + int getCenterY(); + void move(Vector v); +}; + +class Circle +{ +protected : + int x1, y1, r1; + +public : + Circle(int x,int y, int r); + Point getCenter(); + int getRadius(); + int getX(); + int getY(); + void setX(int x); + void setY(int y); + void setXY(int x, int y); + void move(int x, int y); + void move(Vector v); + Rectangle getBoundingRectangle(); +}; +