Elements used in the Balls and Things games for the RETRO.
Dependents: RETRO_BallsAndPaddle RETRO_BallAndHoles
Diff: Ball.h
- Revision:
- 0:3d0db4e183ee
- Child:
- 2:74bc9b16fb88
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Ball.h Fri Feb 06 09:51:06 2015 +0000 @@ -0,0 +1,47 @@ +#pragma once +#include "mbed.h" + +#include "Color565.h" +#include "font_OEM.h" +#include "LCD_ST7735.h" + +#include "Shapes.h" +#include "Vector.h" +#include "Physics.h" + +class Ball +{ + public: + static const bool fFixed=false; + bool fActive; + + Ball(); + Ball(LCD_ST7735* pDisp); + void initialize(int X, int Y, int R, uint16_t uColor); + void setSpeed(int X, int Y); + void changeSpeed(bool fUp); + void unmove(); + void update(); + void clear(); + void clearPrev(); + void draw(); + void redraw(); + + Position pos; + int nRadius; + Vector vSpeed; + + Circle getBoundingCircle(); + bool collides(Rectangle r); + void Bounce(Vector vBounce); + + private: + uint16_t uColor; + uint16_t uColorHigh; + uint16_t uColorMid; + uint16_t uColorLow; + LCD_ST7735* pDisp; + + uint16_t dimmedColor(uint16_t uColor); +}; +