Orxonox  0.0.5 Codename: Arcturus
PongBall.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
35 #ifndef _PongBall_H__
36 #define _PongBall_H__
37 
38 #include "pong/PongPrereqs.h"
39 
40 #include "util/Math.h"
41 
43 
44 
45 namespace orxonox
46 {
47 
60  {
61  public:
62  PongBall(Context* context);
63  virtual ~PongBall();
64 
65  virtual void tick(float dt) override;
66 
67  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
68 
74  void setFieldDimension(float width, float height)
75  { this->fieldWidth_ = width; this->fieldHeight_ = height; }
80  void setFieldDimension(const Vector2& dimension)
81  { this->setFieldDimension(dimension.x, dimension.y); }
86  Vector2 getFieldDimension() const
87  { return Vector2(this->fieldWidth_, this->fieldHeight_); }
88 
89  void setSpeed(float speed);
90 
94  float getSpeed() const
95  { return this->speed_; }
96 
101  void setAccelerationFactor(float factor)
102  { this->accelerationFactor_ = factor; }
107  float getAccelerationFactor() const
108  { return this->accelerationFactor_; }
109 
114  void setBatLength(float batlength)
115  { this->batlength_ = batlength; }
120  float getBatLength() const
121  { return this->batlength_; }
122 
123  void setBats(WeakPtr<PongBat>* bats);
124  void applyBats();
125 
126  static const float MAX_REL_Z_VELOCITY;
127 
128  void setDefScoreSound(const std::string& engineSound);
129  const std::string& getDefScoreSound();
130  void setDefBatSound(const std::string& engineSound);
131  const std::string& getDefBatSound();
132  void setDefBoundarySound(const std::string& engineSound);
133  const std::string& getDefBoundarySound();
134 
135  private:
136  void registerVariables();
137 
138  float fieldWidth_;
139  float fieldHeight_;
140  float speed_;
142  float batlength_;
145  unsigned int* batID_;
150  };
151 }
152 
153 #endif /* _PongBall_H__ */
float fieldWidth_
The width of the playing field.
Definition: PongBall.h:138
Vector2 getFieldDimension() const
Get the dimensions of the playing field.
Definition: PongBall.h:86
float getAccelerationFactor() const
Get the acceleration factor of the ball.
Definition: PongBall.h:107
The WorldSound class is to be used for sounds with position and orientation.
Definition: WorldSound.h:44
float getSpeed() const
Get the speed of the ball (in x-direction).
Definition: PongBall.h:94
::std::string string
Definition: gtest-port.h:756
float getBatLength() const
Get the length of the bats.
Definition: PongBall.h:120
bool bDeleteBats_
Bool, to keep track, of whether this->bat_ exists or not.
Definition: PongBall.h:144
Definition: MovableEntity.h:42
float relMercyOffset_
Offset, that makes the player not loose, when, in all fairness, he would have.
Definition: PongBall.h:146
float accelerationFactor_
The acceleration factor of the ball.
Definition: PongBall.h:141
WeakPtr< PongBat > * bat_
An array with the two bats.
Definition: PongBall.h:143
WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted.
Definition: CorePrereqs.h:236
float fieldHeight_
The height of the playing field.
Definition: PongBall.h:139
static const float MAX_REL_Z_VELOCITY
Definition: PongBall.h:126
void setAccelerationFactor(float factor)
Set the acceleration factor of the ball.
Definition: PongBall.h:101
xmlelement
Definition: Super.h:519
Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the ...
WorldSound * defBatSound_
Definition: PongBall.h:148
WorldSound * defScoreSound_
Definition: PongBall.h:147
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Mode
Definition: CorePrereqs.h:102
float batlength_
The length of the bats (in z-direction) as percentage of the height of the playing field...
Definition: PongBall.h:142
Definition: Context.h:45
void setFieldDimension(float width, float height)
Set the dimensions of the playing field.
Definition: PongBall.h:74
void setBatLength(float batlength)
Set the length of the bats.
Definition: PongBall.h:114
This class manages the ball for Pong.
Definition: PongBall.h:59
void setFieldDimension(const Vector2 &dimension)
Get the dimensions of the playing field.
Definition: PongBall.h:80
unsigned int * batID_
The object IDs of the bats, to be able to synchronize them over the network.
Definition: PongBall.h:145
WorldSound * defBoundarySound_
Definition: PongBall.h:149
#define _PongExport
Definition: PongPrereqs.h:60
float speed_
The speed (in x-direction) of the ball.
Definition: PongBall.h:140
Shared library macros, enums, constants and forward declarations for the pong module ...