Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Presentation_FS19/src/modules/OrxoBlox/OrxoBloxBall.h @ 12411

Last change on this file since 12411 was 12396, checked in by pomselj, 6 years ago

Jesus safed our souls and stopped the crashing. Hallowed be his name and hallowed be his followers sevy and aryo, first of their names, saviors of the andals the raynars and the first nerds. Fourier is love btw

File size: 4.3 KB
Line 
1#ifndef _OrxoBloxBall_H__
2#define _OrxoBloxBall_H__
3
4#include "OrxoBlox/OrxoBloxPrereqs.h"
5
6#include "util/Math.h"
7
8#include "worldentities/pawns/Pawn.h"
9#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
10
11
12namespace orxonox
13{
14
15    /**
16    @brief
17        This class manages the ball for @ref orxonox::OrxoBlox "OrxoBlox".
18
19        It is responsible for both the movement of the ball in the x,z-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint") and the @ref orxonox::OrxoBloxBat "OrxoBloxBats". Or more precisely, it makes the ball bounce off then upper and lower delimiters of the playing field, it makes the ball bounce off the bats and also detects when a player scores and takes appropriate measures.
20
21    @author
22        Fabian 'x3n' Landau
23
24    @ingroup OrxoBlox
25    */
26    class _OrxoBloxExport OrxoBloxBall : public Pawn
27    {
28        public:
29            OrxoBloxBall(Context* context);
30            virtual ~OrxoBloxBall();
31
32            virtual void tick(float dt) override;
33
34            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
35
36            /**
37            @brief Set the dimensions of the playing field.
38            @param width The width of the playing field.
39            @param height The height of the playing field.
40            */
41            void setFieldDimension(float width, float height)
42                { this->fieldWidth_ = width; this->fieldHeight_ = height; }
43            /**
44            @brief Get the dimensions of the playing field.
45            @param dimension A vector with the width as the first and height as the second component.
46            */
47            void setFieldDimension(const Vector2& dimension)
48                { this->setFieldDimension(dimension.x, dimension.y); }
49            /**
50            @brief Get the dimensions of the playing field.
51            @return Returns a vector with the width as the first and height as the second component.
52            */
53            Vector2 getFieldDimension() const
54                { return Vector2(this->fieldWidth_, this->fieldHeight_); }
55
56            void setSpeed(float speed); //!< Set the speed of the ball (in x-direction).
57            /**
58            @brief Get the speed of the ball (in x-direction).
59            @return Returns the speed of the ball (in x-direction).
60            */
61            float getSpeed() const
62                { return this->speed_; }
63
64            /**
65            @brief Set the acceleration factor of the ball.
66            @param factor The factor the acceleration of the ball is set to.
67            */
68            void setAccelerationFactor(float factor)
69                { this->accelerationFactor_ = factor; }
70            /**
71            @brief Get the acceleration factor of the ball.
72            @return Returns the acceleration factor of the ball.
73            */
74            float getAccelerationFactor() const
75                { return this->accelerationFactor_; }
76
77       
78
79            void Bounce(WorldEntity* Stone);
80            void Collides(OrxoBloxStones* otherObject);
81            bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
82
83            static const float MAX_REL_Z_VELOCITY;
84
85            void setDefScoreSound(const std::string& engineSound);
86            const std::string& getDefScoreSound();
87           
88            void setDefBoundarySound(const std::string& engineSound);
89            const std::string& getDefBoundarySound();
90            float getRadius();
91
92
93        private:
94            void registerVariables();
95
96            OrxoBlox* getOrxoBlox();
97            float radius_;
98            float fieldWidth_; //!< The width of the playing field.
99            float fieldHeight_; //!< The height of the playing field.
100            float speed_; //!< The speed (in x-direction) of the ball.
101            float accelerationFactor_; //!< The acceleration factor of the ball.
102           
103            unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network.
104            float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have.
105            WorldSound* defScoreSound_;
106            WorldSound* defBoundarySound_;
107            OrxoBlox* orxoblox_;
108    };
109}
110
111#endif /* _OrxoBloxBall_H__ */
Note: See TracBrowser for help on using the repository browser.