Elements used in the Balls and Things games for the RETRO.
Dependents: RETRO_BallsAndPaddle RETRO_BallAndHoles
Ball.h@8:19dd2a538cbe, 2015-03-02 (annotated)
- Committer:
- maxint
- Date:
- Mon Mar 02 09:58:53 2015 +0000
- Revision:
- 8:19dd2a538cbe
- Parent:
- 5:065f19e08dcb
more clean-up
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maxint | 0:3d0db4e183ee | 1 | #pragma once |
maxint | 0:3d0db4e183ee | 2 | #include "mbed.h" |
maxint | 0:3d0db4e183ee | 3 | |
maxint | 0:3d0db4e183ee | 4 | #include "Color565.h" |
maxint | 0:3d0db4e183ee | 5 | #include "font_OEM.h" |
maxint | 0:3d0db4e183ee | 6 | #include "LCD_ST7735.h" |
maxint | 0:3d0db4e183ee | 7 | |
maxint | 0:3d0db4e183ee | 8 | #include "Shapes.h" |
maxint | 0:3d0db4e183ee | 9 | #include "Vector.h" |
maxint | 0:3d0db4e183ee | 10 | #include "Physics.h" |
maxint | 0:3d0db4e183ee | 11 | |
maxint | 0:3d0db4e183ee | 12 | class Ball |
maxint | 0:3d0db4e183ee | 13 | { |
maxint | 0:3d0db4e183ee | 14 | public: |
maxint | 0:3d0db4e183ee | 15 | static const bool fFixed=false; |
maxint | 0:3d0db4e183ee | 16 | bool fActive; |
maxint | 0:3d0db4e183ee | 17 | |
maxint | 0:3d0db4e183ee | 18 | Ball(); |
maxint | 0:3d0db4e183ee | 19 | Ball(LCD_ST7735* pDisp); |
maxint | 0:3d0db4e183ee | 20 | void initialize(int X, int Y, int R, uint16_t uColor); |
maxint | 0:3d0db4e183ee | 21 | void setSpeed(int X, int Y); |
maxint | 0:3d0db4e183ee | 22 | void changeSpeed(bool fUp); |
maxint | 0:3d0db4e183ee | 23 | void unmove(); |
maxint | 0:3d0db4e183ee | 24 | void update(); |
maxint | 0:3d0db4e183ee | 25 | void clear(); |
maxint | 0:3d0db4e183ee | 26 | void clearPrev(); |
maxint | 0:3d0db4e183ee | 27 | void draw(); |
maxint | 0:3d0db4e183ee | 28 | void redraw(); |
maxint | 0:3d0db4e183ee | 29 | |
maxint | 0:3d0db4e183ee | 30 | Position pos; |
maxint | 0:3d0db4e183ee | 31 | int nRadius; |
maxint | 0:3d0db4e183ee | 32 | Vector vSpeed; |
maxint | 0:3d0db4e183ee | 33 | |
maxint | 0:3d0db4e183ee | 34 | Circle getBoundingCircle(); |
maxint | 0:3d0db4e183ee | 35 | bool collides(Rectangle r); |
maxint | 5:065f19e08dcb | 36 | bool collides(Circle cObject); |
maxint | 3:441dc90d10ce | 37 | bool collides(Line ln); |
maxint | 0:3d0db4e183ee | 38 | void Bounce(Vector vBounce); |
maxint | 2:74bc9b16fb88 | 39 | void BounceAgainst(Vector vBounce); |
maxint | 0:3d0db4e183ee | 40 | |
maxint | 0:3d0db4e183ee | 41 | private: |
maxint | 0:3d0db4e183ee | 42 | uint16_t uColor; |
maxint | 0:3d0db4e183ee | 43 | uint16_t uColorHigh; |
maxint | 0:3d0db4e183ee | 44 | uint16_t uColorMid; |
maxint | 0:3d0db4e183ee | 45 | uint16_t uColorLow; |
maxint | 0:3d0db4e183ee | 46 | LCD_ST7735* pDisp; |
maxint | 0:3d0db4e183ee | 47 | |
maxint | 0:3d0db4e183ee | 48 | uint16_t dimmedColor(uint16_t uColor); |
maxint | 0:3d0db4e183ee | 49 | }; |
maxint | 0:3d0db4e183ee | 50 |