[Orxonox-commit 7222] r11836 - in code/branches/OrxyRoad_FS18: data/levels/templates data/overlays src/modules src/modules/orxyroad
jacobsr at orxonox.net
jacobsr at orxonox.net
Thu Mar 29 15:13:14 CEST 2018
Author: jacobsr
Date: 2018-03-29 15:13:14 +0200 (Thu, 29 Mar 2018)
New Revision: 11836
Added:
code/branches/OrxyRoad_FS18/data/levels/templates/OrxyRoadPattern.oxt
code/branches/OrxyRoad_FS18/data/levels/templates/spaceshipOrxyRoad.oxt
code/branches/OrxyRoad_FS18/data/overlays/OrxyRoadHUD.oxo
code/branches/OrxyRoad_FS18/src/modules/orxyroad/
code/branches/OrxyRoad_FS18/src/modules/orxyroad/CMakeLists.txt
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCenterPoint.cc
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCenterPoint.h
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCube.cc
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCube.h
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadHUDinfo.cc
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadHUDinfo.h
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadPrereqs.h
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRace.h
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRaceShip.cc
code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRaceShip.h
Log:
orxyroad v21
Added: code/branches/OrxyRoad_FS18/data/levels/templates/OrxyRoadPattern.oxt
===================================================================
--- code/branches/OrxyRoad_FS18/data/levels/templates/OrxyRoadPattern.oxt (rev 0)
+++ code/branches/OrxyRoad_FS18/data/levels/templates/OrxyRoadPattern.oxt 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,61 @@
+<Template name=DodgeRaceCube01>
+
+ <DodgeRaceCube position="0,0,0" direction="0,0,0" scale="1" collisionType=dynamic mass=1 friction=0.01 >
+ <attached>
+ <Model position="700,0,50" mesh="CuboidBody.mesh" scale3D="300,50,50" />
+ <Model position="700,0,1150" mesh="CuboidBody.mesh" scale3D="300,50,50" />
+ <Model position="1200,0,200" mesh="CuboidBody.mesh" scale3D="100,50,100" />
+ <Model position="1200,0,1000" mesh="CuboidBody.mesh" scale3D="100,50,100" />
+ <Model position="1250,-10,430" mesh="CuboidBody.mesh" scale3D="50,40,30" />
+ <Model position="1250,-10,600" mesh="CuboidBody.mesh" scale3D="50,40,30" />
+ <Model position="1250,-10,770" mesh="CuboidBody.mesh" scale3D="50,40,30" />
+ <Model position="1650,0,350" mesh="CuboidBody.mesh" scale3D="50,50,150" />
+ <Model position="1650,0,850" mesh="CuboidBody.mesh" scale3D="50,50,150" />
+ <Model position="2100,0,150" mesh="CuboidBody.mesh" scale3D="100,50,150" />
+ <Model position="2100,0,1050" mesh="CuboidBody.mesh" scale3D="100,50,150" />
+ <Model position="2150,0,600" mesh="CuboidBody.mesh" scale3D="50,50,100" />
+ </attached>
+
+ <collisionShapes>
+ <BoxCollisionShape position="700,0,50" halfExtents="300,50,50" />
+ <BoxCollisionShape position="700,0,1150" halfExtents="300,50,50" />
+ <BoxCollisionShape position="1200,0,200" halfExtents="100,50,100" />
+ <BoxCollisionShape position="1200,0,1000" halfExtents="100,50,100" />
+ <BoxCollisionShape position="1250,-10,430" halfExtents="50,40,30" />
+ <BoxCollisionShape position="1250,-10,600" halfExtents="50,40,30" />
+ <BoxCollisionShape position="1250,-10,770" halfExtents="50,40,30" />
+ <BoxCollisionShape position="1650,0,350" halfExtents="50,50,150" />
+ <BoxCollisionShape position="1650,0,850" halfExtents="50,50,150" />
+ <BoxCollisionShape position="2100,0,150" halfExtents="100,50,150" />
+ <BoxCollisionShape position="2100,0,1050" halfExtents="100,50,150" />
+ <BoxCollisionShape position="2150,0,600" halfExtents="50,50,100" />
+ </collisionShapes>
+ </DodgeRaceCube>
+
+</Template>
+
+<Template name=DodgeRaceCube02>
+
+ <DodgeRaceCube position="0,0,0" direction="0,0,0" scale="1" collisionType=dynamic mass=1 friction=0.01 >
+ <attached>
+ <Model position="450,0,300" mesh="CuboidBody.mesh" scale3D="50,50,300" />
+ <Model position="950,0,850" mesh="CuboidBody.mesh" scale3D="50,50,350" />
+ <Model position="1350,0,200" mesh="CuboidBody.mesh" scale3D="50,50,200" />
+ <Model position="1350,0,700" mesh="CuboidBody.mesh" scale3D="50,50,100" />
+ <Model position="1750,0,350" mesh="CuboidBody.mesh" scale3D="50,50,350" />
+ <Model position="2000,0,1000" mesh="CuboidBody.mesh" scale3D="100,50,100" />
+ <Model position="1650,0,1150" mesh="CuboidBody.mesh" scale3D="450,50,50" />
+ </attached>
+
+ <collisionShapes>
+ <BoxCollisionShape position="450,0,300" halfExtents="50,50,300" />
+ <BoxCollisionShape position="950,0,850" halfExtents="50,50,350" />
+ <BoxCollisionShape position="1350,0,200" halfExtents="50,50,200" />
+ <BoxCollisionShape position="1350,0,700" halfExtents="50,50,100" />
+ <BoxCollisionShape position="1750,0,350" halfExtents="50,50,350" />
+ <BoxCollisionShape position="2000,0,1000" halfExtents="100,50,100" />
+ <BoxCollisionShape position="1650,0,1150" halfExtents="450,50,50" />
+ </collisionShapes>
+ </DodgeRaceCube>
+
+</Template>
\ No newline at end of file
Added: code/branches/OrxyRoad_FS18/data/levels/templates/spaceshipOrxyRoad.oxt
===================================================================
--- code/branches/OrxyRoad_FS18/data/levels/templates/spaceshipOrxyRoad.oxt (rev 0)
+++ code/branches/OrxyRoad_FS18/data/levels/templates/spaceshipOrxyRoad.oxt 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,128 @@
+<Template name=spaceshipdodgerace>
+ <DodgeRaceShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipescortcameras
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 4
+
+ health = 40
+ maxhealth = 40
+ initialhealth = 40
+
+ shieldhealth = 20
+ initialshieldhealth = 20
+ maxshieldhealth = 20
+ shieldabsorption = 0.1
+ shieldrechargerate = 1
+ shieldrechargewaittime = 1
+
+ primaryThrust = 150
+ auxilaryThrust = 30
+ rotationThrust = 50
+
+ lift = 1;
+ stallSpeed = 220;
+
+ boostPower = 20
+ boostPowerRate = 1
+ boostRate = 5
+ boostCooldownDuration = 10
+
+ shakeFrequency = 15
+ shakeAmplitude = 6
+
+ collisionType = "dynamic"
+ mass = 4200000
+ linearDamping = 0.9999999
+ angularDamping = 0.9999999
+
+ collisiondamage = 100
+ enablecollisiondamage = true
+
+ >
+ <engines>
+ <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipinvaderengine />
+ <MultiStateEngine position="-7.6, 0, 0" template=spaceshipinvaderengine />
+ </engines>
+ <attached>
+ <Model position="0,0,0" yaw=90 pitch=0 roll=0 scale=4 mesh="escortShip.mesh" />
+ <Model position="0,0,0" yaw=180 pitch=90 roll=0 scale=4 mesh="escortWeapon.mesh" />
+<!--Model mesh="cube.mesh" mass=10 position="0,0,3" scale3D="10,4,8" />
+<Model mesh="cube.mesh" mass=10 position="12.6,-2,3" scale3D="2.8,2.8,11" />
+<Model mesh="cube.mesh" mass=10 position="-12.6,-2,3" scale3D="2.8,2.8,11" />
+<Model mesh="cube.mesh" mass=10 position="0,0,-12" scale3D="4,4,7" /-->
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0 ,0 , 3" halfExtents="10, 4,8" />
+ <BoxCollisionShape position="12.6 ,-2, 3" halfExtents="2.8,2.8,11"/>
+ <BoxCollisionShape position="-12.6,-2, 3" halfExtents="2.8,2.8,11"/>
+ <BoxCollisionShape position="0, 0,-12" halfExtents="4 , 4 ,7" />
+ </collisionShapes>
+ <explosion >
+ <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_flash2" effect2="orxonox/explosion_flame2" />
+ <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_shockwave2" effect2="orxonox/explosion_sparks2" />
+ <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_streak2" effect2="orxonox/explosion_afterglow" />
+
+ <ExplosionPart minspeed=0 maxspeed=0 effect1="Orxonox/explosion2b" effect2="Orxonox/smoke6" />
+ <ExplosionPart mesh="CockpitDebris.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+ <ExplosionPart mesh="BodyDebris1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+ <ExplosionPart mesh="WingDebris1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+ <ExplosionPart mesh="WingDebris2.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+ </explosion>
+<?lua
+ include("../includes/invaderWeapon.oxi")
+?>
+ </DodgeRaceShip>
+</Template>
+
+<Template name=spaceshipescortcameras defaults=0>
+ <DodgeRaceShip>
+ <camerapositions>
+ <CameraPosition position="0,100,180" direction="0, -0.2, -1" drag=false mouselook=true />
+ <CameraPosition position="0,200,250" direction="0, -0.4, -1" drag=false mouselook=true />
+ <CameraPosition position="0,30,150" direction="0, 0, -1" drag=false mouselook=true />
+ <CameraPosition position="0,1300,-100" direction="0, -1, 0" drag=false mouselook=true />
+ </camerapositions>
+ </DodgeRaceShip>
+</Template>
+
+<Template name=spaceshipinvaderengine baseclass=MultiStateEngine>
+ <MultiStateEngine
+ boostfactor = 2.2
+
+ speedfront = 200
+ speedback = 70
+ speedleftright = 70
+ speedupdown = 70
+
+ defEngineSndNormal = "sounds/Engine_low.ogg"
+ defEngineSndBoost = "sounds/Engine_high.ogg"
+
+ accelerationfront = 700
+ accelerationbrake = 700
+ accelerationback = 125
+ accelerationleftright = 125
+ accelerationupdown = 125
+ >
+ <EffectContainer condition="idle">
+ <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+ <FadingBillboard mainstate=activity active=false scale=0.09 position="12, -2, 13" colour="0.2, 1.0, 0.65, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.09 position="-12, -2, 13" colour="0.2, 1.0, 0.65, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
+ <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, 0, 10" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, 0, 10" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ </EffectContainer>
+ <EffectContainer condition="boost">
+ <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, 0, 10" colour="0.6, 0.8, 0.75, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, 0, 10" colour="0.6, 0.8, 0.75, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ </EffectContainer>
+
+ </MultiStateEngine>
+</Template>
\ No newline at end of file
Added: code/branches/OrxyRoad_FS18/data/overlays/OrxyRoadHUD.oxo
===================================================================
--- code/branches/OrxyRoad_FS18/data/overlays/OrxyRoadHUD.oxo (rev 0)
+++ code/branches/OrxyRoad_FS18/data/overlays/OrxyRoadHUD.oxo 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,38 @@
+<Template name="spectatorhud">
+ <OverlayGroup name = "spectatorhud" scale = "1, 1">
+ </OverlayGroup>
+</Template>
+
+<Template name="DodgeRaceHUD">
+ <OverlayGroup name="DodgeRaceHUD" scale = "1, 1">
+
+ <OverlayText
+ position = "0.02, 0.02"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "Points: "
+ />
+
+ <DodgeRaceHUDinfo
+ position = "0.14, 0.02"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+
+ showpoints = true
+ />
+
+
+ </OverlayGroup>
+</Template>
+
+<Template name="spaceshiphud">
+ <OverlayGroup name = "spaceshiphud" scale = "1, 1">
+
+ </OverlayGroup>
+</Template>
\ No newline at end of file
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/CMakeLists.txt
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/CMakeLists.txt (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/CMakeLists.txt 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,16 @@
+SET_SOURCE_FILES(Dodgerace_SRC_FILES
+OrxyRoad.cc
+OrxyRoadCenterPoint.cc
+OrxyRoadShip.cc
+OrxyRoadCube.cc
+OrxyRoadHUDinfo.cc
+)
+
+ORXONOX_ADD_LIBRARY(orxyRoad
+ PLUGIN
+ FIND_HEADER_FILES
+ LINK_LIBRARIES
+ orxonox
+ overlays
+ SOURCE_FILES ${OrxyRoad_SRC_FILES}
+)
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoad.cc 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,234 @@
+/*
+ * 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 DodgeRace.cc
+ @brief Implementation of the DodgeRace class.
+*/
+
+#include "DodgeRace.h"
+#include "DodgeRaceShip.h" // Necessary for getPlayer function. Do NOT include this in Header!
+#include "DodgeRaceCube.h"
+#include "core/CoreIncludes.h"
+#include "Highscore.h"
+#include "infos/PlayerInfo.h"
+
+namespace orxonox
+{
+ RegisterUnloadableClass(DodgeRace);
+
+ DodgeRace::DodgeRace(Context* context) : Deathmatch(context)
+ {
+ RegisterObject(DodgeRace);
+
+ bEndGame = false;
+ lives = 1;
+ level = 1;
+ point = 0;
+ bShowLevel = false;
+ multiplier = 1;
+ b_combo = false;
+ counter = 5000;
+ pattern = 1;
+ lastPosition = 0;
+ // spawn enemy every 3.5 seconds
+ //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&DodgeRace::spawnEnemy, this)));
+ comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&DodgeRace::comboControll, this)));
+ this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
+ this->center_ = nullptr;
+
+ this->setHUDTemplate("DodgeRaceHUD");
+ }
+
+ void DodgeRace::levelUp()
+ {
+ level++;
+ if (getPlayer() != nullptr)
+ {
+ for (int i = 0; i < 7; i++)
+ {
+ WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
+ chunk5->setPosition(Vector3(600, 0, 100.f * i - 300));
+ chunk5->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity()
+ chunk5->setScale(10);
+ chunk5->setEffect1("Orxonox/explosion2b");
+ chunk5->setEffect2("Orxonox/smoke6");
+ chunk5->Explode();
+
+ }
+ }
+ addPoints(multiplier * 42);
+ multiplier *= 2;
+ toggleShowLevel();
+ showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&DodgeRace::toggleShowLevel, this)));
+ }
+
+ void DodgeRace::tick(float dt)
+ {
+ DodgeRaceShip* player = this->getPlayer();
+ if (player != nullptr)
+ {
+ currentPosition = player->getWorldPosition().x;
+ counter = counter + (currentPosition - lastPosition);
+ lastPosition = currentPosition;
+ point = (int) currentPosition;
+ player->speed = 830.0f - (point / 1000);
+
+ for(unsigned int i=0; i < cubeList.size();i++)
+ {
+ if(cubeList.at(i)->getPosition().x < currentPosition-3000)
+ {
+ cubeList.at(i)->destroy();
+ cubeList.erase(cubeList.begin()+i);
+ }
+ }
+
+ if(counter >= 3000)
+ {
+ counter = 0;
+ for(int i = 0; i<6; i++)
+ {
+ DodgeRaceCube* cube = new DodgeRaceCube(this->center_->getContext());
+ cubeList.push_back(cube);
+ switch(pattern)
+ {
+ case 1: cube->addTemplate("DodgeRaceCube01");
+ break;
+ case 2: cube->addTemplate("DodgeRaceCube02");
+ break;
+
+ }
+
+ cube->setPosition(player->getWorldPosition() + Vector3(5000.0f, 0.0f, -3600.0f + (i*1200)));
+ //stEntity->setScale3D(50,50,50);
+ }
+
+
+ pattern %= 2;
+ pattern ++;
+
+ }
+
+ }
+ SUPER(DodgeRace, tick, dt);
+ }
+
+ DodgeRaceShip* DodgeRace::getPlayer()
+ {
+ for (DodgeRaceShip* ship : ObjectList<DodgeRaceShip>())
+ {
+ return ship;
+ }
+ return nullptr;
+ }
+
+ void DodgeRace::costLife()
+ {
+ //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&DodgeRace::end, this)));
+ lives = 0;
+ };
+
+ void DodgeRace::comboControll()
+ {
+ if (b_combo)
+ multiplier++;
+ // if no combo was performed before, reset multiplier
+ else
+ multiplier = 1;
+ b_combo = false;
+ }
+
+ void DodgeRace::start()
+ {
+ orxout() << "start" << endl;
+ for(unsigned int i=0; i< cubeList.size();i++)
+ {
+ cubeList.at(i)->destroy();
+ cubeList.erase(cubeList.begin()+i);
+
+ }
+ cubeList.clear();
+ // Set variable to temporarily force the player to spawn.
+ this->bForceSpawn_ = false;
+
+ if (this->center_ == nullptr) // abandon mission!
+ {
+ orxout(internal_error) << "DodgeRace: No Centerpoint specified." << endl;
+ GSLevel::startMainMenu();
+ return;
+ }
+ // Call start for the parent class.
+ Deathmatch::start();
+ }
+
+ void DodgeRace::playerPreSpawn(PlayerInfo* player)
+ {
+ this->playerInfo_ = player;
+ if(lives <= 0)
+ {
+ this->end();
+ }
+
+ // Reset all the cubes
+ /*
+ orxout() << "prespawn" << endl;
+ for(int i=0; i< cubeList.size();i++)
+ {
+ cubeList.at(i)->destroy();
+ cubeList.erase(cubeList.begin()+i);
+ }
+ cubeList.clear();
+ lives = 1;
+ point = 0;
+ lastPosition = 0;
+ */
+ }
+
+ void DodgeRace::addPoints(int numPoints)
+ {
+ if (!bEndGame)
+ {
+ point += numPoints * multiplier;
+ b_combo = true;
+ }
+ }
+
+ void DodgeRace::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();
+ Highscore::getInstance().storeScore("Dodge Race", score, this->playerInfo_);
+ }
+ GSLevel::startMainMenu();
+ }
+}
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCenterPoint.cc
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCenterPoint.cc (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCenterPoint.cc 2018-03-29 13:13:14 UTC (rev 11836)
@@ -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 DodgeRaceCenterPoint.cc
+ @brief Implementation of the DodgeRaceCenterPoint class.
+*/
+
+#include "DodgeRaceCenterPoint.h"
+
+#include "core/CoreIncludes.h"
+
+#include "DodgeRace.h"
+
+namespace orxonox
+{
+ RegisterClass(DodgeRaceCenterPoint);
+
+ DodgeRaceCenterPoint::DodgeRaceCenterPoint(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(DodgeRaceCenterPoint);
+
+ this->checkGametype();
+ }
+
+ void DodgeRaceCenterPoint::checkGametype()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(DodgeRace)))
+ {
+ DodgeRace* DodgeRaceGametype = orxonox_cast<DodgeRace*>(this->getGametype());
+ DodgeRaceGametype->setCenterpoint(this);
+ }
+ }
+}
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCenterPoint.h
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCenterPoint.h (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCenterPoint.h 2018-03-29 13:13:14 UTC (rev 11836)
@@ -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 DodgeRaceCenterPoint.h
+ @brief Declaration of the DodgeRaceCenterPoint class.
+ @ingroup DodgeRace
+*/
+
+#ifndef _DodgeRaceCenterPoint_H__
+#define _DodgeRaceCenterPoint_H__
+
+#include "dodgerace/DodgeRacePrereqs.h"
+
+//#include "DodgeRace.h"
+//#include "DodgeRaceHUDinfo.h"
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+ class _DodgeRaceExport DodgeRaceCenterPoint : public StaticEntity
+ {
+ public:
+ DodgeRaceCenterPoint(Context* context); //checks whether the gametype is actually DodgeRace.
+
+ private:
+ void checkGametype();
+
+ };
+}
+
+#endif /* _DodgeRaceCenterPoint_H__ */
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCube.cc
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCube.cc (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCube.cc 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,47 @@
+/* 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:
+ * Samuel Riedel
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DodgeRace.cc
+ @brief Implementation of the DodgeRace class.
+*/
+
+#include "DodgeRaceCube.h"
+#include "DodgeRace.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(DodgeRaceCube);
+
+ DodgeRaceCube::DodgeRaceCube(Context* context) : MovableEntity(context)
+ {
+ RegisterObject(DodgeRaceCube);
+ }
+
+
+}
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCube.h
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCube.h (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadCube.h 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,54 @@
+/*
+ * 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:
+ * Samuel Riedel
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DodgeRace.h
+ @brief Gametype.
+ @ingroup DodgeRace
+*/
+
+#ifndef _DodgeRaceCube_H__
+#define _DodgeRaceCube_H__
+
+#include "dodgerace/DodgeRacePrereqs.h"
+
+#include "worldentities/MovableEntity.h"
+
+
+namespace orxonox
+{
+ class _DodgeRaceExport DodgeRaceCube : public MovableEntity
+ {
+ public:
+ DodgeRaceCube(Context* context);
+
+ private:
+ };
+}
+
+#endif /* _DodgeRaceCube_H__ */
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadHUDinfo.cc
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadHUDinfo.cc (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadHUDinfo.cc 2018-03-29 13:13:14 UTC (rev 11836)
@@ -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
+ *
+ */
+
+#include "DodgeRaceHUDinfo.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+//#include "DodgeRace.h"
+
+namespace orxonox
+{
+ RegisterClass(DodgeRaceHUDinfo);
+
+ DodgeRaceHUDinfo::DodgeRaceHUDinfo(Context* context) : OverlayText(context)
+ {
+ RegisterObject(DodgeRaceHUDinfo);
+
+ this->DodgeRaceGame = nullptr;
+ this->bShowPoints_ = true;
+ }
+
+ void DodgeRaceHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(DodgeRaceHUDinfo, XMLPort, xmlelement, mode);
+
+ XMLPortParam(DodgeRaceHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
+ }
+
+ void DodgeRaceHUDinfo::tick(float dt)
+ {
+ SUPER(DodgeRaceHUDinfo, tick, dt);
+
+
+ if(this->bShowPoints_)
+ {
+ const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints());
+ if (this->DodgeRaceGame->lives <= 0)
+ {
+ setTextSize(0.2);
+ setPosition(Vector2(0.1, 0.02));
+ this->setCaption("Final score:\n" + points);
+ this->setColour(ColourValue(1, 0, 0, 1));
+ }
+ else
+ {
+ setTextSize(0.04);
+ setPosition(Vector2(0.14, 0.02));
+ this->setColour(ColourValue(1, 1, 1, 1));
+ this->setCaption(points);
+ }
+ }
+ }
+
+ void DodgeRaceHUDinfo::changedOwner()
+ {
+ SUPER(DodgeRaceHUDinfo, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ {
+ this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype());
+ }
+ else
+ {
+ this->DodgeRaceGame = nullptr;
+ }
+ }
+}
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadHUDinfo.h
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadHUDinfo.h (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadHUDinfo.h 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,61 @@
+/*
+ * 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 _DodgeRaceHUDinfo_H__
+#define _DodgeRaceHUDinfo_H__
+
+//#include "DodgeRaceShip.h"
+#include "DodgeRace.h"
+//#include "DodgeRaceCenterPoint.h"
+
+#include "dodgerace/DodgeRacePrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class _DodgeRaceExport DodgeRaceHUDinfo : public OverlayText, public Tickable
+ {
+ public:
+ DodgeRaceHUDinfo(Context* context);
+
+ virtual void tick(float dt) override;
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void changedOwner() override;
+
+ inline void setShowPoints(bool value)
+ { this->bShowPoints_ = value; }
+ inline bool getShowPoints() const
+ { return this->bShowPoints_; }
+
+
+ private:
+ DodgeRace* DodgeRaceGame;
+ bool bShowPoints_;
+ };
+}
+#endif /* _DodgeRaceHUDinfo_H__ */
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadPrereqs.h
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadPrereqs.h (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadPrereqs.h 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,81 @@
+/*
+ * 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 DodgeRace module
+*/
+
+#ifndef _DodgeRacePrereqs_H__
+#define _DodgeRacePrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(DODGERACE_STATIC_BUILD)
+# ifdef DODGERACE_SHARED_BUILD
+# define _DodgeRaceExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _DodgeRaceExport
+# else
+# define _DodgeRaceExport __declspec(dllimport)
+# endif
+# endif
+# define _DodgeRacePrivate
+#elif defined (ORXONOX_GCC_VISIBILITY)
+# define _DodgeRaceExport __attribute__ ((visibility("default")))
+# define _DodgeRacePrivate __attribute__ ((visibility("hidden")))
+#else
+# define _DodgeRaceExport
+# define _DodgeRacePrivate
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class DodgeRace;
+ class DodgeRaceCenterPoint;
+ class DodgeRaceShip;
+ class DodgeRaceCube;
+ //class DodgeRaceEnemy;
+ //class DodgeRaceEnemyShooter;
+ //class DodgeRaceWeapon;
+ //class DodgeRaceWeaponEnemy;
+ //class DodgeRaceHUDinfo;
+}
+
+#endif /* _DodgeRacePrereqs_H__*/
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRace.h
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRace.h (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRace.h 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,145 @@
+/*
+ * 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 DodgeRace.h
+ @brief Gametype.
+ @ingroup DodgeRace
+*/
+
+#ifndef _DodgeRace_H__
+#define _DodgeRace_H__
+
+#include "dodgerace/DodgeRacePrereqs.h"
+
+#include "DodgeRaceCenterPoint.h" // Necessary for WeakPointer??
+//#include "DodgeRaceShip.h" DO NOT include in Header. Will cause forward declaration issues
+
+//#include "DodgeRaceHUDinfo.h"
+
+
+#include "core/EventIncludes.h"
+#include "core/command/Executor.h"
+#include "core/config/ConfigValueIncludes.h"
+
+#include "gamestates/GSLevel.h"
+#include "chat/ChatManager.h"
+#include <vector>
+
+// ! HACK
+#include "infos/PlayerInfo.h"
+
+#include "core/command/ConsoleCommand.h"
+
+#include "gametypes/Deathmatch.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+
+ class _DodgeRaceExport DodgeRace : public Deathmatch
+ {
+ public:
+ DodgeRace(Context* context);
+
+ virtual void start() override;
+ virtual void end() override;
+
+ virtual void tick(float dt) override;
+
+ virtual void playerPreSpawn(PlayerInfo* player) override;
+
+ void levelUp();
+
+ int getLives(){return this->lives;}
+ int getLevel(){return this->level;}
+ int getPoints(){return this->point;}
+ int getMultiplier(){return this->multiplier;}
+
+ void setCenterpoint(DodgeRaceCenterPoint* center)
+ { this->center_ = center; }
+ virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
+
+ // checks if multiplier should be reset.
+ void comboControll();
+ void costLife();
+
+ bool bEndGame;
+ bool bShowLevel;
+ int lives;
+ int multiplier;
+ float counter;
+ int pattern;
+ float currentPosition;
+ float lastPosition;
+
+ private:
+ Timer endGameTimer;
+
+ DodgeRaceShip* getPlayer();
+ WeakPtr<PlayerInfo> playerInfo_;
+ std::vector<DodgeRaceCube*> cubeList;
+ void toggleShowLevel(){bShowLevel = !bShowLevel;}
+ void addPoints(int numPoints);
+
+ WeakPtr<DodgeRaceCenterPoint> center_;
+ int level;
+ int point;
+ bool b_combo;
+
+ Timer enemySpawnTimer;
+ Timer comboTimer;
+ Timer showLevelTimer;
+
+
+ /*
+
+ //void spawnEnemy();
+
+
+
+
+
+
+
+
+
+
+
+
+ private:
+
+
+
+
+ //Context* context;
+ */
+ };
+}
+
+#endif /* _DodgeRace_H__ */
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRaceShip.cc
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRaceShip.cc (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRaceShip.cc 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,169 @@
+/*
+ * 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 DodgeRaceShip.cc
+ @brief Implementation of the DodgeRaceShip class.
+*/
+
+#include "DodgeRaceShip.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(DodgeRaceShip);
+
+ DodgeRaceShip::DodgeRaceShip(Context* context) : SpaceShip(context)
+ {
+ RegisterObject(DodgeRaceShip);
+
+ speed = 830;
+ isFireing = false;
+ damping = 10;
+
+ // not sure if has to be zero?
+ lastTimeFront = 0;
+ lastTimeLeft = 0;
+ lastTime = 0;
+ }
+
+ void DodgeRaceShip::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;
+ }*/
+ }
+
+ 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(0));
+ }
+
+
+
+ // 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(DodgeRaceShip, tick, dt);
+ }
+
+ void DodgeRaceShip::updateLevel()
+ {
+ lastTime = 0;
+ if (getGame())
+ getGame()->levelUp();
+ }
+
+ void DodgeRaceShip::moveFrontBack(const Vector2& value)
+ {
+ //lastTimeFront = 0;
+ //desiredVelocity.y = value.y * speed * 42;
+
+ }
+
+ void DodgeRaceShip::moveRightLeft(const Vector2& value)
+ {
+ lastTimeLeft = 0;
+ desiredVelocity.x = value.x * speed;
+ }
+ void DodgeRaceShip::boost(bool bBoost)
+ {
+ //getGame()->bEndGame = bBoost;
+ }
+
+ inline bool DodgeRaceShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+ {
+
+ removeHealth(100);
+ this->death();
+ return false;
+ }
+
+ DodgeRace* DodgeRaceShip::getGame()
+ {
+ if (game == nullptr)
+ {
+ for (DodgeRace* race : ObjectList<DodgeRace>())
+ {
+ game = race;
+ }
+ }
+ return game;
+ }
+
+ void DodgeRaceShip::death()
+ {
+ getGame()->costLife();
+ SpaceShip::death();
+ }
+}
Added: code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRaceShip.h
===================================================================
--- code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRaceShip.h (rev 0)
+++ code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadRaceShip.h 2018-03-29 13:13:14 UTC (rev 11836)
@@ -0,0 +1,95 @@
+/*
+ * 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 DodgeRaceShip.h
+ @brief Declaration of the DodgeRaceShip class.
+*/
+
+#ifndef _DodgeRaceShip_H__
+#define _DodgeRaceShip_H__
+
+
+#include "dodgerace/DodgeRacePrereqs.h"
+
+#include "core/XMLPort.h"
+#include "worldentities/pawns/SpaceShip.h"
+#include "graphics/Camera.h"
+
+#include "DodgeRace.h" // Is necessary for getGame function
+//#include "DodgeRaceCenterPoint.h"
+
+namespace orxonox
+{
+ class _DodgeRaceExport DodgeRaceShip : public SpaceShip
+ {
+ public:
+ DodgeRaceShip(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{if (getGame()) if (getGame()->bEndGame) getGame()->end();};
+
+ virtual void updateLevel();
+
+ virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
+
+ float speed, damping, posforeward;
+ bool isFireing;
+
+ protected:
+ virtual void death() override;
+
+ private:
+ DodgeRace* getGame();
+ WeakPtr<DodgeRace> game;
+ WeakPtr<WorldEntity> lastEntity;
+ Camera* camera;
+ float lastTimeFront, lastTimeLeft, lastTime;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity, desiredVelocity;
+
+ };
+}
+
+#endif /* _DodgeRaceShip_H__ */
More information about the Orxonox-commit
mailing list