Elements used in the Balls and Things games for the RETRO.

Dependents:   RETRO_BallsAndPaddle RETRO_BallAndHoles

Ball.h

Committer:
maxint
Date:
2015-02-25
Revision:
2:74bc9b16fb88
Parent:
0:3d0db4e183ee
Child:
3:441dc90d10ce

File content as of revision 2:74bc9b16fb88:

#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);
        void BounceAgainst(Vector vBounce);

    private:
        uint16_t uColor;
        uint16_t uColorHigh;
        uint16_t uColorMid;
        uint16_t uColorLow;
        LCD_ST7735* pDisp;

        uint16_t dimmedColor(uint16_t uColor);
};