[Orxonox-commit 5061] r9725 - code/branches/invaders/src/modules/invader
zifloria at orxonox.net
zifloria at orxonox.net
Mon Oct 28 17:01:56 CET 2013
Author: zifloria
Date: 2013-10-28 17:01:56 +0100 (Mon, 28 Oct 2013)
New Revision: 9725
Added:
code/branches/invaders/src/modules/invader/InvaderCenterPoint.cc
code/branches/invaders/src/modules/invader/InvaderCenterPoint.h
code/branches/invaders/src/modules/invader/InvaderShip.cc
code/branches/invaders/src/modules/invader/InvaderShip.h
Log:
forgotten files
Added: code/branches/invaders/src/modules/invader/InvaderCenterPoint.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderCenterPoint.cc (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderCenterPoint.cc 2013-10-28 16:01:56 UTC (rev 9725)
@@ -0,0 +1,91 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderCenterPoint.cc
+ @brief Implementation of the InvaderCenterPoint class.
+*/
+
+#include "InvaderCenterPoint.h"
+
+#include "core/CoreIncludes.h"
+
+#include "Invader.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderCenterPoint);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object and checks whether the gametype is actually Invader.
+ */
+ InvaderCenterPoint::InvaderCenterPoint(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(InvaderCenterPoint);
+
+ this->checkGametype();
+ }
+
+ /**
+ @brief
+ Method to create a InvaderCenterPoint through XML.
+ */
+ void InvaderCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(InvaderCenterPoint, XMLPort, xmlelement, mode);
+
+// XMLPortParam(InvaderCenterPoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
+
+ }
+
+ /**
+ @brief
+ Is called when the gametype has changed.
+ */
+ void InvaderCenterPoint::changedGametype()
+ {
+ SUPER(InvaderCenterPoint, changedGametype);
+
+ // Check, whether it's still Invader.
+ this->checkGametype();
+ }
+
+ /**
+ @brief
+ Checks whether the gametype is Invader and if it is, sets its centerpoint.
+ */
+ void InvaderCenterPoint::checkGametype()
+ {
+ if (this->getGametype() != NULL && this->getGametype()->isA(Class(Invader)))
+ {
+ Invader* InvaderGametype = orxonox_cast<Invader*>(this->getGametype().get());
+ InvaderGametype->setCenterpoint(this);
+ }
+ }
+}
Added: code/branches/invaders/src/modules/invader/InvaderCenterPoint.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderCenterPoint.h (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderCenterPoint.h 2013-10-28 16:01:56 UTC (rev 9725)
@@ -0,0 +1,60 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderCenterPoint.h
+ @brief Declaration of the InvaderCenterPoint class.
+ @ingroup Invader
+*/
+
+#ifndef _InvaderCenterPoint_H__
+#define _InvaderCenterPoint_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderCenterPoint : public StaticEntity
+ {
+ public:
+ InvaderCenterPoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Invader.
+ virtual ~InvaderCenterPoint() {}
+
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a PongCenterpoint through XML.
+
+ virtual void changedGametype(); //!< Is called when the gametype has changed.
+ private:
+ void checkGametype(); //!< Checks whether the gametype is Pong and if it is, sets its centerpoint.
+
+ };
+}
+
+#endif /* _InvaderCenterPoint_H__ */
Added: code/branches/invaders/src/modules/invader/InvaderShip.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.cc (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderShip.cc 2013-10-28 16:01:56 UTC (rev 9725)
@@ -0,0 +1,93 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderShip.cc
+ @brief Implementation of the InvaderShip class.
+*/
+
+#include "InvaderShip.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderShip);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ InvaderShip::InvaderShip(Context* context) : SpaceShip(context)
+ {
+ RegisterObject(InvaderShip);
+
+ speed = 500;
+ damping = 10;
+ }
+
+ void InvaderShip::tick(float dt)
+ {
+ // If the bat is controlled (but not over the network).
+ if (this->hasLocalController())
+ {
+ this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x)); //
+ //this->setVelocity(this->getOrientation() * Vector3(1, 0, 0));
+ }
+ lastTimeFront += dt * damping;
+ lastTimeLeft += dt * damping;
+ velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
+ velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
+
+ if (isFireing)
+ ControllableEntity::fire(0);
+
+ SUPER(InvaderShip, tick, dt);
+ }
+
+ void InvaderShip::moveFrontBack(const Vector2& value)
+ {
+ orxout(internal_error) << "move backfront" << value.x << value.y << endl;
+ //velocity.y = value.y * speed * 10;
+ lastTimeFront = 0;
+ desiredVelocity.y = value.y * speed * 10;
+ }
+
+ void InvaderShip::moveRightLeft(const Vector2& value)
+ {
+ orxout(internal_error) << "right left front" << value.x << value.y << endl;
+ lastTimeLeft = 0;
+ desiredVelocity.x = value.x * speed;
+ // velocity.x = value.x * speed;
+ }
+ void InvaderShip::boost(bool bBoost)
+ {
+ isFireing = bBoost;
+ }
+}
Added: code/branches/invaders/src/modules/invader/InvaderShip.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.h (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderShip.h 2013-10-28 16:01:56 UTC (rev 9725)
@@ -0,0 +1,73 @@
+/*
+ * 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:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderShip.h
+ @brief Declaration of the InvaderShip class.
+*/
+
+#ifndef _InvaderShip_H__
+#define _InvaderShip_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderShip : public SpaceShip
+ {
+ public:
+ InvaderShip(Context* context); //!< Constructor. Registers and initializes the object.
+ virtual ~InvaderShip() {}
+
+ virtual void tick(float dt);
+
+ virtual void moveFrontBack(const Vector2& value);
+ virtual void moveRightLeft(const Vector2& value);
+
+ virtual void boost(bool bBoost); // Starts or stops fireing
+
+ //no rotation!
+ virtual void rotateYaw(const Vector2& value){};
+ virtual void rotatePitch(const Vector2& value){};
+ virtual void rotateRoll(const Vector2& value){};
+ private:
+ bool isFireing;
+ float speed, damping;
+ float lastTimeFront, lastTimeLeft;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity, desiredVelocity;
+
+ };
+}
+
+#endif /* _InvaderShip_H__ */
More information about the Orxonox-commit
mailing list