Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C++ Windows Programming

You're reading from   C++ Windows Programming Develop real-world applications in Windows.

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher Packt
ISBN-13 9781786464224
Length 588 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (16) Chapters Close

Preface 1. Introduction FREE CHAPTER 2. Hello, Small World! 3. Building a Tetris Application 4. Working with Shapes and Figures 5. The Figure Hierarchy 6. Building a Word Processor 7. Keyboard Input and Character Calculation 8. Building a Spreadsheet Application 9. Formula Interpretation 10. The Framework 11. The Document 12. The Auxiliary Classes 13. The Registry, Clipboard, Standard Dialogs, and Print Preview 14. Dialogs, Controls, and Page Setup A. Rational and Complex Numbers

The GameGrid class

Finally, the GameGrid class is quite simple. It keeps track of the squares on the game board. The gridArea field is the portion of the total client area that is occupied by the grid:

GameGrid.h

const int Rows = 20, Cols = 10;  
 
class GameGrid { 
  public: 
    GameGrid(Rect gridArea); 
    void ClearGameGrid(); 
 
    Color* operator[](int row) {return gameGrid[row];} 
    void InvalidateSquare(Window* windowPtr, int row, 
                          int col, Size offsetSize); 
    void DrawGameGrid(Graphics& graphics, bool inverse) const; 



    void DrawSquare(Graphics& graphics, int row, int col, 
                    Color penColor, Color brushColor, 
                    Size offsetSize = ZeroSize) const; 
 
    Rect GridArea() const {return gridArea;} 
 
  private: 
    Rect gridArea; 
    Color gameGrid[Rows][Cols]; 
}; 

When called by the TetrisWindow constructor, the grid area will be set to (0, 20, 100, 100) units, placing it in the lower 80 percent of...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image