Thomas Davies / Mbed 2 deprecated LetTheBallDrop

Dependencies:   N5110 mbed PowerControl

GameScreen.h

Committer:
AppleJuice
Date:
2015-03-07
Revision:
2:d4402bc3dd45
Parent:
1:3305d7e44880
Child:
4:f8d04c073730

File content as of revision 2:d4402bc3dd45:

#ifndef GameScreen_H
#define GameScreen_H

#include "mbed.h"
#include "N5110.h"

//GameScreen class is an extension of the base Nokia Library Created by Craig Evans
// This extension adds functionality relevant to 'Fall Down Game'. 
// drawPlatform, drawBall, drawScore etc....
// # of platforms defined and can be altered/
// updates platforms at speed proportional to speedOfPlatforms_
// manages location and state of all platforms + player ball

//ISSUES:
//  text is written in wrong plane. Easy fix if I had access to private members of N5110...could just edit lib...
//      could also override current fontarray... look into this later.
//
//


struct Platform {
    int id;     //for identifying.
    int x;      //col of gap
    int y;      //row    
};

class GameScreen: public N5110::N5110
{   
public:
    explicit GameScreen(PinName pwrPin, PinName scePin, PinName rstPin, PinName dcPin, PinName mosiPin, PinName sclkPin, PinName ledPin)
       :N5110(pwrPin, scePin,rstPin,dcPin,mosiPin,sclkPin,ledPin){}    //classes needed are private...dont want to steal code so we'll just inheret constructor aswell :)
    
    void Initialize();
    
    //draw horizontal platform where y top pixel layer location. x hole location
    void drawPlatform(int x,int y);
    void erasePlatform(int y);
    void drawBall(int x, int y);
    void eraseBall(int x, int y);
    void createAllPlatforms();
    void freeAllPlatforms();        //garbage cleanup
    void drawAllPlatforms();
    void eraseAllPlatforms();
    void shiftAllPlatformsUp();     //move all platforms up 1 pixel        
    
    //Read Only
    int maxY(){ return maxY_; }
    int maxX(){ return maxX_; }
    int platThickness() {return platThickness_;}
    int ballRadius() {return ballRadius_;}
    
    Platform *allPlatforms[6];      //public for testing...
    
private:
    static const int platGapSize_ = 8;          //standard platform gap width in pixels
    static const int platThickness_ = 2;        //platform thickness in pixels
    static const int platSpacing_ = 14;         // subsequent platform spacing in pixels
    static const int maxX_ = 48;                // maximun horizontal pixel
    static const int maxY_ = 84;                // maximum vertical pixel
    static const int ballRadius_ = 4;           // size of player ball
    static const int numPlatforms_ = 6;         // total number of platforms
    //Platform *allPlatforms[numPlatforms_];      //array used to track each platform, and refresh when needed!    
};


#endif