// Square class // // single square block which moves around the grid // by the keys and stops when it lands above an occupied grid square #ifndef SQUARE_H #define SQUARE_H #include "gp142display.h" enum Direction {LEFT,RIGHT,DOWN,ERROR}; // Square class -- this is a single square on the screen class Square { public: // default constructor Square(); // constructor Square(GP142Display *display, Grid *grid, int x, int y); // copy constructor Square(const Square &source); // operator= Square &operator=(const Square &other); // initialize or assign the square the values passed void squareInit(GP142Display *display, Grid *grid, int x, int y); // get x coordinate of square int getX() const; // get y coordinate of square int getY() const; // true if the square can move over one square in direction d bool canMove(Direction d) const; // move square in direction d if possible void Move(Direction d); // draw rectangle of pixels corresponding to square at // grid location (x,y) void Draw(GP142Color color); private: int x,y; // corresponding grid location of square bool ableToMove; // true if the square can still move (isn't frozen) GP142Display *display; // screen graphics are drawn on Grid *grid; // grid that this square is a part of }; #endif