Arkanoid Remake  1.0
Ball.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 BALL_H
41 #define BALL_H
42 
43 #include <DynObj.h>
44 
47 
51 class Ball : public DynObj
52 {
53 protected:
57  bool mHeld;
58 public:
59 
61  Ball(float default_speed = 0.0f)
62  : mDefaultSpeed(default_speed)
63  {
64  }
65 
67  float DefaultSpeed() { return mDefaultSpeed; }
68 
70  void SetDefaultSpeed(float default_speed) { mDefaultSpeed=default_speed; }
71 
73  void Hold() { mHeld=true; }
74 
76  void Release() { mHeld=false; }
77 
79  bool Held() { return mHeld; }
80 };
81 
83 
84 #endif//BALL_H
85 
Game ball definition.
Definition: Ball.h:51
void Release()
Mark this ball as not held.
Definition: Ball.h:76
DynObj class definition.
bool mHeld
Flag that save the condition of the ball as "held".
Definition: Ball.h:57
Ball(float default_speed=0.0f)
Constructor.
Definition: Ball.h:61
float mDefaultSpeed
Default speed, used by the ship to launch the ball.
Definition: Ball.h:55
void SetDefaultSpeed(float default_speed)
Set a default speed.
Definition: Ball.h:70
void Hold()
Mark this ball as held.
Definition: Ball.h:73
bool Held()
Check if this ball was marked as held.
Definition: Ball.h:79
Dynamic object with velocity control.
Definition: DynObj.h:52
float DefaultSpeed()
Get the default speed.
Definition: Ball.h:67