[Orxonox-commit 6882] r11503 - in code/branches/FlappyOrx_HS17: data/levels src/modules src/modules/flappyorx
pascscha at orxonox.net
pascscha at orxonox.net
Mon Oct 23 15:19:08 CEST 2017
Author: pascscha
Date: 2017-10-23 15:19:08 +0200 (Mon, 23 Oct 2017)
New Revision: 11503
Added:
code/branches/FlappyOrx_HS17/src/modules/flappyorx/CMakeLists.txt
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxCenterPoint.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxCenterPoint.h
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.h
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxPrereqs.h
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeapon.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeapon.h
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeaponEnemy.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeaponEnemy.h
Modified:
code/branches/FlappyOrx_HS17/data/levels/FlappyOrx.oxw
code/branches/FlappyOrx_HS17/data/levels/Invaders.oxw
code/branches/FlappyOrx_HS17/src/modules/CMakeLists.txt
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
Log:
MoveUpDown
Modified: code/branches/FlappyOrx_HS17/data/levels/FlappyOrx.oxw
===================================================================
--- code/branches/FlappyOrx_HS17/data/levels/FlappyOrx.oxw 2017-10-23 13:14:56 UTC (rev 11502)
+++ code/branches/FlappyOrx_HS17/data/levels/FlappyOrx.oxw 2017-10-23 13:19:08 UTC (rev 11503)
@@ -6,25 +6,49 @@
/>
<?lua
- include("overlays/FlappyHUD.oxo")
+ include("stats.oxo")
+ include("templates/lodInformation.oxt")
?>
+<?lua
+ include("templates/spaceshipAssff2.oxt")
+ include("templates/spaceshipPirate.oxt")
+ include("templates/spaceshipFlappyOrx.oxt")
+ include("templates/enemyFlappyOrx.oxt")
+ include("overlays/FlappyOrxHUD.oxo")
+?>
+
<Level
+ plugins = flappyorx
+ gametype = FlappyOrx
>
- <Scene
- ambientlight = "0.8, 0.7, 0.4"
- skybox = "Orxonox/skyBoxBasic"
- >
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
- <WorldAmbientSound
- source="Earth.ogg"
- looping="true"
- playOnLoad="true"
- />
+ <!-- ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox" -->
+ <Scene
+ ambientlight = "0.8, 0.7, 0.4"
+ skybox = "Orxonox/skyBoxBasic"
+ >
- <Light type=directional position="1100, 11000, -7000" lookat="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
- <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0"/>
+ <WorldAmbientSound
+ source="Earth.ogg"
+ looping="true"
+ playOnLoad="true"
+ />
-
- </Scene>
-</Level>
\ No newline at end of file
+ <!-- <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> -->
+ <Light type=directional position="1100, 11000, -7000" lookat="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+ <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=FlappyOrxShip pawndesign=spaceshipFlappyOrx />
+
+
+ <FlappyOrxCenterPoint name=flappyorxcenter />
+
+
+
+ </Scene>
+</Level>
+
Modified: code/branches/FlappyOrx_HS17/data/levels/Invaders.oxw
===================================================================
--- code/branches/FlappyOrx_HS17/data/levels/Invaders.oxw 2017-10-23 13:14:56 UTC (rev 11502)
+++ code/branches/FlappyOrx_HS17/data/levels/Invaders.oxw 2017-10-23 13:19:08 UTC (rev 11503)
@@ -4,6 +4,7 @@
tags = "minigame"
screenshot = "orxonoxArcade.png"
/>
+
<?lua
include("stats.oxo")
include("templates/lodInformation.oxt")
Modified: code/branches/FlappyOrx_HS17/src/modules/CMakeLists.txt
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/CMakeLists.txt 2017-10-23 13:14:56 UTC (rev 11502)
+++ code/branches/FlappyOrx_HS17/src/modules/CMakeLists.txt 2017-10-23 13:19:08 UTC (rev 11503)
@@ -45,3 +45,4 @@
ADD_SUBDIRECTORY(dodgerace)
ADD_SUBDIRECTORY(hover)
ADD_SUBDIRECTORY(superorxobros)
+ADD_SUBDIRECTORY(flappyorx)
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/CMakeLists.txt
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/CMakeLists.txt (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/CMakeLists.txt 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,20 @@
+SET_SOURCE_FILES(FlappyOrx_SRC_FILES
+BUILD_UNIT FlappyOrxBuildUnit.cc
+ FlappyOrx.cc
+ FlappyOrxCenterPoint.cc
+ FlappyOrxShip.cc
+ FlappyOrxWeapon.cc
+ FlappyOrxWeaponEnemy.cc
+ FlappyOrxHUDinfo.cc
+END_BUILD_UNIT
+)
+
+ORXONOX_ADD_LIBRARY(flappyorx
+ PLUGIN
+ FIND_HEADER_FILES
+ LINK_LIBRARIES
+ orxonox
+ overlays
+ weapons
+ SOURCE_FILES ${FlappyOrx_SRC_FILES}
+)
Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc 2017-10-23 13:14:56 UTC (rev 11502)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc 2017-10-23 13:19:08 UTC (rev 11503)
@@ -28,9 +28,28 @@
/**
@file FlappyOrx.cc
+ @brief Implementation of the FlappyOrx class.
*/
+#include "FlappyOrx.h"
+#include "Highscore.h"
+#include "core/CoreIncludes.h"
+#include "core/EventIncludes.h"
+#include "core/command/Executor.h"
+#include "core/config/ConfigValueIncludes.h"
+#include "gamestates/GSLevel.h"
+#include "chat/ChatManager.h"
+
+// ! HACK
+#include "infos/PlayerInfo.h"
+
+#include "FlappyOrxCenterPoint.h"
+#include "FlappyOrxShip.h"
+
+#include "core/command/ConsoleCommand.h"
+#include "worldentities/ExplosionPart.h"
+
namespace orxonox
{
RegisterUnloadableClass(FlappyOrx);
@@ -38,13 +57,102 @@
FlappyOrx::FlappyOrx(Context* context) : Deathmatch(context)
{
RegisterObject(FlappyOrx);
- this->setHUDTemplate("FlappyHUD");
+ this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
+ this->center_ = nullptr;
+ bEndGame = false;
+ lives = 3;
+ level = 1;
+ point = 0;
+ bShowLevel = false;
+ multiplier = 1;
+ b_combo = false;
+
+ this->setHUDTemplate("FlappyOrxHUD");
}
+ void FlappyOrx::levelUp()
+ {
+ level++;
+ if (getPlayer() != nullptr)
+ {
+ for (int i = 0; i < 7; i++)
+ {
+
+ WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
+ chunk5->setPosition(this->center_->getPosition());
+ chunk5->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity()
+ chunk5->setScale(10);
+ chunk5->setEffect1("Orxonox/explosion2b");
+ chunk5->setEffect2("Orxonox/smoke6");
+ chunk5->setMinSpeed(0);
+ chunk5->setMaxSpeed(0);
+ chunk5->Explode();
+
+ }
+ }
+ addPoints(multiplier * 42);
+ multiplier *= 2;
+ toggleShowLevel();
+ showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&FlappyOrx::toggleShowLevel, this)));
+ }
+
+ FlappyOrxShip* FlappyOrx::getPlayer()
+ {
+ if (player == nullptr)
+ {
+ for (FlappyOrxShip* ship : ObjectList<FlappyOrxShip>())
+ player = ship;
+ }
+ return player;
+ }
+
+
+ void FlappyOrx::setCenterpoint(FlappyOrxCenterPoint* center)
+ {
+ this->center_ = center;
+ }
+
+ void FlappyOrx::costLife()
+ {
+ lives--;
+ multiplier = 1;
+ // end the game in 30 seconds.
+ if (lives <= 0)
+ enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&FlappyOrx::end, this)));
+ };
+
+ void FlappyOrx::comboControll()
+ {
+ if (b_combo)
+ multiplier++;
+ // if no combo was performed before, reset multiplier
+ else
+ multiplier = 1;
+ b_combo = false;
+ }
+
void FlappyOrx::start()
{
+ // Set variable to temporarily force the player to spawn.
+ this->bForceSpawn_ = true;
+
+ if (this->center_ == nullptr) // abandon mission!
+ {
+ orxout(internal_error) << "FlappyOrx: No Centerpoint specified." << endl;
+ GSLevel::startMainMenu();
+ return;
+ }
+ // Call start for the parent class.
Deathmatch::start();
}
+ void FlappyOrx::addPoints(int numPoints)
+ {
+ if (!bEndGame)
+ {
+ point += numPoints * multiplier;
+ b_combo = true;
+ }
+ }
void FlappyOrx::end()
{
@@ -52,6 +160,12 @@
// Deathmatch::end();
// It will misteriously crash the game!
// Instead startMainMenu, this won't crash.
+ if (Highscore::exists()){
+ int score = this->getPoints();
+ if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
+ Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
+
+ }
GSLevel::startMainMenu();
}
}
Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h 2017-10-23 13:14:56 UTC (rev 11502)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h 2017-10-23 13:19:08 UTC (rev 11503)
@@ -35,7 +35,10 @@
#ifndef _FlappyOrx_H__
#define _FlappyOrx_H__
+#include "flappyorx/FlappyOrxPrereqs.h"
+
#include "gametypes/Deathmatch.h"
+#include "tools/Timer.h"
namespace orxonox
{
@@ -47,9 +50,39 @@
virtual void start() override;
virtual void end() override;
-
+ virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
+
+ void spawnEnemy();
+
+ void setCenterpoint(FlappyOrxCenterPoint* center);
+
+ int getLives(){return this->lives;}
+ int getLevel(){return this->level;}
+ int getPoints(){return this->point;}
+ int getMultiplier(){return this->multiplier;}
+
+ void costLife();
+ void levelUp();
+ void addPoints(int numPoints);
+ // checks if multiplier should be reset.
+ void comboControll();
+ int lives;
+ int multiplier;
+ bool bEndGame;
+ bool bShowLevel;
private:
void toggleShowLevel(){bShowLevel = !bShowLevel;}
+ FlappyOrxShip* getPlayer();
+ WeakPtr<FlappyOrxCenterPoint> center_;
+ WeakPtr<FlappyOrxShip> player;
+
+ Timer enemySpawnTimer;
+ Timer comboTimer;
+ Timer showLevelTimer;
+ //Context* context;
+ int level;
+ int point;
+ bool b_combo;
};
}
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxCenterPoint.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxCenterPoint.cc (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxCenterPoint.cc 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,59 @@
+/*
+ * 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 FlappyOrxCenterPoint.cc
+ @brief Implementation of the FlappyOrxCenterPoint class.
+*/
+
+#include "FlappyOrxCenterPoint.h"
+
+#include "core/CoreIncludes.h"
+
+#include "FlappyOrx.h"
+
+namespace orxonox
+{
+ RegisterClass(FlappyOrxCenterPoint);
+
+ FlappyOrxCenterPoint::FlappyOrxCenterPoint(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(FlappyOrxCenterPoint);
+
+ this->checkGametype();
+ }
+
+ void FlappyOrxCenterPoint::checkGametype()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(FlappyOrx)))
+ {
+ FlappyOrx* FlappyOrxGametype = orxonox_cast<FlappyOrx*>(this->getGametype());
+ FlappyOrxGametype->setCenterpoint(this);
+ }
+ }
+}
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxCenterPoint.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxCenterPoint.h (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxCenterPoint.h 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,55 @@
+/*
+ * 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 FlappyOrxCenterPoint.h
+ @brief Declaration of the FlappyOrxCenterPoint class.
+ @ingroup FlappyOrx
+*/
+
+#ifndef _FlappyOrxCenterPoint_H__
+#define _FlappyOrxCenterPoint_H__
+
+#include "flappyorx/FlappyOrxPrereqs.h"
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+ class _FlappyOrxExport FlappyOrxCenterPoint : public StaticEntity
+ {
+ public:
+ FlappyOrxCenterPoint(Context* context); //checks whether the gametype is actually FlappyOrx.
+
+ private:
+ void checkGametype();
+
+ };
+}
+
+#endif /* _FlappyOrxCenterPoint_H__ */
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.cc (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.cc 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,137 @@
+/*
+ * 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
+ *
+ */
+
+#include "FlappyOrxHUDinfo.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+#include "FlappyOrx.h"
+
+namespace orxonox
+{
+ RegisterClass(FlappyOrxHUDinfo);
+
+ FlappyOrxHUDinfo::FlappyOrxHUDinfo(Context* context) : OverlayText(context)
+ {
+ RegisterObject(FlappyOrxHUDinfo);
+
+ this->FlappyOrxGame = nullptr;
+ this->bShowLives_ = false;
+ this->bShowLevel_ = false;
+ this->bShowPoints_ = false;
+ this->bShowMultiplier_ = false;
+ }
+
+ void FlappyOrxHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(FlappyOrxHUDinfo, XMLPort, xmlelement, mode);
+
+ XMLPortParam(FlappyOrxHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false);
+ XMLPortParam(FlappyOrxHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
+ XMLPortParam(FlappyOrxHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false);
+ XMLPortParam(FlappyOrxHUDinfo, "showMultiplier", setShowMultiplier, getShowMultiplier, xmlelement, mode).defaultValues(false);
+ }
+
+ void FlappyOrxHUDinfo::tick(float dt)
+ {
+ SUPER(FlappyOrxHUDinfo, tick, dt);
+
+ if (this->FlappyOrxGame)
+ {
+ if (this->bShowLives_)
+ {
+ const std::string& lives = multi_cast<std::string>(this->FlappyOrxGame->getLives());
+ this->setCaption(lives);
+ }
+ else if(this->bShowLevel_)
+ {
+ const std::string& Level = multi_cast<std::string>(this->FlappyOrxGame->getLevel());
+ if (this->FlappyOrxGame->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->FlappyOrxGame->bEndGame = true;
+ }
+ else if (this->FlappyOrxGame->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);
+ }
+ }
+ else if(this->bShowPoints_)
+ {
+ const std::string& points = multi_cast<std::string>(this->FlappyOrxGame->getPoints());
+ if (this->FlappyOrxGame->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);
+ }
+ }
+ else if(this->bShowMultiplier_)
+ {
+ int mult = this->FlappyOrxGame->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 FlappyOrxHUDinfo::changedOwner()
+ {
+ SUPER(FlappyOrxHUDinfo, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ {
+ this->FlappyOrxGame = orxonox_cast<FlappyOrx*>(this->getOwner()->getGametype());
+ }
+ else
+ {
+ this->FlappyOrxGame = nullptr;
+ }
+ }
+}
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.h (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxHUDinfo.h 2017-10-23 13:19:08 UTC (rev 11503)
@@ -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:
+ * Florian Zinggeler
+ *
+ */
+
+#ifndef _FlappyOrxHUDinfo_H__
+#define _FlappyOrxHUDinfo_H__
+
+#include "flappyorx/FlappyOrxPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class _FlappyOrxExport FlappyOrxHUDinfo : public OverlayText, public Tickable
+ {
+ public:
+ FlappyOrxHUDinfo(Context* context);
+
+ virtual void tick(float dt) override;
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void changedOwner() override;
+
+ inline void setShowLives(bool value)
+ { this->bShowLives_ = value; }
+ inline bool getShowLives() const
+ { return this->bShowLives_; }
+
+ inline void setShowLevel(bool value)
+ { this->bShowLevel_ = value; }
+ inline bool getShowLevel() const
+ { return this->bShowLevel_; }
+
+ inline void setShowPoints(bool value)
+ { this->bShowPoints_ = value; }
+ inline bool getShowPoints() const
+ { return this->bShowPoints_; }
+
+ inline void setShowMultiplier(bool value)
+ { this->bShowMultiplier_ = value; }
+ inline bool getShowMultiplier() const
+ { return this->bShowMultiplier_; }
+
+
+ private:
+ FlappyOrx* FlappyOrxGame;
+ bool bShowLives_;
+ bool bShowLevel_;
+ bool bShowPoints_;
+ bool bShowMultiplier_;
+ };
+}
+#endif /* _FlappyOrxHUDinfo_H__ */
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxPrereqs.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxPrereqs.h (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxPrereqs.h 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,80 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Shared library macros, enums, constants and forward declarations for the FlappyOrx module
+*/
+
+#ifndef _FlappyOrxPrereqs_H__
+#define _FlappyOrxPrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(FlappyOrx_STATIC_BUILD)
+# ifdef FlappyOrx_SHARED_BUILD
+# define _FlappyOrxExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _FlappyOrxExport
+# else
+# define _FlappyOrxExport __declspec(dllimport)
+# endif
+# endif
+# define _FlappyOrxPrivate
+#elif defined (ORXONOX_GCC_VISIBILITY)
+# define _FlappyOrxExport __attribute__ ((visibility("default")))
+# define _FlappyOrxPrivate __attribute__ ((visibility("hidden")))
+#else
+# define _FlappyOrxExport
+# define _FlappyOrxPrivate
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class FlappyOrx;
+ class FlappyOrxCenterPoint;
+ class FlappyOrxShip;
+ class FlappyOrxEnemy;
+ class FlappyOrxEnemyShooter;
+ class FlappyOrxWeapon;
+ class FlappyOrxWeaponEnemy;
+ class FlappyOrxHUDinfo;
+}
+
+#endif /* _FlappyOrxPrereqs_H__ */
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,139 @@
+/*
+ * 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 FlappyOrxShip.cc
+ @brief Implementation of the FlappyOrxShip class.
+*/
+
+#include "FlappyOrxShip.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "FlappyOrx.h"
+#include "graphics/Camera.h"
+#include "weapons/projectiles/Projectile.h"
+
+namespace orxonox
+{
+ RegisterClass(FlappyOrxShip);
+
+ FlappyOrxShip::FlappyOrxShip(Context* context) : SpaceShip(context)
+ {
+ RegisterObject(FlappyOrxShip);
+
+ UpwardThrust = 250;
+ speed = 50;
+ gravity = 20;
+ }
+
+ void FlappyOrxShip::tick(float dt)
+ { //Execute movement
+ if (this->hasLocalController())
+ {
+
+ Vector3 pos = getPosition();
+ velocity.y += gravity;
+ if(isFlapping){
+ isFlapping = false;
+ velocity.y = -UpwardThrust;
+ }
+
+
+ pos += Vector3(speed + velocity.x, 0, velocity.y) * dt;
+
+ if(pos.z < -150 || pos.z > 150){
+ pos.z=0;
+ velocity.y = 0;
+ }
+
+ // restart if game ended
+ if (getGame())
+ if (getGame()->bEndGame)
+ {
+ getGame()->start();
+ return;
+ }
+
+ // Camera
+ Camera* camera = this->getCamera();
+ if (camera != nullptr)
+ {
+ camera->setPosition(Vector3(-pos.z, -pos.y, 0));
+ camera->setOrientation(Vector3::UNIT_Z, Degree(90));
+ }
+
+
+
+ setPosition(pos);
+ setOrientation(Vector3::UNIT_Y, Degree(270));
+
+ }
+
+ SUPER(FlappyOrxShip, tick, dt);
+ }
+
+ void FlappyOrxShip::updateLevel()
+ {
+ if (getGame())
+ getGame()->levelUp();
+ }
+
+ void FlappyOrxShip::moveFrontBack(const Vector2& value)
+ {
+
+ }
+
+ void FlappyOrxShip::moveRightLeft(const Vector2& value){}
+
+ void FlappyOrxShip::boost(bool boost){
+ isFlapping=boost;
+ }
+
+ void FlappyOrxShip::rotateRoll(const Vector2& value)
+ {
+ if (getGame())
+ if (getGame()->bEndGame)
+ getGame()->end();
+ }
+
+ FlappyOrx* FlappyOrxShip::getGame()
+ {
+ if (game == nullptr)
+ {
+ for (FlappyOrx* flappyOrx : ObjectList<FlappyOrx>())
+ game = flappyOrx;
+ }
+ return game;
+ }
+
+ void FlappyOrxShip::death()
+ {
+
+ }
+}
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,83 @@
+/*
+ * 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 FlappyOrxShip.h
+ @brief Declaration of the FlappyOrxShip class.
+*/
+
+#ifndef _FlappyOrxShip_H__
+#define _FlappyOrxShip_H__
+
+#include "flappyorx/FlappyOrxPrereqs.h"
+
+#include "weapons/WeaponsPrereqs.h"
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ class _FlappyOrxExport FlappyOrxShip : public SpaceShip
+ {
+ public:
+ FlappyOrxShip(Context* context);
+
+ virtual void tick(float dt) override;
+
+ // overwrite for 2d movement
+ virtual void moveFrontBack(const Vector2& value) override;
+ virtual void moveRightLeft(const Vector2& value) override;
+
+ // Starts or stops fireing
+ virtual void boost(bool bBoost) override;
+
+ //no rotation!
+ virtual void rotateYaw(const Vector2& value) override{};
+ virtual void rotatePitch(const Vector2& value) override{};
+ //return to main menu if game has ended.
+ virtual void rotateRoll(const Vector2& value) override;
+
+ virtual void updateLevel();
+
+ protected:
+ virtual void death() override;
+ private:
+ FlappyOrx* getGame();
+ WeakPtr<FlappyOrx> game;
+ Camera* camera;
+ bool isFlapping;
+ float speed, UpwardThrust, gravity;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity;
+
+ };
+}
+
+#endif /* _FlappyOrxShip_H__ */
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeapon.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeapon.cc (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeapon.cc 2017-10-23 13:19:08 UTC (rev 11503)
@@ -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 FlappyOrxWeapon.h
+ @brief Implementation of the FlappyOrxWeapon class.
+*/
+
+#include "FlappyOrxWeapon.h"
+
+#include "core/CoreIncludes.h"
+// #include "core/XMLPort.h"
+// #include "core/command/Executor.h"
+
+#include "graphics/Model.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/Projectile.h"
+#include "weapons/MuzzleFlash.h"
+
+namespace orxonox
+{
+ RegisterClass(FlappyOrxWeapon);
+
+ FlappyOrxWeapon::FlappyOrxWeapon(Context* context) : HsW01(context)
+ {
+ RegisterObject(FlappyOrxWeapon);
+ }
+
+ FlappyOrxWeapon::~FlappyOrxWeapon()
+ {
+
+ }
+
+ void FlappyOrxWeapon::shot()
+ {
+ assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+
+ // Create the projectile.projectile
+ projectile = new Projectile(this->getContext());
+ Model* model = new Model(projectile->getContext());
+ model->setMeshSource(mesh_);
+ model->setCastShadows(false);
+ projectile->attach(model);
+ model->setScale(5);
+
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ // only shoot in foreward direction
+ projectile->setOrientation(Quaternion(sqrt(0.5f),0,sqrt(0.5f),0));
+ projectile->setPosition(this->getMuzzlePosition());
+ // only shoot in foreward direction
+ projectile->setVelocity(Vector3(1, 0, 0) * 2000);
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+
+ // Display the muzzle flash.
+ this->FlappyOrxWeapon::muzzleflash();
+ }
+}
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeapon.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeapon.h (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeapon.h 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,55 @@
+/*
+ * 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 FlappyOrxWeapon.h
+ @brief Definition of the FlappyOrxWeapon class.
+*/
+
+#ifndef _FlappyOrxWeapon_H__
+#define _FlappyOrxWeapon_H__
+
+#include "flappyorx/FlappyOrxPrereqs.h"
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weapons/weaponmodes/HsW01.h"
+
+namespace orxonox
+{
+ class _FlappyOrxExport FlappyOrxWeapon : public HsW01
+ {
+ public:
+ FlappyOrxWeapon(Context* context);
+ virtual ~FlappyOrxWeapon();
+ protected:
+ virtual void shot() override;
+ WeakPtr<Projectile> projectile;
+ };
+}
+
+#endif /* _FlappyOrxWeapon_H__ */
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeaponEnemy.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeaponEnemy.cc (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeaponEnemy.cc 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,58 @@
+/*
+ * 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 FlappyOrxWeaponEnemy.h
+ @brief Implementation of the FlappyOrxWeaponEnemy class.
+*/
+
+#include "FlappyOrxWeaponEnemy.h"
+
+#include "core/CoreIncludes.h"
+#include "weapons/projectiles/Projectile.h"
+
+namespace orxonox
+{
+ RegisterClass(FlappyOrxWeaponEnemy);
+
+ FlappyOrxWeaponEnemy::FlappyOrxWeaponEnemy(Context* context) : FlappyOrxWeapon(context)
+ {
+ RegisterObject(FlappyOrxWeaponEnemy);
+ }
+
+ void FlappyOrxWeaponEnemy::shot()
+ {
+ FlappyOrxWeapon::shot();
+ // SUPER(FlappyOrxWeaponEnemy, shot);
+ // only shoot in foreward direction
+ projectile->setVelocity(Vector3(1, 0, 0) * 300);
+ // projectile->setOrientation(Quaternion(sqrt(0.5),0,sqrt(0.5),0));
+ }
+}
+
+
Added: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeaponEnemy.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeaponEnemy.h (rev 0)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxWeaponEnemy.h 2017-10-23 13:19:08 UTC (rev 11503)
@@ -0,0 +1,53 @@
+/*
+ * 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 FlappyOrxWeaponEnemy.h
+ @brief Definition of the FlappyOrxWeaponEnemy class.
+*/
+
+#ifndef _FlappyOrxWeaponEnemy_H__
+#define _FlappyOrxWeaponEnemy_H__
+
+#include "flappyorx/FlappyOrxPrereqs.h"
+
+#include "FlappyOrxWeapon.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _FlappyOrxExport FlappyOrxWeaponEnemy : public FlappyOrxWeapon
+ {
+ public:
+ FlappyOrxWeaponEnemy(Context* context);
+ protected:
+ virtual void shot() override;
+ };
+}
+
+#endif /* _FlappyOrxWeaponEnemy_H__ */
More information about the Orxonox-commit
mailing list