Arkanoid Remake  1.0
Block.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 BLOCK_H
41 #define BLOCK_H
42 
43 #include <BoxObj.h>
44 #include <string>
45 
48 
52 class Block : public BoxObj
53 {
54  int mState;
55  int mType;
56  int mScore;
57  std::string mBonusType;
58 
59 public:
61  Block();
62 
64  bool Valid() const { return mType>=0; }
65 
67  bool Visible() const { return mState>=0; }
68 
70  void Hide() { mState=-1; }
71 
73  int Hit();
74 
76  int State() const { return mState; }
77 
79  const std::string& Bonus() const { return mBonusType; }
80 
86  void Set(int typ, int state=0, int score=1, const std::string& bonus = "");
87 
89  int Type() const { return mType; }
90 };
91 
92 
94 
95 #endif//BLOCK_H
96 
int Hit()
Hit the block, return the related score.
int Type() const
Get the type of this block (identifier of the block type)
Definition: Block.h:89
void Hide()
Hide (destroy only visually) the block.
Definition: Block.h:70
bool Valid() const
Check if the block was well defined.
Definition: Block.h:64
int State() const
Get the current block state (decreased when hit, 0=destroyed)
Definition: Block.h:76
A box-shaped object.
Definition: BoxObj.h:51
Block()
Constructor: initialize data members.
bool Visible() const
Check if the block is still visible.
Definition: Block.h:67
Wall block.
Definition: Block.h:52
const std::string & Bonus() const
Get the score bonus related to this block.
Definition: Block.h:79
BoxObj class definition.
void Set(int typ, int state=0, int score=1, const std::string &bonus="")