All pastes #1903082 Raw Edit

blocks.cpp

public cpp v1 · immutable
#1903082 ·published 2010-07-18 17:14 UTC
rendered paste body
#ifndef BLOCKS_HPP#define BLOCKS_HPP/* * Includes classes used for representing the blocks on the screen *//**************************************** *************** Includes *************** ****************************************/#include <GL/gl.h>#include <GL/glu.h>#include <list>using namespace std;/******************************************* *************** Definitions *************** *******************************************///Initially how fast blocks drop on the screen#define DROP_INTERVAL 1.0//How fast blocks shift left and right#define MOVE_INTERVAL 1.0/******************************************* *************** Structures **************** *******************************************/typedef struct struct_position {  float x;  float y;  float z;} position;typedef struct struct_colour {  float r;  float g;  float b;} colour;enum state {  FROZEN,  COLLIDED,  MOVING,};/**************************************** ********** Class Prototypes ************ ****************************************/class Block;class Big_Block;/**************************************** *************** Classes **************** ****************************************///The main part of the game. Each block in the game is represented by//a classclass Block {public:  Block(Big_Block*,	position,	colour);  ~Block();    //Updates the position to the new position  void changePosition(position thePosition);  void changePosition(float, float, float);  //changes the state to reflect on the block dropping down  void dropDown(float interval = DROP_INTERVAL);    //changes the state to reflect on the block moving left or right  void moveLeft(float interval = MOVE_INTERVAL);  void moveRight(float interval = MOVE_INTERVAL);  //Changes the blocks state to break the block  void breakMe();  //draws the openGL representation of the block on the screen  //based on its position and colour  void drawMe(state);  //GET Methods  position getPosition();  colour getColour();  Big_Block* getParent();  //Static variables  static unsigned int totalBlocks;  static list<Block> blockArray;private:  position thePosition;  colour theColour;  Big_Block *parent;  };class Big_Block {  public:  Big_Block(position, colour);  ~Big_Block();//Updates the position to the new position  void changeBlockPosition(position);  void changeBlockPosition(float, float, float);  //changes the state to reflect on the blocks dropping down  void dropBlocksDown(float interval = DROP_INTERVAL);    //changes the state to reflect on the blocks moving left or right  void moveBlocksLeft(float interval = MOVE_INTERVAL);  void moveBlocksRight(float interval = MOVE_INTERVAL);  //Changes the blocks state to break the blocks  void breakBlocks();  //draws the openGL representation of the blocks on the screen  //based on its position and colour  void drawBlocks(state);private:  unsigned int numBlocks;  Block blockListing[4];protected:  static list<Big_Block> bigBlockListing;};class L_Block: protected Big_Block {      };#endif //BLOCKS_HPP