Library to control the Tetris game area

Dependents:   Tetris_Game

Tetris.h

Committer:
el14ja
Date:
2016-04-07
Revision:
3:af0a7a4464e5
Parent:
2:56dc50270349
Child:
4:e4952be370d3

File content as of revision 3:af0a7a4464e5:

/*Tetris

Library which contains the functions for the game tetris to run on a Nokia N5110 screen

V 1.0 - initial release

Joseph Allison March 2016

#ifndef TMP102_H
#define TMP102_H

*/

#ifndef Tetris_H //header guards to stop the library from being included more than once
#define Tetris_H

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

//int shapes[7][4] = {{0x00F0,0x4444,0x0F00,0x2222},{0x0071,0x0226,0x0470,0x0322},{0x0074,0x0622,0x0170,0x0223},{0x0033,0x0033,0x0033,0x0033},{0x0072,0x0262,0x0270,0x0232},{0x0036,0x0462,0x0360,0x0231},{0x0063,0x0264,0x0630,0x0132}};


class Tetris
{

public:

    Tetris();
    void movePieceRight();
    void movePieceLeft();
    void spinPiece();
    void movePieceDown();
    
private:

    void gameInfo(int score,int level,int next);
    /**
    Sets a 3x3  sets a pixel cell in the game area at position (x,y)
    @param x - cells horizontal position
    @param y - cells vertical position
    */
    void gamePixel(int x,int y);
    /**
    Sets a 3x3  clears a pixel cell in the game area at position (x,y)
    @param x - cells horizontal position
    @param y - cells vertical position
    */
    void clearGamePixel(int x, int y);
    /**
    Clears the game area
    */
    void clearGame();
    /**
    Places a game piece on the screen
    @param x - cells horizontal position
    @param y - cells vertical position
    @param shape - the shape that is being placed
    */
    void piecePlace(int x,int y,int shape);
    /**
    Clears a game piece on the screen
    @param x - cells horizontal position
    @param y - cells vertical position
    @param shape - the shape that is being cleared
    */
    void pieceClear(int x,int y,int shape);

    bool movePossible(int xpos, int ypos, int orientation);

    void gameSetup();
    
    void newpiece();
    
    void newShapeBag();
    
    void checkCompleteLine();
    
    void removeCompleteLines(int rowscomplete[4]);
    
    void pieceToGameArray(); 
    
    void setGameArea(); 
    
    
    
    
    
    void movePiece(int x, int y,int spin);
public:

    int pieceposition[2]; //set position of the current dropping piece ***
    int orientation;
    int gamearea[12][16]; //stores the current states of the game area and is used to check for collisions ***add sides
    int currentshape;

    int nextpiece;
    int shapebagcounter;
    int nextshape[7];//stores the next 7 shapes to be used - 7 bag system

    int musiccounter;

    int score; /*!< */
    int completedlines;
    int level;
    float gamespeed; //how often a block moves down

private:


};

#endif