Arkanoid Remake  1.0
BlockMatrix.h
Go to the documentation of this file.
1 /*
2 ArkanoidRemakeSDL
3 a sample of object-oriented game programming with C++.
4 version 1.0, May 2016
5 
6 Copyright (c) 2016 Giovanni Paolo Vigano'
7 
8 The source code of the SDL library used by ArkanoidRemakeSDL can be found here:
9 https://www.libsdl.org/
10 ---
11 ArkanoidRemakeSDL source code is licensed with the same zlib license:
12 (http://www.gzip.org/zlib/zlib_license.html)
13 
14 This software is provided 'as-is', without any express or implied warranty. In
15 no event will the authors be held liable for any damages arising from the use of
16 this software.
17 
18 Permission is granted to anyone to use this software for any purpose, including
19 commercial applications, and to alter it and redistribute it freely, subject to
20 the following restrictions:
21 
22  1. The origin of this software must not be misrepresented; you must not
23  claim that you wrote the original software. If you use this software in a
24  product, an acknowledgment in the product documentation would be appreciated
25  but is not required.
26 
27  2. Altered source versions must be plainly marked as such, and must not be
28  misrepresented as being the original software.
29 
30  3. This notice may not be removed or altered from any source distribution.
31 */
32 
33 
37 
38 #pragma once
39 
40 #ifndef BLOCKMATRIX_H
41 #define BLOCKMATRIX_H
42 
43 #include <Block.h>
44 #include <vector>
45 
48 
53 {
54  unsigned int mCols;
55  unsigned int mRows;
56  std::vector<Block> mBlockList;
57 public:
58 
60  BlockMatrix();
61 
63  BlockMatrix(unsigned int rows, unsigned int cols);
64 
66  void Init(unsigned int rows, unsigned int cols);
67 
69  Block& operator()(unsigned int row, unsigned int col);
70 
72  unsigned int Cols() const { return mCols; }
73 
75  unsigned int Rows() const { return mRows; }
76 
78  unsigned int CountVisibleBlocks() const;
79 };
80 
81 
83 
84 #endif//BLOCKMATRIX_H
85 
Block class definition.
unsigned int Rows() const
Get the number of rows of blocks.
Definition: BlockMatrix.h:75
BlockMatrix()
Default constructor.
void Init(unsigned int rows, unsigned int cols)
Initialize the matrix to hold the given rows and columns of blocks.
unsigned int Cols() const
Get the number of columns of blocks.
Definition: BlockMatrix.h:72
Wall block.
Definition: Block.h:52
Matrix with the wall blocks of the game.
Definition: BlockMatrix.h:52
unsigned int CountVisibleBlocks() const
Count blocks that are still visible (not completely destroyed)
Block & operator()(unsigned int row, unsigned int col)
Access a block in the matrix using its row and column.