[Orxonox-commit 6952] r11573 - in code/branches/SOBv2_HS17: data/levels src/modules/superorxobros

zarron at orxonox.net zarron at orxonox.net
Mon Nov 20 15:11:07 CET 2017


Author: zarron
Date: 2017-11-20 15:11:07 +0100 (Mon, 20 Nov 2017)
New Revision: 11573

Modified:
   code/branches/SOBv2_HS17/data/levels/SOB.oxw
   code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
   code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h
   code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc
   code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h
Log:
fireing Fireballs enabled

Modified: code/branches/SOBv2_HS17/data/levels/SOB.oxw
===================================================================
--- code/branches/SOBv2_HS17/data/levels/SOB.oxw	2017-11-20 13:46:48 UTC (rev 11572)
+++ code/branches/SOBv2_HS17/data/levels/SOB.oxw	2017-11-20 14:11:07 UTC (rev 11573)
@@ -63,8 +63,20 @@
 		</SOBFigure>
 	</Template> 
 
+					<!--Test Fireball-->
 
 
+	<Template name=fireball>
+		<SOBFireball collisionType="dynamic" speed=80>
+			<attached>
+				<Model mesh="planets/sol.mesh" position="0,0,0" scale=3 pitch=90/> 
+				
+			</attached>
+			<collisionShapes>
+				<SphereCollisionShape position="0,0,0" halfExtents="5,5,5" /> 			
+			</collisionShapes>
+		</SOBFireball>
+	</Template>
 
 
 
@@ -98,23 +110,10 @@
 				</attached>
 			</MovableEntity>
 
-					<!--Test Fireball-->
 
 
 
-					<SOBFireball collisionType="dynamic" speed=80 position = "10,0,40">
-						<attached>
-							<Model mesh="planets/sol.mesh" position="0,0,0" scale=3 pitch=90/> 
-							
-						</attached>
-						<collisionShapes>
-							<SphereCollisionShape position="0,0,0" halfExtents="5,5,5" /> 			
-						</collisionShapes>
-					</SOBFireball>
 
-
-
-
 					<!--Gumba
 
 					<SOBGumba collisionType="dynamic" speed=40 position = "240,0,0">

Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc	2017-11-20 13:46:48 UTC (rev 11572)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc	2017-11-20 14:11:07 UTC (rev 11573)
@@ -44,6 +44,7 @@
 #include "SOB.h"
 #include "SOBFlagstone.h"
 #include "SOBCastlestone.h"
+#include "SOBFireball.h"
 #include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
 
 namespace orxonox
@@ -82,6 +83,10 @@
         lvlEnded_ = false;
         reachedLvlEndState_ = 0;
 
+        //Properties of fireing Fireballs, NOTE! fireballs are fired with the moveUP Key, not with the fire key
+        fireallowed_=true;
+        firecooldown_=0;
+
         
         setAngularFactor(0.0); //Means player doesn't turn on collision, so he doesn't fall over while walking over the ground
         this->enableCollisionCallback(); // Turns on that on every collision function collidesAgainst is executed
@@ -110,7 +115,6 @@
             SOBGame->addMushroom(); // Tell the gametype to increase points
             mush->hasCollided_ = true; // needed because of destroyLater takes some time and player should receive points only once
 
-
             // now, change the clothes of the Figure to red
             std::string name = "orxo_material_gross";
             this->changeClothes(name);
@@ -179,6 +183,22 @@
     return 1;
 }
 
+//Function to spawn the Fireball
+void SOBFigure::spawnFireball() {
+        SOBCenterpoint* center_ = ((SOB*)getGametype())->center_;
+
+         SOBFireball* ball = new SOBFireball(center_->getContext());
+         Vector3 spawnpos = this->getWorldPosition();
+         spawnpos.z += 0;
+
+        if (ball != nullptr && center_ != nullptr)
+        {
+            ball->addTemplate("fireball");
+            ball->setPosition(spawnpos);
+            
+        }
+     }
+
 //For those of you who don't have an idea: the tick function is called about 50 times/sec
 void SOBFigure::tick(float dt)
 {
@@ -294,7 +314,24 @@
             velocity.x /= 1.1;
         }
 
+        //If moveUp pressed, fire a fireball
+        if(moveUpPressed_ && gotPowerUp_ && fireallowed_)
+        {
+            spawnFireball();
+            fireallowed_=false;
+            firecooldown_=0;
+        }
 
+        //Increase the firecooldown
+        if(firecooldown_>0.5)
+        {
+            fireallowed_=true;
+        }
+        if(!fireallowed_)
+        {
+            firecooldown_+=dt;
+        }
+
         //Again another EndOfLevel behavior
         if (reachedLvlEndState_ == 1)
             velocity.x = -2;

Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h	2017-11-20 13:46:48 UTC (rev 11572)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h	2017-11-20 14:11:07 UTC (rev 11573)
@@ -46,6 +46,7 @@
             virtual void boost(bool boost) override;
             virtual  bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
             void changeClothes(std::string& name);
+            void spawnFireball();
 
             bool dead_;
             bool predead_;
@@ -54,6 +55,7 @@
         private:
 
             //Soooo many declarations
+            bool fireallowed_;
             bool gotPowerUp_;
             bool moveUpPressed_;
             bool moveDownPressed_;
@@ -63,6 +65,7 @@
             float gravityAcceleration_;
             float timeSinceLastFire_;
             float lastSpeed_z;
+            float firecooldown_;
             SOBCenterpoint* sobcenterpoint;
             float pitch_;
             bool isColliding_;

Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc	2017-11-20 13:46:48 UTC (rev 11572)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc	2017-11-20 14:11:07 UTC (rev 11573)
@@ -66,7 +66,6 @@
         goesRight_ = true;
         collDisX_ = 0;
         collDisZ_ = 0;
-        hitCounter_ = 0;
 
       orxout() << "fireball existed" << endl;
 
@@ -120,8 +119,6 @@
             goesRight_=!goesRight_;
         }
 
-        hitCounter_++;
-
         
         return true;
     }

Modified: code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h
===================================================================
--- code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h	2017-11-20 13:46:48 UTC (rev 11572)
+++ code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h	2017-11-20 14:11:07 UTC (rev 11573)
@@ -63,7 +63,6 @@
 
             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_;



More information about the Orxonox-commit mailing list