[Orxonox-commit 6909] r11530 - code/branches/FlappyOrx_HS17/src/modules/flappyorx
pascscha at orxonox.net
pascscha at orxonox.net
Mon Nov 6 12:58:54 CET 2017
Author: pascscha
Date: 2017-11-06 12:58:54 +0100 (Mon, 06 Nov 2017)
New Revision: 11530
Added:
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h
Log:
Asteroid Clusters
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.cc 2017-11-06 11:58:54 UTC (rev 11530)
@@ -0,0 +1,89 @@
+/*
+ * 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 FlappyOrxAsteroid.h
+ @brief Declaration of the FlappyOrxAsteroid class.
+*/
+
+#include "FlappyOrxAsteroid.h"
+
+#include "core/CoreIncludes.h"
+#include "FlappyOrx.h"
+#include "FlappyOrxShip.h"
+
+namespace orxonox
+{
+ RegisterClass(FlappyOrxAsteroid);
+
+ FlappyOrxAsteroid::FlappyOrxAsteroid(Context* context) : Pawn(context)
+ {
+ RegisterObject(FlappyOrxAsteroid);
+ enableCollisionCallback();
+ lifetime = 0;
+ }
+
+ void FlappyOrxAsteroid::tick(float dt)
+ {
+ lifetime += dt;
+ // die after 5 seconds.
+ if (lifetime > 5000)
+ removeHealth(2000);
+
+ if (player != nullptr)
+ {
+ float newZ = 2/(pow(std::abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);
+ setVelocity(Vector3(1000.f - level * 100 , 0, newZ));
+ }
+ SUPER(FlappyOrxAsteroid, tick, dt);
+ }
+
+ inline bool FlappyOrxAsteroid::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+ {
+ if(orxonox_cast<FlappyOrxShip*>(otherObject))
+ removeHealth(2000);
+ return false;
+ }
+
+ FlappyOrx* FlappyOrxAsteroid::getGame()
+ {
+ if (game == nullptr)
+ {
+ for (FlappyOrx* flappyOrx : ObjectList<FlappyOrx>())
+ game = flappyOrx;
+ }
+ return game;
+ }
+
+ void FlappyOrxAsteroid::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
+ {
+ Pawn::damage(damage, healthdamage, shielddamage, originator, cs);
+ if (getGame() && orxonox_cast<FlappyOrxShip*>(originator) != nullptr && getHealth() <= 0)
+ getGame()->addPoints(42);
+ }
+}
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxAsteroid.h 2017-11-06 11:58:54 UTC (rev 11530)
@@ -0,0 +1,72 @@
+/*
+ * 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 FlappyOrxAsteroid.h
+ @brief Declaration of the FlappyOrxAsteroid class.
+*/
+
+#ifndef _FlappyOrxAsteroid_H__
+#define _FlappyOrxAsteroid_H__
+
+#include "flappyorx/FlappyOrxPrereqs.h"
+
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ class _FlappyOrxExport FlappyOrxAsteroid : public Pawn
+ {
+ public:
+ FlappyOrxAsteroid(Context* context);
+
+ virtual void tick(float dt) override;
+ virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+ virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override;
+ virtual void setFlappyOrxPlayer(FlappyOrxShip* player){this->player = player;}
+
+ int level;
+ protected:
+ FlappyOrx* getGame();
+ WeakPtr<FlappyOrx> game;
+ WeakPtr<FlappyOrxShip> player;
+ Camera* camera;
+ bool isFireing;
+ float speed, damping;
+ float lastTimeFront, lastTimeLeft;
+ float lifetime;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity, desiredVelocity;
+
+ };
+}
+
+#endif /* _FlappyOrxAsteroid_H__ */
More information about the Orxonox-commit
mailing list