[Orxonox-commit 7548] r12151 - in code/branches/WorldMap_HS18: data/gui/layouts data/levels src/orxonox/controllers
linggj at orxonox.net
linggj at orxonox.net
Wed Dec 5 11:54:24 CET 2018
Author: linggj
Date: 2018-12-05 11:54:24 +0100 (Wed, 05 Dec 2018)
New Revision: 12151
Modified:
code/branches/WorldMap_HS18/data/gui/layouts/CampaignMenu.layout
code/branches/WorldMap_HS18/data/levels/StoryModeMap.oxw
code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.cc
code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.h
code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc
code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.h
Log:
it works
Modified: code/branches/WorldMap_HS18/data/gui/layouts/CampaignMenu.layout
===================================================================
--- code/branches/WorldMap_HS18/data/gui/layouts/CampaignMenu.layout 2018-12-05 10:54:14 UTC (rev 12150)
+++ code/branches/WorldMap_HS18/data/gui/layouts/CampaignMenu.layout 2018-12-05 10:54:24 UTC (rev 12151)
@@ -8,27 +8,8 @@
<Property name="BackgroundEnabled" value="False" />
- <Window name="RightButton" type="MenuWidgets/Button">
- <Property name="Text" value="F" />
- <Property name="MaxSize" value="{{1,0},{1,0}}" />
- <Property name="Area" value="{{0.350,0},{0.9,0},{0.45,0},{0.95,0}}" />
-
- </Window>
+
- <Window name="LeftButton" type="MenuWidgets/Button">
- <Property name="Text" value="B" />
- <Property name="MaxSize" value="{{1,0},{1,0}}" />
- <Property name="Area" value="{{0.55,0},{0.9,0},{0.65,0},{0.95,0}}" />
-
- </Window>
-
- <Window name="SelectButton" type="MenuWidgets/Button">
- <Property name="Text" value="Play" />
- <Property name="MaxSize" value="{{1,0},{1,0}}" />
- <Property name="Area" value="{{0.45,0},{0.9,0},{0.55,0},{0.95,0}}" />
-
- </Window>
-
<Window name="Mission1Text" type="MenuWidgets/Button">
<Property name="Text" value="Mission One" />
<Property name="Visible" value="False" />
Modified: code/branches/WorldMap_HS18/data/levels/StoryModeMap.oxw
===================================================================
--- code/branches/WorldMap_HS18/data/levels/StoryModeMap.oxw 2018-12-05 10:54:14 UTC (rev 12150)
+++ code/branches/WorldMap_HS18/data/levels/StoryModeMap.oxw 2018-12-05 10:54:24 UTC (rev 12151)
@@ -15,7 +15,7 @@
?>
<Level
-gametype = Deathmatch
+gametype = StoryMode
>
<templates>
@@ -30,24 +30,7 @@
ambientlight = "0.2, 0.2, 0.2"
skybox = "Orxonox/Starbox"
>
- <StoryModeController position="0,0,0" collisionType="dynamic" mass=42000000 >
-
- <attached>
- <Model position="0,0,0" mesh="assff.mesh" scale=20 visible="true" />
- </attached>
- <CameraPosition position="0,0,1000" direction="0, -1, 0" drag=false />
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="3,1,10" />
- </collisionShapes>
- </StoryModeController>
- <!-- <MovableEntity>
- <attached>
- <StaticEntity name=asdfasdf figureTemplate=smCont>
- <attached>
- </attached>
- </StaticEntity>
- </attached>
- </MovableEntity> -->
+
@@ -58,7 +41,7 @@
<Model name="a" position="550,300,0" mesh="planets/moon.mesh" scale=100 visible="true" />
<Billboard colour="1,0,0.05" position="550,300,-80" material="Flares/lensflare" scale=4.5 />
- <Model name="a" position="600,370,0" mesh="planets/moon.mesh" scale=100 visible="false" />
+ <Model name="a" position="600,370,0" mesh="planets/moon.mesh" scale=100 visible="true" />
<Model position="550,300,0" mesh="assff.mesh" scale=20 visible="false" orientation="-0.015,0.091,0.038,-0.995"/>
@@ -67,10 +50,10 @@
<Model position="100,350,-250" mesh="planets/moon.mesh" scale=100 visible="true"/>
- <Model position="50,300,-250" mesh="assff.mesh" scale=20 visible="false" orientation="-0.015,0.091,0.038,-0.995"/>
+
<Billboard colour="1,1,0.05" position="100,350,-330" material="Flares/lensflare" scale=4.5 />
- <Model position="-600,250,-500" mesh="planets/moon.mesh" scale=100 visible="false"/>
+ <Model position="-600,250,-500" mesh="planets/moon.mesh" scale=100 visible="true"/>
<Billboard colour="1,1,0.05" position="-600,250,-580" material="Flares/lensflare" scale=5 />
<Model position="-1000,50,-750" mesh="planets/moon.mesh" scale=100 />
@@ -98,7 +81,7 @@
<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"/>
- <SpawnPoint position="000.000, 000.000, 1000.000" orientation="0, 0, 0, -1" spawnclass=StoryModeController pawndesign=StoryMode />
+ <SpawnPoint position="000.000, 000.000, 1000.000" orientation="0, 0, 0, -1" spawnclass=StoryMode pawndesign=StoryMode />
</Scene>
Modified: code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.cc
===================================================================
--- code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.cc 2018-12-05 10:54:14 UTC (rev 12150)
+++ code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.cc 2018-12-05 10:54:24 UTC (rev 12151)
@@ -1,82 +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:
+ * Joel Lingg
+ * Co-authors:
+ * ...
+ *
+ */
+
#include "SMCoord.h"
namespace orxonox {
- SMCoord::SMCoord() {
- set(0);
- }
+ SMCoord::SMCoord() {
+ set(0);
+ }
- SMCoord::~SMCoord() {
-
- }
+ SMCoord::~SMCoord() {
- SMCoord::SMCoord(int x) {
- set(x);
- }
+ }
- void SMCoord::set(int index) {
- if(index<0) return;
- if(index>8) return;
- this->index = index;
+ SMCoord::SMCoord(int x) {
+ set(x);
+ }
+
+ //sets the index. the boundaries neeed to set higher when you want more games.
+ void SMCoord::set(int index) {
+ if (index < 0) {
+ this -> index = 0;
+ } else if (index > 3) {
+ this -> index = 3;
+ } else {
+ this -> index = index;
}
+ }
+ //Returns the 3dcoordinate of the symbol which is choosen at the moment
+ Vector3 SMCoord::get3dcoordinate() {
+ Vector3 coord;
+ switch (this -> index) {
+ case 0:
+ coord.x = 550;
+ coord.y = 300;
+ coord.z = 0;
+ break;
+ case 1:
+ coord.x = 600;
+ coord.y = 300;
+ coord.z = 0;
+ break;
+ case 2:
+ coord.x = 650;
+ coord.y = 300;
+ coord.z = 0;
+ break;
+ case 3:
+ coord.x = 700;
+ coord.y = 300;
+ coord.z = 0;
+ break;
- Vector3 SMCoord::get3dcoordinate() {
- Vector3 coord;
- switch(this->index)
- {
- case 0:
- coord.x= 550;
- coord.y = 300;
- coord.z = 0;
- break;
- case 1:
- coord.x= 100;
- coord.y = 350;
- coord.z = -250;
- break;
- case 2:
- coord.x= -600;
- coord.y = 250;
- coord.z = -500;
- break;
- case 3:
- coord.x= -1000;
- coord.y = 50;
- coord.z = -750;
- break;
- case 4:
- coord.x= -900;
- coord.y = -400;
- coord.z = -1000;
- break;
- case 5:
- coord.x= -500;
- coord.y = -700;
- coord.z = -1250;
- break;
- case 6:
- coord.x= 0;
- coord.y = -900;
- coord.z = -1500;
- break;
- case 7:
- coord.x= 700;
- coord.y = -1100;
- coord.z = -1750;
- break;
- case 8:
- coord.x= 1500;
- coord.y = 1300;
- coord.z = -2000;
- break;
- default:
- coord.x= 0;
- coord.y = 0;
- coord.z = 0;
- }
- return coord;
+ default:
+ coord.x = 550;
+ coord.y = 300;
+ coord.z = 0;
+ break;
}
+ return coord;
+ }
- int SMCoord::getIndex() {
- return this->index;
- }
+ int SMCoord::getIndex() {
+ return this -> index;
+ }
}
\ No newline at end of file
Modified: code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.h
===================================================================
--- code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.h 2018-12-05 10:54:14 UTC (rev 12150)
+++ code/branches/WorldMap_HS18/src/orxonox/controllers/SMCoord.h 2018-12-05 10:54:24 UTC (rev 12151)
@@ -1,3 +1,30 @@
+/*
+ * 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:
+ * Joel Lingg
+ * Co-authors:
+ * ...
+ *
+ */
#ifndef _SMCoord_H__
#define _SMCoord_H__
@@ -4,24 +31,18 @@
#include "core/CoreIncludes.h"
#include "gametypes/Deathmatch.h"
-namespace orxonox
-{
+namespace orxonox {
- class _OrxonoxExport SMCoord
- {
- public:
- SMCoord();
- SMCoord(int x);
- void set(int index);
- virtual int getIndex();
- virtual Vector3 get3dcoordinate();
- virtual ~SMCoord();
+ class _OrxonoxExport SMCoord {
+ public: SMCoord();
+ SMCoord(int x);
+ void set(int index);
+ virtual int getIndex();
+ virtual Vector3 get3dcoordinate();
+ virtual~SMCoord();
+ private: int index;
+ };
- private:
- int index;
- };
-
-
}
#endif
\ No newline at end of file
Modified: code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc
===================================================================
--- code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc 2018-12-05 10:54:14 UTC (rev 12150)
+++ code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc 2018-12-05 10:54:24 UTC (rev 12151)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Joel Lingg
* Co-authors:
* ...
*
@@ -28,166 +28,143 @@
#include "StoryModeController.h"
+namespace orxonox {
+ RegisterClass(StoryModeController);
-#include "core/CoreIncludes.h"
-#include "worldentities/ControllableEntity.h"
-#include "graphics/Camera.h"
-#include "SMCoord.h"
-#include "core/XMLPort.h"
-#include "gamestates/GSLevel.h"
-namespace orxonox
-{
- RegisterClass(StoryModeController);
+ StoryModeController::StoryModeController(Context * context): SpaceShip(context) {
- StoryModeController::StoryModeController(Context* context) : SpaceShip(context)
- {
- RegisterObject(StoryModeController);
- float time_;
- selectedPos_ = new SMCoord(0);
- moveForward_= false;
- moveBackward_=false;
- boostPressed_=false;
- dtime_=50;
+ RegisterObject(StoryModeController);
-
- }
- StoryModeController::~StoryModeController()
- {
- delete selectedPos_;
- selectedPos_ = nullptr;
+ //initiate all variables according to our needs
+ selectedPos_ = new SMCoord(0);
+ moveForward_ = false;
+ moveBackward_ = false;
+ boostPressed_ = false;
+ init_ = true;
+ dtime_ = 50;
+ time_ = dtime_ + 1;
+ updatePosition();
+ }
+ StoryModeController::~StoryModeController() {
+ delete selectedPos_;
+ selectedPos_ = nullptr;
+
+ }
+
+ //Pre:selectedPos_ needs to be defined
+ // Post: the position of the camera will be updated
+ void StoryModeController::updatePosition() {
+ Vector3 pos = selectedPos_ -> get3dcoordinate();
+ setPosition(pos);
+ }
+
+ //Pre: @index integer
+ //post: our new position is updated in selectedPos_
+ void StoryModeController::setLocation(int index) {
+ selectedPos_ -> set(index);
+ }
+
+ //Function which is repeated anz dt.
+ void StoryModeController::tick(float dt) {
+ //Passing arguments to SpaceShip
+ SUPER(StoryModeController, tick, dt);
+
+ Camera * camera = this -> getCamera();
+
+ if (init_ && camera != nullptr) {
+ camera -> setPosition(0, 0, 200);
+ camera -> setOrientation(Vector3::UNIT_Z, Degree(0));
+ init_ = false;
}
- //void StoryModeController:: switchCamera(){};
- void StoryModeController::updatePosition(){
- Vector3 pos = selectedPos_->get3dcoordinate();
- setPosition(pos);
- }
- void StoryModeController::setLocation(int index){
- selectedPos_->set(index);
- }
- void StoryModeController::tick(float dt)
- {
- //orxout(internal_error) << "Hi" << endl;
- SUPER(StoryModeController, tick, dt);
- time_ +=dt;
- Camera* camera = this->getCamera();
-
-
+ //As I dont want to update positions every time (to prevent multiple key presses) time_ is raised untill a sertain dtime_
+ time_++;
+ if (time_ >= dtime_) {
- if(time_>= dtime_*dt){
-
- time_=0;
-
- if(moveForward_ == true){
- orxout(internal_error) << "Position update" << endl;
- moveForward_ = false;
- selectedPos_->set(selectedPos_->getIndex()+1);
- updatePosition();
- }
+ time_ = 0;
- if(moveBackward_ == true){
- orxout(internal_error) << "Position update" << endl;
- moveBackward_ = false;
- selectedPos_->set(selectedPos_->getIndex()-1);
- updatePosition();
- }
+ if (moveForward_ == true) {
+ moveForward_ = false;
+ selectedPos_ -> set(selectedPos_ -> getIndex() + 1);
+ updatePosition();
+ }
- if(boostPressed_ == true){
- boostPressed_ = false;
- chooseGame();
- }
+ if (moveBackward_ == true) {
+ moveBackward_ = false;
+ selectedPos_ -> set(selectedPos_ -> getIndex() - 1);
+ updatePosition();
+ }
-
- if (camera != nullptr)
- {
+ if (boostPressed_ == true) {
+ boostPressed_ = false;
+ chooseGame();
+ }
- Vector3 epos = selectedPos_->get3dcoordinate();
- orxout(internal_error) << "ex: "<< epos.x <<" ey: "<< epos.y << " ez: " << epos.z<< endl;
- camera->setPosition(-(epos.x),-(epos.y),-(epos.z)+1000);
- camera->setOrientation(Vector3::UNIT_Z, Degree(0));
+ //updates the cameraposition
+ if (camera != nullptr) {
- }
- }
-
+ camera -> setPosition(0, 0, 200);
+ camera -> setOrientation(Vector3::UNIT_Z, Degree(0));
+
+ }
}
- void StoryModeController::moveFrontBack(const Vector2& value)
- {
- // orxout(internal_error) << "moveFrontBack" << endl;
+ }
+
+ //Post: The game is choosen acording to the index in selectedPos_. This one must be extended if more games want to be loaded
+ void StoryModeController::chooseGame() {
+ int ind = selectedPos_ -> getIndex();
+ std::string name = "changeGame ";
+ switch (ind) {
+ case 0:
+ name = name + "gallery.oxw";
+ break;
+ case 1:
+ name = name + "pong.oxw";
+ break;
+ case 2:
+ name = name + "towerDefense.oxw";
+ break;
+ case 3:
+ name = name + "SOB.oxw";
+ break;
+
+ default:
+ name = name + "MapExample.oxw";
+ break;
}
+ CommandExecutor::execute(name);
- void StoryModeController::chooseGame()
- {
- int ind = selectedPos_->getIndex();
- std::string name = "changeGame ";
- switch(ind){
- case 0:
- name = name + "pong.oxw";
- break;
- case 1:
-
- break;
- case 2:
-
- break;
- case 3:
-
- break;
- case 4:
-
- break;
- case 5:
-
- break;
- case 6:
-
- break;
- case 7:
-
- break;
- case 8:
-
- break;
- default:
- break;
- }
- CommandExecutor::execute(name);
- /*for (GSLevel* level : ObjectList<GSLevel>())
- level->changeGame(name);*/
- //hideAllMenuSheets();
+ }
+
+ //decides if we move left or right
+ void StoryModeController::moveRightLeft(const Vector2 & value) {
+ if (!moveForward_ && !moveBackward_ && !boostPressed_) {
+ if (value.x > 0) {
+ moveForward_ = false;
+ moveBackward_ = true;
+ } else {
+ moveBackward_ = false;
+ moveForward_ = true;
+ }
}
+ }
- void StoryModeController::moveRightLeft(const Vector2& value)
- {
- if(!moveForward_&&!moveBackward_){
- if (value.x>0){
- orxout(internal_error) << "Right" << endl;
- moveForward_ =true;
- moveBackward_ =false;
- } else {
- orxout(internal_error) << "Left" << endl;
- moveBackward_ = true;
- moveForward_ = false;
- }
- }
-
+ //decides to choose the game
+ void StoryModeController::boost(bool bBoost) {
+ if (!moveForward_ && !moveBackward_ && !boostPressed_) {
+ boostPressed_ = true;
}
+ }
- void StoryModeController::rotateYaw(const Vector2& value){
- //orxout(internal_error) << "RightLeft" << endl;
- }
- void StoryModeController::rotatePitch(const Vector2& value){
- //orxout(internal_error) << "RightLeft" << endl;
- }
- void StoryModeController::rotateRoll(const Vector2& value){
- //orxout(internal_error) << "RightLeft" << endl;
- }
- void StoryModeController::fire(unsigned int a){}
- void StoryModeController::fired(unsigned int b){}
- void StoryModeController::boost(bool bBoost){
- orxout(internal_error) << "Boost" << endl;
- boostPressed_ = true;
- }
-}
+ //Some functions I didn't use, but can be used to enhance your map. Just orientate at the function above
+ void StoryModeController::rotateYaw(const Vector2 & value) {}
+ void StoryModeController::rotatePitch(const Vector2 & value) {}
+ void StoryModeController::rotateRoll(const Vector2 & value) {}
+ void StoryModeController::moveFrontBack(const Vector2 & value) {}
+ void StoryModeController::fire(unsigned int a) {}
+ void StoryModeController::fired(unsigned int b) {}
+
+}
\ No newline at end of file
Modified: code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.h
===================================================================
--- code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.h 2018-12-05 10:54:14 UTC (rev 12150)
+++ code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.h 2018-12-05 10:54:24 UTC (rev 12151)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Joel Lingg
* Co-authors:
* ...
*
@@ -38,12 +38,19 @@
#include "tools/interfaces/Tickable.h"
#include "worldentities/ControllableEntity.h"
#include "worldentities/pawns/SpaceShip.h"
+
+
+#include "core/CoreIncludes.h"
+
+#include "graphics/Camera.h"
#include "SMCoord.h"
+//#include "core/XMLPort.h"
+//#include "gamestates/GSLevel.h"
//#include <gtest/gtest.h>
#include "core/class/Identifier.h"
#include "core/class/IdentifierManager.h"
-#include "core/command/ConsoleCommandIncludes.h"
+//#include "core/command/ConsoleCommandIncludes.h"
#include "core/command/CommandExecutor.h"
#include "core/object/Destroyable.h"
#include "core/module/ModuleInstance.h"
@@ -53,9 +60,11 @@
class _OrxonoxExport StoryModeController : public SpaceShip
{
public:
+ // Implementation of a Controller needs the two following lines
StoryModeController(Context* context);
virtual ~StoryModeController();
-
+ // As we extend SpaceShip but just are interested in the moment of function
+ // calling, we mark all the functions of spaceship to be override
virtual void tick(float dt) override;
virtual void moveFrontBack(const Vector2& value) override;
virtual void moveRightLeft(const Vector2& value) override;
@@ -65,20 +74,31 @@
void fire(unsigned int firemode);
virtual void fired(unsigned int firemode) override;
virtual void boost(bool bBoost) override;
- //virtual void switchCamera() override;
+
+
+ private:
+ //Add to function to set and update the Position. As setPosition isn't available, we used setLocation
virtual void setLocation(int index);
- bool moveRight_ ;
- bool moveLeft_ ;
- SMCoord* selectedPos_;
- private:
- virtual void updatePosition();
+ virtual void updatePosition();
+
+ //According to the position, this function starts the game.
+ virtual void chooseGame();
+
+ SMCoord* selectedPos_;
+
+ //Variables to keep track of time
float time_;
int dtime_;
+
+ //Bools which get true as soon as the event they are named after has occured
+ bool moveRight_ ;
+ bool moveLeft_ ;
bool moveForward_;
bool moveBackward_;
bool boostPressed_;
- virtual void chooseGame();
+ bool init_;
+
};
}
More information about the Orxonox-commit
mailing list