[Orxonox-commit 6742] r11370 - in code/branches/SuperOrxoBros_FS17: data/levels src/modules src/modules/superorxobros
jkindle at orxonox.net
jkindle at orxonox.net
Thu Mar 16 16:02:16 CET 2017
Author: jkindle
Date: 2017-03-16 16:02:15 +0100 (Thu, 16 Mar 2017)
New Revision: 11370
Added:
code/branches/SuperOrxoBros_FS17/data/levels/SuperOrxoBros.oxw
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.h
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
Modified:
code/branches/SuperOrxoBros_FS17/src/modules/CMakeLists.txt
Log:
Damn shit
Added: code/branches/SuperOrxoBros_FS17/data/levels/SuperOrxoBros.oxw
===================================================================
--- code/branches/SuperOrxoBros_FS17/data/levels/SuperOrxoBros.oxw (rev 0)
+++ code/branches/SuperOrxoBros_FS17/data/levels/SuperOrxoBros.oxw 2017-03-16 15:02:15 UTC (rev 11370)
@@ -0,0 +1,55 @@
+<LevelInfo
+ name = "Super Orxo Bros."
+ description = "Retro Mario game.\nNothing more to say."
+ tags = "minigame"
+ screenshot = "orxonoxArcade.png"
+/>
+<?lua
+ include("stats.oxo")
+ include("templates/lodInformation.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipAssff2.oxt")
+ include("templates/spaceshipPirate.oxt")
+ include("templates/spaceshipInvader.oxt")
+ include("templates/enemyInvader.oxt")
+ include("overlays/InvaderHUD.oxo")
+?>
+
+<Level
+ plugins = superorxobros
+ gametype = Deathmatch
+>
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
+
+ <!-- ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox" -->
+ <Scene
+ ambientlight = "0.8, 0.7, 0.4"
+ skybox = "Orxonox/skyBoxBasic"
+ >
+
+ <WorldAmbientSound
+ source="Earth.ogg"
+ looping="true"
+ playOnLoad="true"
+ />
+
+ <!-- <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=Orxo pawndesign=spaceshippirate />
+
+ <DistanceTrigger name="start" position="-200,0,0" target="Pawn" distance=10 stayActive="true" delay=0 />
+
+
+
+
+
+
+ </Scene>
+</Level>
+
Modified: code/branches/SuperOrxoBros_FS17/src/modules/CMakeLists.txt
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/CMakeLists.txt 2017-03-16 13:33:55 UTC (rev 11369)
+++ code/branches/SuperOrxoBros_FS17/src/modules/CMakeLists.txt 2017-03-16 15:02:15 UTC (rev 11370)
@@ -43,3 +43,4 @@
ADD_SUBDIRECTORY(mini4dgame)
ADD_SUBDIRECTORY(dodgerace)
ADD_SUBDIRECTORY(hover)
+ADD_SUBDIRECTORY(superorxobros)
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt 2017-03-16 15:02:15 UTC (rev 11370)
@@ -0,0 +1,15 @@
+SET_SOURCE_FILES(Superorxobros_SRC_FILES
+ Orxo.cc
+
+
+)
+
+ORXONOX_ADD_LIBRARY(superorxobros
+ PLUGIN
+ FIND_HEADER_FILES
+ LINK_LIBRARIES
+ orxonox
+ overlays
+ weapons
+ SOURCE_FILES ${Superorxobros_SRC_FILES}
+)
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.cc (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.cc 2017-03-16 15:02:15 UTC (rev 11370)
@@ -0,0 +1,196 @@
+/*
+ * 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 InvaderShip.cc
+ @brief Implementation of the InvaderShip class.
+*/
+
+#include "Orxo.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+//#include "Invader.h"
+//#include "InvaderEnemy.h"
+#include "graphics/Camera.h"
+//#include "weapons/projectiles/Projectile.h"
+
+namespace orxonox
+{
+ RegisterClass(Orxo);
+
+ Orxo::Orxo(Context* context) : SpaceShip(context)
+ {
+ RegisterObject(Orxo);
+
+ speed = 500;
+ damping = 10;
+ }
+
+ void Orxo::tick(float dt)
+ {
+ /*Vector3 pos = getPosition();
+
+ //Movement calculation
+ lastTimeFront += dt * damping;
+ lastTimeLeft += dt * damping;
+ lastTime += dt;
+
+ velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
+ velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
+
+ //Execute movement
+ if (this->hasLocalController())
+ {
+ float dist_y = velocity.y * dt;
+ float dist_x = velocity.x * dt;
+ if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
+ posforeward += dist_y;
+ else
+ {
+ velocity.y = 0;
+ // restart if game ended
+ if (getGame())
+ if (getGame()->bEndGame)
+ {
+ getGame()->start();
+ return;
+ }
+ }
+ if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3)
+ velocity.x = 0;
+ pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
+ }
+
+
+ // Camera
+ Camera* camera = this->getCamera();
+ if (camera != nullptr)
+ {
+ camera->setPosition(Vector3(-pos.z, -posforeward, 0));
+ camera->setOrientation(Vector3::UNIT_Z, Degree(90));
+ }
+
+
+
+ // bring back on track!
+ if(pos.y != 0)
+ pos.y = 0;
+
+ setPosition(pos);
+ setOrientation(Vector3::UNIT_Y, Degree(270));
+
+ // Level up!
+ if (pos.x > 42000)
+ {
+ updateLevel();
+ setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)
+ }*/
+
+ SUPER(Orxo, tick, dt);
+ }
+
+ void Orxo::updateLevel()
+ {
+ lastTime = 0;
+ /*if (getGame())
+ getGame()->levelUp();*/
+ }
+
+ void Orxo::moveFrontBack(const Vector2& value)
+ {
+ Pawn::moveFrontBack(value);
+ lastTimeLeft = 0;
+ desiredVelocity.x = -value.x * speed;
+ }
+
+ void Orxo::moveRightLeft(const Vector2& value)
+ {
+ lastTimeFront = 0;
+ desiredVelocity.y = value.y * speed * 42;
+ }
+ void Orxo::boost(bool bBoost)
+ {
+ // isFireing = bBoost;
+ }
+ void Orxo::rotateRoll(const Vector2& value)
+ {/*
+ if (getGame())
+ if (getGame()->bEndGame)
+ getGame()->end();
+ */}
+ inline bool Orxo::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+ {
+ /*// orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
+ InvaderEnemy* enemy = orxonox_cast<InvaderEnemy*>(otherObject);
+ Projectile* shot = orxonox_cast<Projectile*>(otherObject);
+ // ensure that this gets only called once per enemy.
+ if (enemy != nullptr && lastEnemy != enemy)
+ {
+ lastEnemy = enemy;
+
+ removeHealth(20);
+ if (getGame())
+ {
+ getGame()->multiplier = 1;
+ }
+ }
+ // was shot, decrease multiplier
+ else if (shot != nullptr && lastShot != shot)
+ {
+ if (getGame() && orxonox_cast<InvaderEnemy*>(shot->getShooter()) != nullptr)
+ {
+ if (getGame()->multiplier > 1)
+ {
+ lastShot = shot;
+ getGame()->multiplier -= 1;
+ }
+ }
+ }
+ return false;
+ // SUPER(InvaderShip, collidesAgainst, otherObject, contactPoint);
+ */
+ return false;
+ }
+
+ /*SOB* Orxo::getGame()
+ {
+ if (game == nullptr)
+ {
+ for (SOB* sob : ObjectList<SOB>())
+ game = sob;
+ }
+ return game;
+ }*/
+
+ void Orxo::death()
+ {
+ //getGame()->costLife();
+ Pawn::death();
+ }
+}
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.h (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.h 2017-03-16 15:02:15 UTC (rev 11370)
@@ -0,0 +1,88 @@
+/*
+ * 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 InvaderShip.h
+ @brief Declaration of the InvaderShip class.
+*/
+
+#ifndef _Orxo_H__
+#define _Orxo_H__
+
+//#include "invader/InvaderPrereqs.h"
+
+//#include "weapons/WeaponsPrereqs.h"
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ class Orxo : public SpaceShip
+ {
+ public:
+ Orxo(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();
+
+ virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+
+ protected:
+ virtual void death() override;
+ private:
+ //SOB* getGame();
+ //WeakPtr<SOB> game;
+ Camera* camera;
+ float speed, damping, posforeward;
+ float lastTimeFront, lastTimeLeft, lastTime;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity, desiredVelocity;
+
+ // WeakPtr<InvaderEnemy> lastEnemy;
+ //WeakPtr<Projectile> lastShot;
+
+ };
+}
+
+#endif /* _InvaderShip_H__ */
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc 2017-03-16 15:02:15 UTC (rev 11370)
@@ -0,0 +1,199 @@
+/*
+ * 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 Invader.cc
+ @brief Implementation of the Invader class.
+*/
+
+#include "Invader.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 "InvaderCenterPoint.h"
+#include "InvaderShip.h"
+#include "InvaderEnemy.h"
+#include "InvaderEnemyShooter.h"
+
+#include "core/command/ConsoleCommand.h"
+#include "worldentities/ExplosionPart.h"
+
+namespace orxonox
+{
+ RegisterUnloadableClass(Invader);
+
+ Invader::Invader(Context* context) : Deathmatch(context)
+ {
+ RegisterObject(Invader);
+ 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;
+ // spawn enemy every 3.5 seconds
+ enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
+ comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
+ this->setHUDTemplate("InvaderHUD");
+ }
+
+ void Invader::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(&Invader::toggleShowLevel, this)));
+ }
+
+ InvaderShip* Invader::getPlayer()
+ {
+ if (player == nullptr)
+ {
+ for (InvaderShip* ship : ObjectList<InvaderShip>())
+ player = ship;
+ }
+ return player;
+ }
+
+ void Invader::spawnEnemy()
+ {
+ if (getPlayer() == nullptr)
+ return;
+
+ for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
+ {
+ InvaderEnemy* newPawn;
+ if (rand() % 42/(1 + level*level) == 0)
+ {
+ newPawn = new InvaderEnemyShooter(this->center_->getContext());
+ newPawn->addTemplate("enemyinvadershooter");
+ }
+ else
+ {
+ newPawn = new InvaderEnemy(this->center_->getContext());
+ newPawn->addTemplate("enemyinvader");
+ }
+ newPawn->setInvaderPlayer(player);
+ newPawn->level = level;
+ // spawn enemy at random points in front of player.
+ newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
+ }
+ }
+
+ void Invader::setCenterpoint(InvaderCenterPoint* center)
+ {
+ this->center_ = center;
+ }
+
+ void Invader::costLife()
+ {
+ lives--;
+ multiplier = 1;
+ // end the game in 30 seconds.
+ if (lives <= 0)
+ enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this)));
+ };
+
+ void Invader::comboControll()
+ {
+ if (b_combo)
+ multiplier++;
+ // if no combo was performed before, reset multiplier
+ else
+ multiplier = 1;
+ b_combo = false;
+ }
+
+ void Invader::start()
+ {
+ // Set variable to temporarily force the player to spawn.
+ this->bForceSpawn_ = true;
+
+ if (this->center_ == nullptr) // abandon mission!
+ {
+ orxout(internal_error) << "Invader: No Centerpoint specified." << endl;
+ GSLevel::startMainMenu();
+ return;
+ }
+ // Call start for the parent class.
+ Deathmatch::start();
+ }
+ void Invader::addPoints(int numPoints)
+ {
+ if (!bEndGame)
+ {
+ point += numPoints * multiplier;
+ b_combo = true;
+ }
+ }
+
+ void Invader::end()
+ {
+ // DON'T CALL THIS!
+ // 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();
+ }
+}
Added: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h (rev 0)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h 2017-03-16 15:02:15 UTC (rev 11370)
@@ -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 Invader.h
+ @brief Gametype.
+ @ingroup Invader
+*/
+
+#ifndef _Invader_H__
+#define _Invader_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "gametypes/Deathmatch.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+ class _InvaderExport Invader : public Deathmatch
+ {
+ public:
+ Invader(Context* context);
+
+ 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(InvaderCenterPoint* 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;}
+ InvaderShip* getPlayer();
+ WeakPtr<InvaderCenterPoint> center_;
+ WeakPtr<InvaderShip> player;
+
+ Timer enemySpawnTimer;
+ Timer comboTimer;
+ Timer showLevelTimer;
+ //Context* context;
+ int level;
+ int point;
+ bool b_combo;
+ };
+}
+
+#endif /* _Invader_H__ */
More information about the Orxonox-commit
mailing list