Elements used in the Balls and Things games for the RETRO.
Dependents: RETRO_BallsAndPaddle RETRO_BallAndHoles
Revision 4:f421e34313d3, committed 2015-02-28
- Comitter:
- maxint
- Date:
- Sat Feb 28 11:40:24 2015 +0000
- Parent:
- 3:441dc90d10ce
- Child:
- 5:065f19e08dcb
- Commit message:
- Added support for walls
Changed in this revision
--- a/Shapes.cpp Thu Feb 26 11:46:46 2015 +0000 +++ b/Shapes.cpp Sat Feb 28 11:40:24 2015 +0000 @@ -220,6 +220,12 @@ y2=rNew.getY2(); } +bool Rectangle::isHorizontal() +{ + return(x2-x1 > y2-y1); +} + + void Rectangle::move(Vector v) { x1+=rint(v.x);
--- a/Shapes.h Thu Feb 26 11:46:46 2015 +0000 +++ b/Shapes.h Sat Feb 28 11:40:24 2015 +0000 @@ -61,6 +61,7 @@ int getY2(); int getCenterX(); int getCenterY(); + bool isHorizontal(); void move(Vector v); };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Wall.cpp Sat Feb 28 11:40:24 2015 +0000 @@ -0,0 +1,43 @@ +#include "Wall.h" + +Wall::Wall() : rWall(0,0,0,0) +{ // constructor +} + +Wall::Wall(LCD_ST7735* pDisp) : rWall(0,0,0,0) +{ // constructor + this->pDisp=pDisp; + uColor=Color565::Blue; + this->fActive=false; +} + +void Wall::setRect(Rectangle rNew) +{ + rWall=rNew; +} + + +Rectangle Wall::getRect() +{ + return(rWall); +} + +void Wall::draw() +{ + int x1=rWall.getX1(); + int y1=rWall.getY1(); + int x2=rWall.getX2(); + int y2=rWall.getY2(); + if(x1!=x2 && y1!=y2) + pDisp->fillRect(x1,y1,x2,y2, uColor); + else + pDisp->drawLine(x1,y1,x2,y2, uColor); + +/* +char szBuffer[256]; +sprintf(szBuffer, "w:%d,%d - %d,%d ", rWall.getX1(), rWall.getY1(), rWall.getX2(), rWall.getY2()); +pDisp->drawString(font_oem, 0, 0, szBuffer); +*/ + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Wall.h Sat Feb 28 11:40:24 2015 +0000 @@ -0,0 +1,24 @@ +#pragma once +#include "mbed.h" + +#include "Color565.h" +#include "font_OEM.h" +#include "LCD_ST7735.h" + +#include "Shapes.h" + +class Wall +{ + public: + Wall(); + Wall(LCD_ST7735* pDisp); + void draw(); + bool fActive; + void setRect(Rectangle rNew); + Rectangle getRect(); + + private: + uint16_t uColor; + LCD_ST7735* pDisp; + Rectangle rWall; +}; \ No newline at end of file