[Orxonox-commit 7656] r12249 - code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
pomselj at orxonox.net
pomselj at orxonox.net
Thu Mar 28 14:40:18 CET 2019
Author: pomselj
Date: 2019-03-28 14:40:18 +0100 (Thu, 28 Mar 2019)
New Revision: 12249
Removed:
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBat.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBat.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBot.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBot.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongCenterpoint.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongCenterpoint.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongScore.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongScore.h
Log:
ohne nervige files
Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBat.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBat.cc 2019-03-28 13:38:36 UTC (rev 12248)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBat.cc 2019-03-28 13:40:18 UTC (rev 12249)
@@ -1,155 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file PongBat.cc
- @brief Implementation of the PongBat class.
-*/
-
-#include "PongBat.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
- RegisterClass(PongBat);
-
- /**
- @brief
- Constructor. Registers and initializes the object.
- */
- PongBat::PongBat(Context* context) : ControllableEntity(context)
- {
- RegisterObject(PongBat);
-
- this->movement_ = 0;
- this->bMoveLocal_ = false;
- this->speed_ = 60;
- this->length_ = 0.25;
- this->fieldHeight_ = 100;
- this->bSteadiedPosition_ = false;
-
- this->registerVariables();
- }
-
- /**
- @brief
- Registers variables to be synchronized over the network.
- */
- void PongBat::registerVariables()
- {
- registerVariable(this->speed_);
- registerVariable(this->fieldHeight_);
- registerVariable(this->length_);
- }
-
- /**
- @brief
- Is called each tick.
- Moves the bat.
- @param dt
- The time since last tick.
- */
- void PongBat::tick(float dt)
- {
- // If the bat is controlled (but not over the network).
- if (this->hasLocalController())
- {
- if (this->movement_ != 0)
- {
- // The absolute value of the movement is restricted to be lesser or equal than the speed of the bat.
- this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_;
-
- // If moveRightLeft() is used the movement is dependento on wehther it is the right or the left bat, so, it is i.e. dependent on the orientation of the bat.
- if (this->bMoveLocal_)
- this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0));
- else
- this->setVelocity(0, 0, this->movement_);
-
- this->movement_ = 0;
- this->bSteadiedPosition_ = false;
- }
- // If there is no movement but the position has not been steadied, the velocity is set to zero and the position is reaffirmed.
- else if (!this->bSteadiedPosition_)
- {
- // To ensure network synchronicity
- this->setVelocity(0, 0, 0);
- this->setPosition(this->getPosition());
- this->bSteadiedPosition_ = true;
- }
- }
-
- SUPER(PongBat, tick, dt);
-
- // Restrict the position of the bats, for them to always be between the upper and lower delimiters. i.e. the bats stall if they reach the upper or lower boundary.
- Vector3 position = this->getPosition();
- if (position.z > this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2)
- position.z = this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2;
- if (position.z < -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2)
- position.z = -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2;
- if (position != this->getPosition())
- {
- this->setPosition(position);
- this->setVelocity( Vector3::ZERO );
- }
- }
-
- /**
- @brief
- Overloaded the function to steer the bat up and down.
- @param value
- A vector whose first component is the inverse direction in which we want to steer the bat.
- */
- void PongBat::moveFrontBack(const Vector2& value)
- {
- this->bMoveLocal_ = false;
- this->movement_ = -value.x;
- }
-
- /**
- @brief
- Overloaded the function to steer the bat up and down.
- @param value
- A vector whose first component is the direction in which we wnat to steer the bat.
- */
- void PongBat::moveRightLeft(const Vector2& value)
- {
- this->bMoveLocal_ = true;
- this->movement_ = value.x;
- }
-
- /**
- @brief
- Is called when the player changed.
- */
- void PongBat::changedPlayer()
- {
- this->setVelocity(0, 0, 0);
- }
-}
Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBat.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBat.h 2019-03-28 13:38:36 UTC (rev 12248)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBat.h 2019-03-28 13:40:18 UTC (rev 12249)
@@ -1,120 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file PongBat.h
- @brief Declaration of the PongBat class.
- @ingroup Pong
-*/
-
-#ifndef _PongBat_H__
-#define _PongBat_H__
-
-#include "pong/PongPrereqs.h"
-
-#include "worldentities/ControllableEntity.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- The PongBat class manages the bats for @ref orxonox::Pong "Pong", which are the elements controlled by the players.
-
- It is responsible for the movement (controlled by the players) of the bat.
-
- @author
- Fabian 'x3n' Landau
-
- @ingroup Pong
- */
- class _PongExport PongBat : public ControllableEntity
- {
- public:
- PongBat(Context* context); //!< Constructor. Registers and initializes the object.
- virtual ~PongBat() {}
-
- virtual void tick(float dt) override;
-
- virtual void moveFrontBack(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down.
- virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down.
-
- virtual void changedPlayer() override; //!< Is called when the player changed.
-
- /**
- @brief Set the speed of the bat.
- @param speed The speed to be set.
- */
- void setSpeed(float speed)
- { this->speed_ = speed; }
- /**
- @brief Get the speed of the bat.
- @return Returns the speed of the bat.
- */
- float getSpeed() const
- { return this->speed_; }
-
- /**
- @brief Set the height of the playing field.
- @param height The height of the playing field.
- */
- void setFieldHeight(float height)
- { this->fieldHeight_ = height; }
- /**
- @brief Get the height of the playing field.
- @return Returns the height of the playing field.
- */
- float getFieldHeight() const
- { return this->fieldHeight_; }
-
- /**
- @brief Set the length of the bat.
- @param length The length of the bat (in z-direction) as percentage of the height of the playing field.
- */
- void setLength(float length)
- { this->length_ = length; }
- /**
- @brief Get the length of the bat.
- @return Returns the length of the bat (in z-direction) as percentage of the height of the playing field.
- */
- float getLength() const
- { return this->length_; }
-
- private:
- void registerVariables(); //!< Registers variables to be synchronized over the network.
-
- float movement_; //!< The amount (and direction), in z-direction, of movement of the bat.
- bool bMoveLocal_; //!< Helper to know whether the movement is caused by moveFrontBack() or moveRightLeft().
- float speed_; //!< The movement speed of the bat.
- float length_; //!< The length of the bat (in z-direction) as percentage of the height of the playing field.
- float fieldHeight_; //!< The height of the playing field.
- bool bSteadiedPosition_; //!< Helper boolean, to keep track of when to steady the position, to ensure network synchronicity.
- };
-}
-
-#endif /* _PongBat_H__ */
Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBot.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBot.cc 2019-03-28 13:38:36 UTC (rev 12248)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBot.cc 2019-03-28 13:40:18 UTC (rev 12249)
@@ -1,54 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file PongBot.cc
- @brief Implementation of the PongBot class.
-*/
-
-#include "PongBot.h"
-
-#include "core/CoreIncludes.h"
-#include "PongAI.h"
-
-namespace orxonox
-{
- RegisterClass(PongBot);
-
- /**
- @brief
- Constructor. Registers the object and creates a PongAI controller.
- */
- PongBot::PongBot(Context* context) : Bot(context)
- {
- RegisterObject(PongBot);
-
- this->defaultController_ = Class(PongAI);
- this->createController();
- }
-}
Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBot.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBot.h 2019-03-28 13:38:36 UTC (rev 12248)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongBot.h 2019-03-28 13:40:18 UTC (rev 12249)
@@ -1,63 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file PongBot.h
- @brief Declaration of the PongBot class.
- @ingroup Pong
-*/
-
-#ifndef _PongBot_H__
-#define _PongBot_H__
-
-#include "pong/PongPrereqs.h"
-#include "infos/Bot.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- A bot especially for @ref orxonox::Pong "Pong".
-
- Uses the @ref orxonox::PongAI "PongAI".
-
- @author
- Fabian 'x3n' Landau
-
- @ingroup Pong
- */
- class _PongExport PongBot : public Bot
- {
- public:
- PongBot(Context* context);
- virtual ~PongBot() {}
- };
-}
-
-#endif /* _PongBot_H__ */
Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongCenterpoint.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongCenterpoint.cc 2019-03-28 13:38:36 UTC (rev 12248)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongCenterpoint.cc 2019-03-28 13:40:18 UTC (rev 12249)
@@ -1,92 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file PongCenterpoint.cc
- @brief Implementation of the PongCenterpoint class.
-*/
-
-#include "PongCenterpoint.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-#include "Pong.h"
-
-namespace orxonox
-{
- RegisterClass(PongCenterpoint);
-
- /**
- @brief
- Constructor. Registers and initializes the object and checks whether the gametype is actually Pong.
- */
- PongCenterpoint::PongCenterpoint(Context* context) : StaticEntity(context)
- {
- RegisterObject(PongCenterpoint);
-
- this->width_ = 200;
- this->height_ = 120;
- this->ballspeed_ = 100;
- this->ballaccfactor_ = 1.0;
- this->batspeed_ = 60;
- this->batlength_ = 0.25;
-
- this->checkGametype();
- }
-
- /**
- @brief
- Method to create a PongCenterpoint through XML.
- */
- void PongCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(PongCenterpoint, XMLPort, xmlelement, mode);
-
- XMLPortParam(PongCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
- XMLPortParam(PongCenterpoint, "balltemplate", setBalltemplate, getBalltemplate, xmlelement, mode);
- XMLPortParam(PongCenterpoint, "battemplate", setBattemplate, getBattemplate, xmlelement, mode);
- XMLPortParam(PongCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
- XMLPortParam(PongCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
- XMLPortParam(PongCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode);
- XMLPortParam(PongCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode);
- }
-
- /**
- @brief
- Checks whether the gametype is Pong and if it is, sets its centerpoint.
- */
- void PongCenterpoint::checkGametype()
- {
- if (this->getGametype() != nullptr && this->getGametype()->isA(Class(Pong)))
- {
- Pong* pongGametype = orxonox_cast<Pong*>(this->getGametype());
- pongGametype->setCenterpoint(this);
- }
- }
-}
Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongCenterpoint.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongCenterpoint.h 2019-03-28 13:38:36 UTC (rev 12248)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongCenterpoint.h 2019-03-28 13:40:18 UTC (rev 12249)
@@ -1,235 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file PongCenterpoint.h
- @brief Declaration of the PongCenterpoint class.
- @ingroup Pong
-*/
-
-#ifndef _PongCenterpoint_H__
-#define _PongCenterpoint_H__
-
-#include "pong/PongPrereqs.h"
-
-#include <string>
-
-#include <util/Math.h>
-
-#include "worldentities/StaticEntity.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- The PongCenterpoint implements the playing field @ref orxonox::Pong "Pong" takes place in and allows for many parameters of the minigame to be set.
- The playing field resides in the x,z-plane, with the x-axis being the horizontal axis and the z-axis being the vertical axis.
-
- Various parameters can be set:
- - The <b>dimension</b> is a vector, that defines the width and height of the playing field. The default is <em>(200, 120)</em>.
- - The <b>balltemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBall", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
- - The <b>battemplate</b> is a template that is applied to the @ref orxonox::PongBall "PongBat", it can be used to attach different things to it, e.g. its @ref orxonox::Model "Model". See below for a usage example.
- - The <b>ballspeed</b> is the speed with which the @ref orxonox::PongBall "PongBall" moves. The default is <em>100</em>.
- - The <b>ballaccfactor</b> is the acceleration factor for the @ref orxonox::PongBall "PongBall". The default is <em>1.0</em>.
- - The <b>batspeed</b> is the speed with which the @ref orxonox::PongBat "PongBats" move. The default is <em>60</em>.
- - The <b>batlength</b> is the length of the @ref orxonox::PongBat "PongBats" as the percentage of the height of the playing field. The default is <em>0.25</em>.
-
- An example in XML of the PongCenterpoint would be:
-
- First the needed templates:
- The template for the @ref orxonox::PongBall "PongBall".
- @code
- <Template name="pongball">
- <PongBall>
- <attached>
- <Model mesh="sphere.mesh" scale="2" />
- <ParticleSpawner name="hiteffect" position="0,0,0" source="Orxonox/sparks2" lifetime="0.01" autostart="0" mainstate="spawn" />
- </attached>
- <eventlisteners>
- <EventTarget target="hiteffect" />
- </eventlisteners>
- </PongBall>
- </Template>
- @endcode
- As can be seen, a sphere is attached as the @ref orxonox::Model "Model" for the @ref orxonox::PongBall "PongBall", and also an @ref orxonox::EventListener "EventListener" that triggers a @ref orxonox::ParticleSpawner "ParticleSpawner", whenever the ball hits the boundaries is attached.
-
- Additionally the template for the @ref orxonox::PongBat "PongBat".
- @code
- <Template name="pongbatcameras" defaults="0">
- <PongBat>
- <camerapositions>
- <CameraPosition position="0,200,0" pitch="-90" absolute="true" />
- </camerapositions>
- </PongBat>
- </Template>
-
- <Template name="pongbat">
- <PongBat camerapositiontemplate=pongbatcameras>
- <attached>
- <Model position="0,0,3" mesh="cube.mesh" scale3D="14,2,2" />
- </attached>
- </PongBat>
- </Template>
- @endcode
- As can be seen, there are actually two templates. The first template is needed to set the camera for the @ref orxonox::PongBat "PongBat". The second template ist the actual template for the @ref orxonox::PongBat "PongBat", the template for the camera position is added and a @ref orxonox::Model "Model" for the @ref orxonox::PongBat "PongBat" is attached.
-
- Finally the PongCenterpoint is created.
- @code
- <PongCenterpoint name="pongcenter" dimension="200,120" balltemplate="pongball" battemplate="pongbat" ballspeed="200" ballaccfactor="1.0" batspeed="130" batlength="0.25">
- <attached>
- <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" />
- <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" />
- </attached>
- </PongCenterpoint>
- @endcode
- All parameters are specified. And also two @ref orxonox::Model "Models" (for the upper and lower boundary) are attached.
-
- For a more elaborate example, have a look at the <code>pong.oxw</code> level file.
-
- @author
- Fabian 'x3n' Landau
-
- @ingroup Pong
- */
- class _PongExport PongCenterpoint : public StaticEntity
- {
- public:
- PongCenterpoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Pong.
- virtual ~PongCenterpoint() {}
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method to create a PongCenterpoint through XML.
-
- /**
- @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.)
- @param balltemplate The name of the template to be set.
- */
- void setBalltemplate(const std::string& balltemplate)
- { this->balltemplate_ = balltemplate; }
- /**
- @brief Get the template of the ball.
- @return Returns the name of the template of the ball.
- */
- const std::string& getBalltemplate() const
- { return this->balltemplate_; }
-
- /**
- @brief Set the template for the bats. (e.g. to attach the model of the bat, but also to attach CameraPositions to it, to be able to view the game from the bats perspective)
- @param battemplate The name of the template to be set.
- */
- void setBattemplate(const std::string& battemplate)
- { this->battemplate_ = battemplate; }
- /**
- @brief Get the template of the bats.
- @return Returns the name of the template of the bats.
- */
- const std::string& getBattemplate() const
- { return this->battemplate_; }
-
- /**
- @brief Set the dimensions of the playing field.
- @param dimension A vector with the width of the playing field as first component and the height as second.
- */
- void setFieldDimension(const Vector2& dimension)
- { this->width_ = dimension.x; this->height_ = dimension.y; }
- /**
- @brief Get the dimensions of the playing field.
- @return Returns a vector with the width of the playing field as first component and the height as second.
- */
- Vector2 getFieldDimension() const
- { return Vector2(this->width_, this->height_); }
-
- /**
- @brief Set the speed of the ball.
- @param ballspeed The speed of the ball.
- */
- void setBallSpeed(float ballspeed)
- { this->ballspeed_ = ballspeed; }
- /**
- @brief Get the speed of the ball.
- @return Returns the speed of the ball.
- */
- float getBallSpeed() const
- { return this->ballspeed_; }
-
- /**
- @brief Set the ball's acceleration factor.
- @param ballaccfactor The ball's acceleration factor.
- */
- void setBallAccelerationFactor(float ballaccfactor)
- { this->ballaccfactor_ = ballaccfactor; }
- /**
- @brief Get the ball's acceleration factor
- @return Returns the ball's acceleration factor.
- */
- float getBallAccelerationFactor() const
- { return this->ballaccfactor_; }
-
- /**
- @brief Set the speed of the bats.
- @param batspeed The speed of the bats.
- */
- void setBatSpeed(float batspeed)
- { this->batspeed_ = batspeed; }
- /**
- @brief Get the speed of the bats.
- @return Returns the speed of the bats.
- */
- float getBatSpeed() const
- { return this->batspeed_; }
-
- /**
- @brief Set the length of the bats.
- @param batlength The length of the bats (in z-direction) as a percentage of the height of the playing field.
- */
- void setBatLength(float batlength)
- { this->batlength_ = batlength; }
- /**
- @brief Get the length of the bats.
- @return Returns the length of the bats (in z-direction) as a percentage of the height of the playing field.
- */
- float getBatLength() const
- { return this->batlength_; }
-
- private:
- void checkGametype(); //!< Checks whether the gametype is Pong and if it is, sets its centerpoint.
-
- std::string balltemplate_; //!< The template for the ball.
- std::string battemplate_; //!< The template for the bats.
-
- float ballspeed_; //!< The speed of then ball.
- float ballaccfactor_; //!< The acceleration factor of the ball.
- float batspeed_; //!< The speed of the bat.
- float batlength_; //!< The length of the bat (in z-direction) as a percentage of the height of the playing field.
-
- float width_; //!< The height of the playing field.
- float height_; //!< The width of the playing field.
- };
-}
-
-#endif /* _PongCenterpoint_H__ */
Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongScore.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongScore.cc 2019-03-28 13:38:36 UTC (rev 12248)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongScore.cc 2019-03-28 13:40:18 UTC (rev 12249)
@@ -1,176 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file PongScore.cc
- @brief Implementation of the PongScore class.
-*/
-
-#include "PongScore.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Convert.h"
-
-#include "infos/PlayerInfo.h"
-
-#include "Pong.h"
-#include "sound/WorldSound.h" /////////////////////////////
-
-namespace orxonox
-{
- RegisterClass(PongScore);
-
- /**
- @brief
- Constructor. Registers and initializes the object.
- */
- PongScore::PongScore(Context* context) : OverlayText(context)
- {
- RegisterObject(PongScore);
-
- this->owner_ = nullptr;
-
- this->bShowName_ = false;
- this->bShowScore_ = false;
- this->bShowLeftPlayer_ = false;
- this->bShowRightPlayer_ = false;
- }
-
- /**
- @brief
- Destructor.
- */
- PongScore::~PongScore()
- {
- }
-
- /**
- @brief
- Method to create a PongScore through XML.
- */
- void PongScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(PongScore, XMLPort, xmlelement, mode);
-
- XMLPortParam(PongScore, "showname", setShowName, getShowName, xmlelement, mode).defaultValues(false);
- XMLPortParam(PongScore, "showscore", setShowScore, getShowScore, xmlelement, mode).defaultValues(false);
- XMLPortParam(PongScore, "showleftplayer", setShowLeftPlayer, getShowLeftPlayer, xmlelement, mode).defaultValues(false);
- XMLPortParam(PongScore, "showrightplayer", setShowRightPlayer, getShowRightPlayer, xmlelement, mode).defaultValues(false);
- }
-
- /**
- @brief
- Is called each tick.
- Creates and sets the caption to be displayed by the PongScore.
- @param dt
- The time that has elapsed since the last tick.
- */
- void PongScore::tick(float dt)
- {
- SUPER(PongScore, tick, dt);
-
- // If the owner is set. The owner being a Pong game.
- if (this->owner_ != nullptr)
- {
- if (!this->owner_->hasEnded())
- {
- // Get the two players.
- player1_ = this->owner_->getLeftPlayer();
- player2_ = this->owner_->getRightPlayer();
- }
-
- std::string name1;
- std::string name2;
-
- std::string score1("0");
- std::string score2("0");
-
- // Save the name and score of each player as a string.
- if (player1_ != nullptr)
- {
- name1 = player1_->getName();
- score1 = multi_cast<std::string>(this->owner_->getScore(player1_));
- }
- if (player2_ != nullptr)
- {
- name2 = player2_->getName();
- score2 = multi_cast<std::string>(this->owner_->getScore(player2_));
- }
-
- // Assemble the strings, depending on what should all be displayed.
- std::string output1;
- if (this->bShowLeftPlayer_)
- {
- if (this->bShowName_ && this->bShowScore_ && player1_ != nullptr)
- output1 = name1 + " - " + score1;
- else if (this->bShowScore_)
- output1 = score1;
- else if (this->bShowName_)
- output1 = name1;
- }
-
- std::string output2;
- if (this->bShowRightPlayer_)
- {
- if (this->bShowName_ && this->bShowScore_ && player2_ != nullptr)
- output2 = score2 + " - " + name2;
- else if (this->bShowScore_)
- output2 = score2;
- else if (this->bShowName_)
- output2 = name2;
- }
-
- std::string output("PONG");
- if (this->bShowName_ || this->bShowScore_)
- {
- if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
- output = output1 + ':' + output2;
- else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
- output = output1 + output2;
- }
-
- this->setCaption(output);
- }
- }
-
- /**
- @brief
- Is called when the owner changes.
- Sets the owner to nullptr, if it is not a pointer to a Pong game.
- */
- void PongScore::changedOwner()
- {
- SUPER(PongScore, changedOwner);
-
- if (this->getOwner() != nullptr && this->getOwner()->getGametype())
- this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype());
- else
- this->owner_ = nullptr;
- }
-}
Deleted: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongScore.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongScore.h 2019-03-28 13:38:36 UTC (rev 12248)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongScore.h 2019-03-28 13:40:18 UTC (rev 12249)
@@ -1,130 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file PongScore.h
- @brief Declaration of the PongScore class.
- @ingroup Pong
-*/
-
-#ifndef _PongScore_H__
-#define _PongScore_H__
-
-#include "pong/PongPrereqs.h"
-
-#include "tools/interfaces/Tickable.h"
-
-#include "overlays/OverlayText.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- The PongScore class displays the score for a game of @ref orxonox::Pong "Pong".
-
- @author
- Fabian 'x3n' Landau
-
- @ingroup Pong
- */
- class _PongExport PongScore : public OverlayText, public Tickable
- {
- public:
- PongScore(Context* context);
- virtual ~PongScore();
-
- virtual void tick(float dt) override; //!< Creates and sets the caption to be displayed by the PongScore.
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
- virtual void changedOwner() override; //!< Is called when the owner changes.
-
- /**
- @brief Set whether the PongScore displays the players' names.
- @param value If true the players' names are displayed.
- */
- inline void setShowName(bool value)
- { this->bShowName_ = value; }
- /**
- @brief Get whether the PongScore displays the players' names.
- @return Returns true if the players' names are displayed, false otherwise.
- */
- inline bool getShowName() const
- { return this->bShowName_; }
-
- /**
- @brief Set whether the PongScore displays the players' scores.
- @param value If true the players' scores are displayed.
- */
- inline void setShowScore(bool value)
- { this->bShowScore_ = value; }
- /**
- @brief Get whether the PongScore displays the players' scores.
- @return Returns true if the players' scores are displayed, false otherwise.
- */
- inline bool getShowScore() const
- { return this->bShowScore_; }
-
- /**
- @brief Set whether the PongScore displays the left player.
- @param value If true the left player is displayed.
- */
- inline void setShowLeftPlayer(bool value)
- { this->bShowLeftPlayer_ = value; }
- /**
- @brief Get whether the PongScore displays the left player.
- @return Returns true if the left player is displayed, false otherwise.
- */
- inline bool getShowLeftPlayer() const
- { return this->bShowLeftPlayer_; }
-
- /**
- @brief Set whether the PongScore displays the right player.
- @param value If true the right player is displayed.
- */
- inline void setShowRightPlayer(bool value)
- { this->bShowRightPlayer_ = value; }
- /**
- @brief Get whether the PongScore displays the right player.
- @return Returns true if the right player is displayed, false otherwise.
- */
- inline bool getShowRightPlayer() const
- { return this->bShowRightPlayer_; }
-
- private:
- Pong* owner_; //!< The Pong game that owns this PongScore.
- bool bShowName_; //!< Whether the names of the players are shown.
- bool bShowScore_; //!< Whether the score of the players is shown.
- bool bShowLeftPlayer_; //!< Whether the left player is shown.
- bool bShowRightPlayer_; //!< Whether the right player is shown.
- WeakPtr<PlayerInfo> player1_; //!< Store information about left player permanently.
- WeakPtr<PlayerInfo> player2_; //!< Same for the right player. To end the game properly.
- WorldSound* scoreSound_;
-
- };
-}
-#endif /* _PongScore_H__ */
More information about the Orxonox-commit
mailing list