[Orxonox-commit 6935] r11556 - in code/branches/SOBv2_HS17: data/levels src/modules/superorxobros
zarron at orxonox.net
zarron at orxonox.net
Mon Nov 13 16:07:13 CET 2017
Author: zarron
Date: 2017-11-13 16:07:13 +0100 (Mon, 13 Nov 2017)
New Revision: 11556
Added:
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h
Modified:
code/branches/SOBv2_HS17/data/levels/SOB.oxw
code/branches/SOBv2_HS17/src/modules/superorxobros/CMakeLists.txt
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
Log:
Fireball implemented, Physics are crazy at the moment
Modified: code/branches/SOBv2_HS17/data/levels/SOB.oxw
===================================================================
--- code/branches/SOBv2_HS17/data/levels/SOB.oxw 2017-11-13 15:05:34 UTC (rev 11555)
+++ code/branches/SOBv2_HS17/data/levels/SOB.oxw 2017-11-13 15:07:13 UTC (rev 11556)
@@ -13,7 +13,6 @@
include("overlays/SOBHUD.oxo")
?>
- <!--THEO-->
<Template name=mushroom defaults=0>
@@ -99,9 +98,25 @@
</attached>
</MovableEntity>
+ <!--Test Fireball-->
- <!--Gumba-->
+
+ <SOBFireball collisionType="dynamic" speed=40 position = "20,0,100">
+ <attached>
+ <Model mesh="planets/sol.mesh" position="0,0,1" scale=3 pitch=90/>
+
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="5,5,5" />
+ </collisionShapes>
+ </SOBFireball>
+
+
+
+
+ <!--Gumba
+
<SOBGumba collisionType="dynamic" speed=40 position = "240,0,0">
<attached>
<Model mesh="Goomba.mesh" position="0,0,1" scale=3 pitch=90/>
@@ -111,6 +126,7 @@
<BoxCollisionShape position="0,0,0" halfExtents="5,5,3" />
</collisionShapes>
</SOBGumba>
+ Gumba-->
<SOBGumba collisionType="dynamic" speed=30 position = "420,0,0">
<attached>
<Model mesh="Goomba.mesh" position="0,0,21" scale=3 pitch=90/>
@@ -232,11 +248,6 @@
</StaticEntity>
-
-
-
-
-
<!-- Boden 1 -->
<Model mesh="Cube2.12.mesh" position="0,0,-30" scale=10 Pitch=90/> <!-- B1.1 -->
<Model mesh="Cube2.12.mesh" position="120,0,-30" scale=10 Pitch=90/> <!-- B1.2-->
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/CMakeLists.txt
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/CMakeLists.txt 2017-11-13 15:05:34 UTC (rev 11555)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/CMakeLists.txt 2017-11-13 15:07:13 UTC (rev 11556)
@@ -8,6 +8,7 @@
SOBMushroom.cc
SOBHUDInfo.cc
SOBGumba.cc
+ SOBFireball.cc
SOBFlagstone.cc
SOBCastlestone.cc
SOBCoin.cc
Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc 2017-11-13 15:05:34 UTC (rev 11555)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc 2017-11-13 15:07:13 UTC (rev 11556)
@@ -121,7 +121,7 @@
else if (gumba != nullptr && !(gumba->hasCollided_)) {
- //If player doesn't jump on its head, kill it, else, kill the player
+ //If player jumps on its head, kill the Gumba, else, kill the player
if (getVelocity().z >= -20) {
// If player hasn't a power up, he dies. Else he shrinks and the gumba dies.
if(!gotPowerUp_){
Added: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc (rev 0)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc 2017-11-13 15:07:13 UTC (rev 11556)
@@ -0,0 +1,157 @@
+/*
+ * 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:
+ * Theo von Arx
+ * Noah Zarro
+ * Co-authors:
+ *
+ *
+ */
+
+/**
+ @file SOBFireball.cc
+ @brief Fireballs are the Projectile of the Fireflower Powerup
+*/
+
+#include "SOBFireball.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "SOBFigure.h"
+#include "SOBGumba.h"
+#include "SOB.h"
+#include "util/Output.h"
+#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
+
+
+
+namespace orxonox
+{
+ RegisterClass(SOBFireball);
+
+ SOBFireball::SOBFireball(Context* context) : MovableEntity(context)
+ {
+ RegisterObject(SOBFireball);
+
+ attachedToFigure_ = false;
+ setAngularFactor(0.0);
+ figure_ = nullptr;
+ this->enableCollisionCallback();
+ gravityAcceleration_ = 3.0;
+ speed_ = 0;
+ hasCollided_=false;
+ lastPos_ = getPosition();
+ lastPos_.x -= 20;
+ changeAllowed_ = true;
+ changedOn_ = 0.0;
+ goesRight_ = true;
+ collDisX_ = 0;
+ collDisZ_ = 0;
+
+ orxout() << "fireball existed" << endl;
+
+
+ }
+
+
+
+ void SOBFireball::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(SOBFireball, XMLPort, xmlelement, mode);
+ XMLPortParam(SOBFireball, "speed", setSpeed, getSpeed, xmlelement, mode);
+
+
+ }
+
+
+ bool SOBFireball::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
+ collDisX_ = getPosition().x - contactPoint.getPositionWorldOnB().getX();
+ collDisZ_ = getPosition().z - contactPoint.getPositionWorldOnB().getZ();
+
+ SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
+
+ if(gumba!=nullptr && !(gumba->hasCollided_)) //if other object is a Gumba, kill the Gumba and add score and destroy the fireball
+ {
+ gumba->destroyLater();
+ gumba->hasCollided_ = true;
+ SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
+ SOBGame->addGumba();
+ this->destroyLater();
+ this->hasCollided_ = true;
+ }
+ //collision with either top or bottom of a block
+ else if(changeAllowed_ && (abs(collDisX_)<=abs(collDisZ_)))
+ {
+ changeAllowed_ = false;
+ Vector3 velocity = getVelocity();
+ velocity.z = -velocity.z;
+ setVelocity(velocity);
+ }
+
+ //collision with the vertical side of a block
+ else if(changeAllowed_ && (abs(collDisX_)>abs(collDisZ_)))
+ {
+ changeAllowed_ = false;
+ goesRight_=!goesRight_;
+ }
+
+
+ return true;
+ }
+
+
+ void SOBFireball::setFigure(SOBFigure* newFigure)
+ {
+ figure_ = newFigure;
+ }
+
+
+
+ void SOBFireball::tick(float dt)
+ {
+ SUPER(SOBFireball, tick, dt);
+
+ if (!changeAllowed_) {
+ changedOn_+= dt;
+ // After a collision, we don't listen for collisions for 200ms - that's because one wall can cause several collisions!
+ if (changedOn_> 0.200) {
+ changeAllowed_ = true;
+ changedOn_ = 0.0;
+
+ }
+ }
+
+
+ int dir = 1;
+ if (!goesRight_)
+ dir = -1;
+
+ Vector3 velocity = getVelocity();
+ velocity.z -= gravityAcceleration_*dt;
+ velocity.x = dir*speed_;
+ setVelocity(velocity);
+
+ lastPos_ = getPosition();
+ }
+
+
+}
Added: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h (rev 0)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h 2017-11-13 15:07:13 UTC (rev 11556)
@@ -0,0 +1,82 @@
+/*
+ * 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:
+ * Theo von Arx
+ Noah Zarro
+ * Co-authors:
+ *
+ *
+ */
+
+/**
+ @file SOBFireball.h
+ @brief Declaration of the SOBFireball class. Fireballs are the Projectile of the Fireflower Powerup
+ @ingroup SOB
+*/
+
+#ifndef _SOBFireball_H__
+#define _SOBFireball_H__
+
+#include "superorxobros/SOBPrereqs.h"
+#include "worldentities/MovableEntity.h"
+
+
+namespace orxonox
+{
+ class _SOBExport SOBFireball : public MovableEntity
+ {
+ public:
+ SOBFireball(Context* context);
+ virtual ~SOBFireball() {}
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void setFigure(SOBFigure* newFigure);
+ virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+ virtual void tick(float dt) override;
+
+
+ bool attachedToFigure_;
+
+ void setSpeed(const float speed)
+ { this->speed_ = speed; }
+ float getSpeed() const
+ { return speed_; }
+
+ bool hasCollided_;
+ protected:
+ int hitCounter_; //counts how many times the floor was hit, ball gets deleted if has hit the floor 3 times
+ float gravityAcceleration_;
+ float speed_;
+ WeakPtr<SOBFigure> figure_;
+ Vector3 lastPos_;
+ bool goesRight_;
+ bool changeAllowed_;
+ float changedOn_;
+
+
+ float collDisX_;
+ float collDisZ_;
+
+ };
+}
+
+#endif /* _SOBFireball_H__ */
More information about the Orxonox-commit
mailing list