Maxint R&D / RETRO_BallsAndThings

Dependents:   RETRO_BallsAndPaddle RETRO_BallAndHoles

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Shapes.h Source File

Shapes.h

00001 #pragma once
00002 #include <algorithm>        // required for min() and max(), see http://www.cplusplus.com/reference/algorithm/
00003 #include "mbed.h"
00004 #include "Vector.h"
00005 
00006 //#define MAX(x, y) (((x) > (y)) ? (x) : (y))
00007 //#define MIN(x, y) (((x) < (y)) ? (x) : (y))
00008 
00009 class Point
00010 { 
00011 protected :
00012     int x1, y1;
00013 
00014 public :
00015     Point();
00016     Point(int x, int y);
00017     int getX();
00018     int getY();
00019     void set(int x, int y);
00020 };
00021 
00022 class Rectangle;    // predefinition needed by Line class
00023 
00024 class Line
00025 {
00026 protected :
00027     int x1, x2, y1, y2;
00028 
00029 public :
00030     Line(int x1,int y1, int x2, int y2);
00031     Line(Point p1, Point p2);
00032     Point get1();
00033     Point get2();
00034     float getSizeFloat();
00035     int getSize();
00036     Rectangle getBoundingRectangle();
00037     int getDistance(Point pt);
00038 };
00039 
00040 class Rectangle
00041 {
00042 protected :
00043     int x1, x2, y1, y2;
00044  
00045 public :
00046     Rectangle(int x,int y, int x2, int y2);
00047     Rectangle(Point pt1, Point pt2);
00048     bool collides(Point pt);
00049     bool collides(Rectangle r);
00050 
00051     void set(Rectangle rNew);
00052     
00053     Point get1();
00054     Point get2();
00055     Point get3();
00056     Point get4();
00057     Point getCenter();
00058 
00059     int getX1();
00060     int getX2();
00061     int getY1();
00062     int getY2();
00063     int getCenterX();
00064     int getCenterY();
00065     bool isHorizontal();
00066     void move(Vector v);
00067 };
00068 
00069 class Circle
00070 { 
00071 protected :
00072     int x1, y1, r1;
00073 
00074 public :
00075     Circle(int x,int y, int r);
00076     Point getCenter();
00077     int getRadius();
00078     int getX();
00079     int getY();
00080     void setX(int x);
00081     void setY(int y);
00082     void setXY(int x, int y);
00083     void move(int x, int y);
00084     void move(Vector v);
00085     Rectangle getBoundingRectangle();
00086     bool collides(Line l);
00087 };
00088