[Orxonox-commit 6784] r11412 - in code/branches/SuperOrxoBros_FS17: data/levels data/overlays src/modules/superorxobros
jkindle at orxonox.net
jkindle at orxonox.net
Thu May 4 15:17:59 CEST 2017
Author: jkindle
Date: 2017-05-04 15:17:59 +0200 (Thu, 04 May 2017)
New Revision: 11412
Added:
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFlagstone.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFlagstone.h
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBGumba.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBGumba.h
Modified:
code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw
code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBHUDInfo.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.h
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBPrereqs.h
Log:
Fixed turning, added and finished Gumbas, added turnOnCollide for all NPC and items, added Flagstone - todo: add points on flagstone hit and go into a between lvl mode, then warp to lvl 2. AAH, and added onDeath fcts...
Modified: code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw
===================================================================
--- code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw 2017-05-04 13:17:59 UTC (rev 11412)
@@ -117,6 +117,20 @@
+ <SOBGumba collisionType="dynamic" speed=30>
+ <attached>
+ <Model mesh="Goomba.mesh" position="0,0,21" scale=3 pitch=90/>
+
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,20" halfExtents="5,5,3" /> <!-- ?????? -->
+ </collisionShapes>
+ </SOBGumba>
+
+
+
+
+
<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-->
<Model mesh="Cube2.12.mesh" position="240,0,-30" scale=10 Pitch=90/> <!-- B1.3 -->
@@ -126,7 +140,7 @@
<Model mesh="Cube2.3.mesh" position="660,0,-30" scale=10 Pitch=90/> <!-- B1.7 -->
- <StaticEntity collisionType="static">
+ <StaticEntity collisionType="static" mass='-1'>
<collisionShapes>
<BoxCollisionShape position="340,0,-20" halfExtents="345,5,5" />
</collisionShapes>
@@ -138,7 +152,7 @@
<!-- BLOCK 1 in der LUFT - alle analog wie diesen :) -->
<!-- Sobald ein QBlock von unten gehittet wird, wechselt die Visibility von allen attached Models. Hier wuerde also Cube1.1 invisible und Cube2.12 visible. Die Collisionshape wird ja sowieso beibehalten. -->
- <SOBQBlock collisionType="static" type="Mushroom" position="170,0,20"> <!-- L1.1 -->
+ <SOBQBlock collisionType="static" type="Mushroom" position="170,0,20" mass=-1> <!-- L1.1 -->
<attached>
<Model mesh="QCube.mesh" scale=10 pitch=90 />
<Model mesh="QCube-grey.mesh" scale=10 pitch=90 visible=false/>
@@ -207,28 +221,6 @@
- <SOBMushroom collisionType="dynamic" speed=30>
- <attached>
- <Model mesh="Goomba.mesh" position="0,0,21" scale=3 pitch=90/>
-
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,20" halfExtents="5,5,3" /> <!-- ?????? -->
- </collisionShapes>
- </SOBMushroom>
-
- <SOBMushroom collisionType="dynamic" speed=30>
- <attached>
- <Model mesh="Alien.mesh" position="30,0,21" scale=3 pitch=90/>
-
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="30,0,20" halfExtents="5,5,3" /> <!-- ?????? -->
- </collisionShapes>
- </SOBMushroom>
-
-
-
<StaticEntity collisionType="static"><!-- ? Block -->
<collisionShapes><!-- ?/S Block has his own collisionShape(1,3,5,6) -->
Modified: code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo
===================================================================
--- code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo 2017-05-04 13:17:59 UTC (rev 11412)
@@ -47,8 +47,8 @@
font = "ShareTechMono"
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
- align = "middle"
- caption = "WORLD\n 1-1"
+ align = "center"
+ caption = "WORLD\n1-1"
/>
@@ -78,6 +78,18 @@
+ <SOBHUDInfo
+ position = "0.5,0.5"
+ pickpoint = "0.5, 0.5"
+ textposition = "0.5, 0.5"
+ textpickpoint = "0.5, 0.5"
+ font = "ShareTechMono"
+ textsize = 0.07
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "center"
+ type = "Info"
+
+ />
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt 2017-05-04 13:17:59 UTC (rev 11412)
@@ -7,6 +7,8 @@
SOBQBlock.cc
SOBMushroom.cc
SOBHUDInfo.cc
+ SOBGumba.cc
+ SOBFlagstone.cc
)
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc 2017-05-04 13:17:59 UTC (rev 11412)
@@ -37,6 +37,7 @@
#include "core/EventIncludes.h"
#include "core/command/Executor.h"
#include "core/config/ConfigValueIncludes.h"
+#include "core/Game.h"
#include "gamestates/GSLevel.h"
#include "chat/ChatManager.h"
@@ -67,6 +68,8 @@
coins_=0;
points_=0;
timeLeft_=400.0;
+
+ lvl_ = 1;
}
@@ -85,7 +88,7 @@
camera = nullptr;
}
- void SOB::start()
+ void SOB::start()
{
if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place.
{
@@ -124,6 +127,16 @@
Deathmatch::end();
}
+ void SOB::restart() {
+ cleanup();
+
+ // HACK
+ Game::getInstance().popState();
+ Game::getInstance().popState();
+ Game::getInstance().requestStates("standalone, level");
+
+
+ }
void SOB::spawnPlayer(PlayerInfo* player)
{
assert(player);
@@ -147,15 +160,17 @@
}
}
-void SOB::tick(float dt)
+ void SOB::tick(float dt)
{
SUPER(SOB, tick, dt);
- if (this->figure_ != nullptr && figure_->dead_)
+ if (this->figure_ != nullptr && figure_->dead_) {
+ info_ = "Game over. Press <Space> to restart";
orxout() << "DEED" << endl;
-
+ }
+
- timeLeft_-=dt*2.5;
+ timeLeft_-=dt*2.5;
}
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h 2017-05-04 13:17:59 UTC (rev 11412)
@@ -61,6 +61,7 @@
virtual void spawnPlayer(PlayerInfo* player) override;
PlayerInfo* getPlayer() const;
+ void restart();
int getPoints() {
return points_;
}
@@ -74,12 +75,23 @@
void addMushroom() {
points_+=1000;
}
+ void addGumba() {
+ points_+=100;
+ }
int getTimeLeft() {
return timeLeft_;
}
+ std::string getInfoText() {
+ return info_;
+ }
-
- virtual void playerEntered(PlayerInfo* player) override
+ void setLvl(int lvl) {
+ lvl_ = lvl;
+ }
+ int getLvl() {
+ return lvl_;
+ }
+ virtual void playerEntered(PlayerInfo* player) override
{
Gametype::playerEntered(player);
}
@@ -96,6 +108,9 @@
int points_;
int coins_;
float timeLeft_;
+
+ int lvl_;
+ std::string info_;
};
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc 2017-05-04 13:17:59 UTC (rev 11412)
@@ -40,7 +40,9 @@
#include "graphics/ParticleSpawner.h"
#include "SOBMushroom.h"
+#include "SOBGumba.h"
#include "SOB.h"
+#include "SOBFlagstone.h"
namespace orxonox
{
@@ -65,6 +67,7 @@
gravityAcceleration_ = 350.0;
pitch_ = 0.0;
+ predead_ = false;
dead_ = false;
gotPowerUp_ = false;
@@ -78,7 +81,9 @@
isColliding_ = true;
SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject);
- // ADD ANOTHER OBJECT FOR BAD GUMBAS AND REMOVE POWERUP OR KILL PLAYER ON COLLISION WITHOUT Z-ACCELERATION
+ SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
+ SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*>(otherObject);
+
if (mush != nullptr && !(mush->hasCollided_)) {
otherObject->destroyLater();
gotPowerUp_ = true;
@@ -86,80 +91,112 @@
SOBGame->addMushroom();
mush->hasCollided_ = true;
+ } else if (gumba != nullptr && !(gumba->hasCollided_)) {
+
+ if (getVelocity().z >= -20) {
+ Vector3 vel = getVelocity();
+ vel.y = -80;
+ vel.z = 200;
+ setVelocity(vel);
+ predead_=true;
+ } else {
+ gumba->destroyLater();
+ gumba->hasCollided_ = true;
+ SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
+ SOBGame->addGumba();
+
+
}
-
- return true;
}
+ if (flagstone != nullptr && !(flagstone->hasCollided_)) {
+ flagstone->hasCollided_ = true;
+ }
- void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(SOBFigure, XMLPort, xmlelement, mode);
+ return true;
+}
- }
+void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+{
+ SUPER(SOBFigure, XMLPort, xmlelement, mode);
- void SOBFigure::tick(float dt)
- {
- SUPER(SOBFigure, tick, dt);
+}
- if (particlespawner_ == NULL) {
- for (WorldEntity* object : this->getAttachedObjects())
- {
- if (object->isA(Class(ParticleSpawner)))
- particlespawner_ = object;
- }
+int SOBFigure::sgn(float x) {
+ if (x < 0.0) return -1;
+ return 1;
+}
+
+void SOBFigure::tick(float dt)
+{
+ SUPER(SOBFigure, tick, dt);
+
+ if (particlespawner_ == NULL) {
+ for (WorldEntity* object : this->getAttachedObjects())
+ {
+ if (object->isA(Class(ParticleSpawner)))
+ particlespawner_ = object;
+
}
+}
- if (firePressed_ == false) {
- gravityAcceleration_ = 350.0;
- }
+if (firePressed_ == false) {
+ gravityAcceleration_ = 350.0;
- if (hasLocalController())
- {
- Vector3 velocity = getVelocity();
- Vector3 position = getPosition();
+}
+if (hasLocalController())
+{
+ Vector3 velocity = getVelocity();
+ Vector3 position = getPosition();
- if (position.z < -100)
- dead_ = true;
+ if (!predead_)
+ velocity.y = 0;
+if (position.z < -100) {
+ dead_ = true;
- if (dead_) {
- velocity.x = 0;
- velocity.z = 0;
- setVelocity(velocity);
- return;
- }
+}
+if (dead_) {
+ velocity.x = 0;
+ velocity.z = 0;
+ setVelocity(velocity);
+ SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
+ if (firePressed_)
+ SOBGame->restart();
+ return;
+}
- int maxvelocity_x = 100;
- int speedAddedPerTick = 5;
- int camMaxOffset = 25;
- timeSinceLastFire_ += dt;
- lastSpeed_z = velocity.z;
+int maxvelocity_x = 100;
+int speedAddedPerTick = 5;
+int camMaxOffset = 25;
+timeSinceLastFire_ += dt;
+lastSpeed_z = velocity.z;
+
//Handle the rocket fire from the jetpack
- if (velocity.z > 40)
- particlespawner_->setVisible(true);
- else
- particlespawner_->setVisible(false);
+if (velocity.z > 40)
+ particlespawner_->setVisible(true);
+else
+ particlespawner_->setVisible(false);
//If player hits space and does not move in z-dir
- if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
- gravityAcceleration_ = 100.0;
+if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
+ gravityAcceleration_ = 100.0;
velocity.z = 110; //150
}
@@ -168,25 +205,22 @@
//Left-right movement with acceleration
float rot = getOrientation().getRoll().valueDegrees();
+ orxout() << rot << endl;
if (moveRightPressed_) {
- if (rot < 0.0)
- setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
+ if (!(rot < 5.0 && -5.0 < rot))
+ setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() - sgn(rot)*dt*Radian(6));
+
if (std::abs(velocity.x) < maxvelocity_x) {
velocity.x += speedAddedPerTick;
-
-
-
-
- // if (pitch_ > 0.0) {
- // pitch -= turn_fac*dt);
- // }
}
} else if (moveLeftPressed_) {
- if (rot >= 0.0)
- setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
+ if (!(abs(rot) > 175.0 ))
+ setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + sgn(rot)*dt*Radian(6));
+
+
if (std::abs(velocity.x) < maxvelocity_x) {
velocity.x -= speedAddedPerTick;
}
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h 2017-05-04 13:17:59 UTC (rev 11412)
@@ -37,7 +37,7 @@
{
class _SOBExport SOBFigure : public ControllableEntity
{
- public:
+ public:
SOBFigure(Context* context); //!< Constructor. Registers and initializes the object.
virtual ~SOBFigure() {}
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
@@ -45,21 +45,21 @@
virtual void moveFrontBack(const Vector2& value) override; //!< Overloaded the function to steer the figure up and down.
virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the figure up and down.
-
+
virtual void boost(bool boost) override;
virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
-
+
//virtual void CollisionWithEnemy(SOBEnemy* enemy);
-
-
+
+
bool dead_;
+ bool predead_;
-
private:
-
+
bool gotPowerUp_;
bool moveUpPressed_;
bool moveDownPressed_;
@@ -73,11 +73,13 @@
float pitch_;
bool isColliding_;
WorldEntity* particlespawner_;
+ int sgn(float x);
-
+
+
-
- };
-}
+ };
+ }
+
#endif /* _SOBFigure_H__ */
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFlagstone.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFlagstone.cc (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFlagstone.cc 2017-05-04 13:17:59 UTC (rev 11412)
@@ -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:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file SOBFlagstone.cc
+ @brief All items in this minigame inherit from this class. Items can move around like platforms and enemies.
+*/
+
+#include "SOBFlagstone.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "SOBFigure.h"
+#include "util/Output.h"
+
+
+namespace orxonox
+{
+ RegisterClass(SOBFlagstone);
+
+ SOBFlagstone::SOBFlagstone(Context* context) : MovableEntity(context)
+ {
+ RegisterObject(SOBFlagstone);
+
+ setAngularFactor(0.0);
+ this->enableCollisionCallback();
+
+ hasCollided_=false;
+
+
+ }
+
+
+
+ void SOBFlagstone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(SOBFlagstone, XMLPort, xmlelement, mode);
+ XMLPortParam(SOBFlagstone, "points", setPoints, getPoints, xmlelement, mode);
+
+
+ }
+
+
+ bool SOBFlagstone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
+
+
+
+orxout() << "Watshc bum baem" << otherObject->getMass()<< endl;
+return true;
+ }
+
+
+
+
+
+
+}
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFlagstone.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFlagstone.h (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFlagstone.h 2017-05-04 13:17:59 UTC (rev 11412)
@@ -0,0 +1,65 @@
+/*
+ * 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:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file SOBFlagstone.h
+ @brief Declaration of the SOBFlagstone class.
+ @ingroup SOB
+*/
+
+#ifndef _SOBFlagstone_H__
+#define _SOBFlagstone_H__
+
+#include "superorxobros/SOBPrereqs.h"
+#include "worldentities/MovableEntity.h"
+
+
+namespace orxonox
+{
+ class _SOBExport SOBFlagstone : public MovableEntity
+ {
+ public:
+ SOBFlagstone(Context* context);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+
+ void setPoints(int points) {
+ points_ = points;
+ }
+ int getPoints() {
+ return points_;
+ }
+
+
+ bool hasCollided_;
+ protected:
+ int points_;
+ };
+}
+
+#endif /* _SOBFlagstone_H__ */
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBGumba.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBGumba.cc (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBGumba.cc 2017-05-04 13:17:59 UTC (rev 11412)
@@ -0,0 +1,202 @@
+/*
+ * 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:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file SOBGumba.cc
+ @brief All items in this minigame inherit from this class. Items can move around like platforms and enemies.
+*/
+
+#include "SOBGumba.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "SOBFigure.h"
+#include "util/Output.h"
+
+
+namespace orxonox
+{
+ RegisterClass(SOBGumba);
+
+ SOBGumba::SOBGumba(Context* context) : MovableEntity(context)
+ {
+ RegisterObject(SOBGumba);
+
+ attachedToFigure_ = false;
+ setAngularFactor(0.0);
+ figure_ = nullptr;
+ this->enableCollisionCallback();
+ gravityAcceleration_ = 350.0;
+ speed_ = 0.0;
+ hasCollided_=false;
+ goesRight_ = true;
+ lastPos_ = getPosition();
+ lastPos_.x -= 20;
+ changeAllowed_ = true;
+ changedOn_ = 0.0;
+
+ }
+
+
+
+ void SOBGumba::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(SOBGumba, XMLPort, xmlelement, mode);
+ XMLPortParam(SOBGumba, "speed", setSpeed, getSpeed, xmlelement, mode);
+
+
+ }
+
+
+ bool SOBGumba::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
+
+
+ if (changeAllowed_ && otherObject->getMass() != -1) {
+ goesRight_ = !goesRight_;
+ changeAllowed_ = false;
+ }
+
+ return true;
+ }
+
+
+ void SOBGumba::setFigure(SOBFigure* newFigure)
+ {
+ figure_ = newFigure;
+ }
+
+ void SOBGumba::touchFigure()
+ {
+
+ }
+
+ void SOBGumba::tick(float dt)
+ {
+ SUPER(SOBGumba, tick, dt);
+
+ if (!changeAllowed_) {
+ changedOn_+= dt;
+ if (changedOn_> 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();
+ }
+
+
+}
+/*
+ * 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:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file SOBGumba.h
+ @brief Declaration of the SOBGumba class.
+ @ingroup SOB
+*/
+
+#ifndef _SOBGumba_H__
+#define _SOBGumba_H__
+
+#include "superorxobros/SOBPrereqs.h"
+#include "worldentities/MovableEntity.h"
+
+
+namespace orxonox
+{
+ class _SOBExport SOBGumba : public MovableEntity
+ {
+ public:
+ SOBGumba(Context* context);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void setFigure(SOBFigure* newFigure);
+ virtual void touchFigure();
+ 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:
+ float gravityAcceleration_;
+ float speed_;
+ WeakPtr<SOBFigure> figure_;
+ bool goesRight_;
+ Vector3 lastPos_;
+ bool changeAllowed_;
+ float changedOn_;
+
+ };
+}
+
+#endif /* _SOBGumba_H__ */
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBGumba.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBGumba.h (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBGumba.h 2017-05-04 13:17:59 UTC (rev 11412)
@@ -0,0 +1,75 @@
+/*
+ * 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:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file SOBGumba.h
+ @brief Declaration of the SOBGumba class.
+ @ingroup SOB
+*/
+
+#ifndef _SOBGumba_H__
+#define _SOBGumba_H__
+
+#include "superorxobros/SOBPrereqs.h"
+#include "worldentities/MovableEntity.h"
+
+
+namespace orxonox
+{
+ class _SOBExport SOBGumba : public MovableEntity
+ {
+ public:
+ SOBGumba(Context* context);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void setFigure(SOBFigure* newFigure);
+ virtual void touchFigure();
+ 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:
+ float gravityAcceleration_;
+ float speed_;
+ WeakPtr<SOBFigure> figure_;
+ bool goesRight_;
+ Vector3 lastPos_;
+ bool changeAllowed_;
+ float changedOn_;
+
+ };
+}
+
+#endif /* _SOBGumba_H__ */
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBHUDInfo.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBHUDInfo.cc 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBHUDInfo.cc 2017-05-04 13:17:59 UTC (rev 11412)
@@ -65,8 +65,8 @@
// setPosition(Vector2(0.1, 0.65));
if (this->type_ == "Coins") {
// this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!");
-
-
+
+
std::stringstream ss;
ss << "cc x " << std::setw(2) << std::setfill('0') << SOBGame->getCoins();
std::string s = ss.str();
@@ -73,82 +73,42 @@
this->setCaption(s);
- }
- if (this->type_ == "Points") {
+ }
+ if (this->type_ == "Points") {
std::stringstream ss;
ss << std::setw(6) << std::setfill('0') << SOBGame->getPoints();
std::string s = ss.str();
this->setCaption(s);
- }
- if (this->type_ == "Time") {
+ }
+ if (this->type_ == "Time") {
std::stringstream ss;
ss << SOBGame->getTimeLeft();
std::string s = ss.str();
this->setCaption(s);
- }
-
+ }
+ if (this->type_ == "Info") {
+ std::stringstream ss;
+ ss << SOBGame->getInfoText();
+ std::string s = ss.str();
+ this->setCaption(s);
+ }
+
-
- // const std::string& Level = multi_cast<std::string>(this->SOBGame->getLevel());
- // if (this->SOBGame->lives <= 0)
- // {
- // setPosition(Vector2(0.1, 0.65));
- // this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!");
- // setTextSize(0.05);
- // this->SOBGame->bEndGame = true;
- // }
- // else if (this->SOBGame->bShowLevel)
- // {
- // setTextSize(0.1);
- // setPosition(Vector2(0.3, 0.55));
- // std::stringstream sstm;
- // sstm << "Level " << Level;
- // this->setCaption(sstm.str()); // + level
- // }
- // else
- // {
- // setTextSize(0.04);
- // setPosition(Vector2(0.14, 0.055));
- // this->setCaption(Level);
- // }
- // ////////////
- // const std::string& points = multi_cast<std::string>(this->SOBGame->getPoints());
- // if (this->SOBGame->lives <= 0)
- // {
- // setTextSize(0.2);
- // setPosition(Vector2(0.1, 0.25));
- // this->setCaption("Final score:\n" + points);
- // this->setColour(ColourValue(1, 0, 0, 1));
- // }
- // else
- // {
- // setTextSize(0.04);
- // setPosition(Vector2(0.14, 0.1));
- // this->setColour(ColourValue(1, 1, 1, 1));
- // this->setCaption(points);
- // }
-
- // /////////////
- // int mult = this->SOBGame->getMultiplier();
- // const std::string& Multiplier = "X " + multi_cast<std::string>(mult);
- // this->setCaption(Multiplier);
- // this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f)));
- // this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f);
-
- }
+
}
+}
- void SOBHUDInfo::changedOwner()
+void SOBHUDInfo::changedOwner()
+{
+ SUPER(SOBHUDInfo, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
{
- SUPER(SOBHUDInfo, changedOwner);
-
- if (this->getOwner() && this->getOwner()->getGametype())
- {
- this->SOBGame = orxonox_cast<SOB*>(this->getOwner()->getGametype());
- }
- else
- {
- this->SOBGame = nullptr;
- }
+ this->SOBGame = orxonox_cast<SOB*>(this->getOwner()->getGametype());
}
+ else
+ {
+ this->SOBGame = nullptr;
+ }
}
+}
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.cc 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.cc 2017-05-04 13:17:59 UTC (rev 11412)
@@ -54,6 +54,11 @@
gravityAcceleration_ = 350.0;
speed_ = 0.0;
hasCollided_=false;
+ goesRight_ = true;
+ lastPos_ = getPosition();
+ lastPos_.x -= 20;
+ changeAllowed_ = true;
+ changedOn_ = 0.0;
}
@@ -70,7 +75,13 @@
bool SOBMushroom::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
-//orxout() << "Watshc bum baem" << endl;
+
+if (changeAllowed_ && otherObject->getMass() != -1) {
+ goesRight_ = !goesRight_;
+ changeAllowed_ = false;
+}
+
+orxout() << "Watshc bum baem" << otherObject->getMass()<< endl;
return true;
}
@@ -89,13 +100,29 @@
{
SUPER(SOBMushroom, tick, dt);
- Vector3 velocity = getVelocity();
+ if (!changeAllowed_) {
+ changedOn_+= dt;
+ if (changedOn_> 200) {
+ changeAllowed_ = true;
+ changedOn_ = 0.0;
+
+ }
+ }
+
+
+ int dir = 1;
+ if (!goesRight_)
+ dir = -1;
+
+ Vector3 velocity = getVelocity();
velocity.z -= gravityAcceleration_*dt;
- velocity.x = speed_;
+ velocity.x = dir*speed_;
setVelocity(velocity);
+ lastPos_ = getPosition();
+ }
+
}
-}
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.h 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.h 2017-05-04 13:17:59 UTC (rev 11412)
@@ -64,6 +64,10 @@
float gravityAcceleration_;
float speed_;
WeakPtr<SOBFigure> figure_;
+ bool goesRight_;
+ Vector3 lastPos_;
+ bool changeAllowed_;
+ float changedOn_;
};
}
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBPrereqs.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBPrereqs.h 2017-05-04 09:26:52 UTC (rev 11411)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBPrereqs.h 2017-05-04 13:17:59 UTC (rev 11412)
@@ -80,6 +80,8 @@
class SOBQBlock;
class SOBMushroom;
class SOBHUDInfo;
+ class SOBGumba;
+ class SOBFlagstone;
/*
class PongScore;*/
}
More information about the Orxonox-commit
mailing list