[Orxonox-commit 6895] r11516 - in code/branches/Asteroid_HS17: data/levels data/overlays src/modules/asteroids
vyang at orxonox.net
vyang at orxonox.net
Mon Oct 30 16:04:29 CET 2017
Author: vyang
Date: 2017-10-30 16:04:29 +0100 (Mon, 30 Oct 2017)
New Revision: 11516
Added:
code/branches/Asteroid_HS17/data/levels/Asteroids.oxw
code/branches/Asteroid_HS17/data/overlays/asteroidsHUD.oxo
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.cc
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.h
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsPrereqs.h
Modified:
code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc
code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h
code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt
Log:
Files hinzugefuegt, versucht Aehnlichkeiten mit anderen minigames (dodgerace, invader) zu finden. Testlevel noch zu bearbeiten. Gametype Asteroids crashed immer noch
Added: code/branches/Asteroid_HS17/data/levels/Asteroids.oxw
===================================================================
--- code/branches/Asteroid_HS17/data/levels/Asteroids.oxw (rev 0)
+++ code/branches/Asteroid_HS17/data/levels/Asteroids.oxw 2017-10-30 15:04:29 UTC (rev 11516)
@@ -0,0 +1,75 @@
+ <LevelInfo
+ name = "Asteroids"
+ description = "Try to prevent asteroids from colliding into your spaceshuttle. Be prepared to dodge all asteroids or destroy them;"
+ tags = "asteroids, minigame"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("templates/lodInformation.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipAssff2.oxt")
+ include("templates/spaceshipPirate.oxt")
+ include("templates/spaceshipDodgeRace.oxt")
+ include("templates/enemyInvader.oxt")
+ include("templates/DodgeRacePattern.oxt")
+ include("overlays/DodgeRaceHUD.oxo")
+?>
+
+
+
+<Level
+ plugin = asteroids
+ gametype = Asteroids
+ >
+
+
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
+
+ <Scene
+ ambientlight = "1.0, 1.0, 1.0"
+ skybox = "Orxonox/skyBoxClouds"
+ negativeWorldRange = "-100000, -100000, -100000"
+ positiveWorldRange = " 100000, 100000, 100000"
+ >
+
+ <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="-100, 10000, -700" lookat="0.2, -1, 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=AsteroidsShip pawndesign=spaceshipdodgerace />
+
+ <DistanceTrigger name="start" position="-200,0,0" target="Pawn" distance=10 stayActive="true" delay=0 />
+
+
+ <DodgeRaceCenterPoint name=invadercenter />
+
+ <StaticEntity position="0,-50,0" direction="0,0,0" scale="1" collisionType=static mass=1 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="plane.mesh" scale3D="100000,0,100000" />
+ </attached>
+
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="1,1,1" />
+ </collisionShapes>
+
+ </StaticEntity>
+
+
+
+
+
+
+ </Scene>
+</Level>
+
Added: code/branches/Asteroid_HS17/data/overlays/asteroidsHUD.oxo
===================================================================
--- code/branches/Asteroid_HS17/data/overlays/asteroidsHUD.oxo (rev 0)
+++ code/branches/Asteroid_HS17/data/overlays/asteroidsHUD.oxo 2017-10-30 15:04:29 UTC (rev 11516)
@@ -0,0 +1,37 @@
+<Template name="AsteroidsHUD">
+ <OverlayGroup name="AsteroidsHUD" scale = "1, 1">
+ <AsteroidsScore
+ position = "0.9, 0.1"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.05
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ />
+
+ <OverlayText
+ position = "0.7, 0.10"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.05
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+
+ caption = "Points: "
+ />
+
+ <OverlayText
+ position = "0.7, 0.20"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.05
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+
+ caption = "Next Brick"
+ />
+
+
+
+ </OverlayGroup>
+</Template>
Modified: code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc 2017-10-30 15:01:47 UTC (rev 11515)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc 2017-10-30 15:04:29 UTC (rev 11516)
@@ -1,23 +1,121 @@
+/*
+ * 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 "Asteroids.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 "AsteroidsCenterPoint.h"
+#include "AsteroidsShip.h"
+
+#include "core/command/ConsoleCommand.h"
+#include "worldentities/ExplosionPart.h"
+
namespace orxonox
{
- RegisterUnloadableClass(Asteroids);
+ RegisterUnloadableClass(Asteroids);
- Asteroids::Asteroids(Context* context) : Deathmatch(context)
- {
- level = 1;
- this->numberOfBots = 0;
- }
+ Asteroids::Asteroids(Context* context) : Deathmatch(context)
+ {
+ RegisterObject(Asteroids);
+ this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
+ this->center_ = nullptr;
+ bEndGame = false;
+ lives = 3;
+ point = 0;
- void Asteroids::spawnAsteroid();
+ }
- void Asteroids::setCenterpoint(InvaderCenterPoint* center)
+
+ AsteroidsShip* Asteroids::getPlayer()
{
+ if (player == nullptr)
+ {
+ for (Asteroids* ship : ObjectList<AsteroidsShip>())
+ player = ship;
+ }
+ return player;
+ }
+
+
+ void Asteroids::setCenterpoint(AsteroidsCenterPoint* center)
+ {
this->center_ = center;
}
- void Asteroids::start();
- void Asteroids::end();
-
-}
\ No newline at end of file
+ void Asteroids::costLife()
+ {
+ lives = 0;
+ };
+
+ void Asteroids::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 Asteroids::addPoints(int numPoints)
+ {
+ if (!bEndGame)
+ {
+ point += numPoints;
+ }
+ }
+
+ void Asteroids::end()
+ {
+ // DON'T CALL THIS!
+ // Deathmatch::end();
+ // It will misteriously crash the game!
+ // Instead startMainMenu, this won't crash.
+ GSLevel::startMainMenu();
+ }
+}
Modified: code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h 2017-10-30 15:01:47 UTC (rev 11515)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h 2017-10-30 15:04:29 UTC (rev 11516)
@@ -32,11 +32,10 @@
@ingroup Invader
*/
-#ifndef _Invader_H__
-#define _Invader_H__
+#ifndef _Asteroids_H__
+#define _Asteroids_H__
-#include "invader/InvaderPrereqs.h"
-
+#include "asteroids/AsteroidsPrereqs.h"
#include "gametypes/Deathmatch.h"
#include "tools/Timer.h"
@@ -43,38 +42,33 @@
namespace orxonox
{
- class _InvaderExport Invader : public Deathmatch
+ class _AsteroidsExport Asteroids : public Deathmatch
{
public:
- Invader(Context* context);
+ Asteroids(Context* context);
virtual void start() override;
virtual void end() override;
+ virtual void tick(float dt) override;
virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
- void spawnEnemy();
+ void setCenterpoint(AsteroidsCenterPoint* center);
- 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;
+ AsteroidsShip* getPlayer();
+ WeakPtr<AsteroidsCenterPoint> center_;
+ WeakPtr<AsteroidsShip> player;
+ WeakPtr<Camera> camera;
Timer enemySpawnTimer;
Timer comboTimer;
Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.cc (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.cc 2017-10-30 15:04:29 UTC (rev 11516)
@@ -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 InvaderCenterPoint.cc
+ @brief Implementation of the InvaderCenterPoint class.
+*/
+
+#include "AsteroidsCenterPoint.h"
+
+#include "core/CoreIncludes.h"
+
+#include "Asteroids.h"
+
+namespace orxonox
+{
+ RegisterClass(AsteroidsCenterPoint);
+
+ AsteroidsCenterPoint::AsteroidsCenterPoint(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(AsteroidsCenterPoint);
+
+ this->checkGametype();
+ }
+
+ void AsteroidsCenterPoint::checkGametype()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(Asteroids)))
+ {
+ Asteroids* AsteroidsGametype = orxonox_cast<Asteroids*>(this->getGametype());
+ AsteroidsGametype->setCenterpoint(this);
+ }
+ }
+}
Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.h (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.h 2017-10-30 15:04:29 UTC (rev 11516)
@@ -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 InvaderCenterPoint.h
+ @brief Declaration of the InvaderCenterPoint class.
+ @ingroup Invader
+*/
+
+#ifndef _AsteroidsCenterPoint_H__
+#define _AsteroidsCenterPoint_H__
+
+#include "asteroids/AsteroidsPrereqs.h"
+
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+ class _AsteroidsExport AsteroidsCenterPoint : public StaticEntity
+ {
+ public:
+ AsteroidsCenterPoint(Context* context); //checks whether the gametype is actually Invader.
+
+ private:
+ void checkGametype();
+
+ };
+}
+
+#endif /* _InvaderCenterPoint_H__ */
Added: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsPrereqs.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsPrereqs.h (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsPrereqs.h 2017-10-30 15:04:29 UTC (rev 11516)
@@ -0,0 +1,74 @@
+/*
+ * 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:
+ * Reto Grieder
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Shared library macros, enums, constants and forward declarations for the tetris module
+*/
+
+#ifndef _AsteroidsPrereqs_H__
+#define _AsteroidsPrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(TETRIS_STATIC_BUILD)
+# ifdef ASTEROIDS_SHARED_BUILD
+# define _AsteroidsExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _AsteroidsExport
+# else
+# define _AsteroidsExport __declspec(dllimport)
+# endif
+# endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+# define _AsteroidsExport __attribute__ ((visibility("default")))
+#else
+# define _AsteroidsExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class Asteroids;
+ class AsteroidsCenterpoint;
+ class AsteroidsStone;
+ class AsteroidsShip;
+ class AsteroidsWeapon;
+}
+
+#endif /* _AsteroidsPrereqs_H__ */
Modified: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc 2017-10-30 15:01:47 UTC (rev 11515)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc 2017-10-30 15:04:29 UTC (rev 11516)
@@ -2,11 +2,12 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
-#include "Invader.h"
-#include "InvaderEnemy.h"
+#include "Asteroids.h"
#include "graphics/Camera.h"
+#include "asteroids/AsteroidStone"
#include "weapons/projectiles/Projectile.h"
+
namespace orxonox
{
//Constructor
@@ -15,13 +16,23 @@
AsteroidsShip::AsteroidsShip(Context* context) : SpaceShip(context)
{
RegisterObject(AsteroidsShip);
+ /*radius = 20;
+ x = getPosition().x;
+ y = getPosition().y;
+ dx = 3.0f;
+ dy = 3.0f;
+ angle= 0.0f;*/
- float x = getPosition().x;
- float y = getPosition().y;
- float velocityx = 0.0f;
- float velocityy = 0.0f;
- this->bBoost_ = false;
+ speed = 830;
+ isFireing = false;
+ damping = 10;
+
+ lastTimeFront = 0;
+ lastTimeLeft = 0;
+ lastTime = 0;
+
}
+
//Destructor
AsteroidsShip::~AsteroidsShip()
{
@@ -34,12 +45,30 @@
//update coordinates and velocity
void AsteroidsShip::tick(float dt)
{
- //Movement computation
- Vector3 speed = Vector3 (100, 100, 0);
- Vector3 position = this->getPosition();
- position += (speed * dt);
- this->setPosition(position);
+ /*Movement computation
+ Vector3 pos = getPosition();
+
+ dx *= damping;
+ dy *= damping;
+
+ float speed = sqrt(dx*dx+ dy*dy);
+ if(speed > maxspeed)
+ {
+ dx *= maxspeed/speed;
+ dy *= mayspeed/speed;
+ }
+
+ x += dx;
+ y += dy;
+
+ if(x>W) x=0;
+ if(x<0) x=W;
+ if(y>H) y=0;
+ if(y<0) y=H;
+ setPosition(x,y,0);
+
//roll? muss sich das Raumschiff drehen?
+ setOrientation(angle, x, y, 0);
//Schiessen wenn geschossen wurde
// shoot!
@@ -46,11 +75,78 @@
if (isFireing)
ControllableEntity::fire(0);
- //Leben verloren
+ //Leben verloren */
+ 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));
+
+ SUPER(AsteroidsShip, tick, dt);
}
- void
+ Asteroids* AsteroidsShip::getGame()
+ {
+ if (game == nullptr)
+ {
+ for (Asteroids* asteroids : ObjectList<Asteroids>())
+ game = asteroids;
+ }
+ return game;
+ }
+ void InvaderShip::death()
+ {
+ getGame()->costLife();
+ SpaceShip::death();
+ }
Modified: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h 2017-10-30 15:01:47 UTC (rev 11515)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h 2017-10-30 15:04:29 UTC (rev 11516)
@@ -32,114 +32,65 @@
@ingroup DodgeRace
*/
-#ifndef _DodgeRace_H__
-#define _DodgeRace_H__
+#ifndef _Asteroids_H__
+#define _Asteroids_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 "asteroids/AsteroidsPrereqs.h"
#include "gametypes/Deathmatch.h"
-#include "tools/Timer.h"
+#include "worldentities/pawns/SpaceShip.h"
+#include "weapons/projectiles/Projectile.h"
+#include <math.h>
namespace orxonox
{
- class _DodgeRaceExport DodgeRace : public Deathmatch
+ class _AsteroidsExport Asteroids : public SpaceShip
{
public:
- DodgeRace(Context* context);
+ Asteroids(Context* context);
- virtual void start() override;
- virtual void end() override;
-
virtual void tick(float dt) override;
- virtual void playerPreSpawn(PlayerInfo* player) override;
+ // overwrite for 2d movement
+ virtual void moveFrontBack(const Vector2& value) override;
+ virtual void moveRightLeft(const Vector2& value) override;
- void levelUp();
+ // Starts or stops fireing
+ virtual void boost(bool bBoost) override;
- 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;
+ float angle, radius;
+ float speed, damping, posforeward;
+ bool isFireing;
- private:
- Timer endGameTimer;
+ //Nachschauen wie gross das Spielfeld ist!
+ float H = 1000;
+ float W = 1000;
- DodgeRaceShip* getPlayer();
- WeakPtr<DodgeRaceShip> player;
- std::vector<DodgeRaceCube*> cubeList;
- void toggleShowLevel(){bShowLevel = !bShowLevel;}
- void addPoints(int numPoints);
+ protected:
+ virtual void death() override;
- WeakPtr<DodgeRaceCenterPoint> center_;
- int level;
- int point;
- bool b_combo;
-
- Timer enemySpawnTimer;
- Timer comboTimer;
- Timer showLevelTimer;
-
-
- /*
-
- //void spawnEnemy();
-
-
-
-
-
-
-
-
-
-
-
-
- private:
-
-
-
-
- //Context* context;
- */
+ private:
+ Asteroids* getGame();
+ WeakPtr<Asteroids> game;
+ WeakPtr<WorldEntity> lastEntity;
+ Camera* camera;
+ float lastTimeFront, lastTimeLeft, lastTime;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity, desiredVelocity;
+
};
}
-#endif /* _DodgeRace_H__ */
+#endif /* _Asteroids_H__ */
Modified: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc 2017-10-30 15:01:47 UTC (rev 11515)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc 2017-10-30 15:04:29 UTC (rev 11516)
@@ -31,39 +31,45 @@
@brief Declaration of the InvaderEnemy class.
*/
-#include "InvaderEnemy.h"
-
+#include "AsteroidsStone.h"
#include "core/CoreIncludes.h"
-#include "Invader.h"
-#include "InvaderShip.h"
+#include "Asteroids.h"
+#include "AsteroidsShip.h"
+#include <cmath>
+#include "util/Math.h"
namespace orxonox
{
- RegisterClass(InvaderEnemy);
+ RegisterClass(AsteroidsStone);
- InvaderEnemy::InvaderEnemy(Context* context) : Pawn(context)
+ AsteroidsStone::AsteroidsStone(Context* context) : MovableEntity(context)
{
- RegisterObject(InvaderEnemy);
- enableCollisionCallback();
- lifetime = 0;
- }
+ RegisterObject(AsteroidsStone);
- void InvaderEnemy::tick(float dt)
- {
- lifetime += dt;
- // die after 5 seconds.
- if (lifetime > 5000)
- removeHealth(2000);
+ maxspeed = 50.0f;
+ //Random Spawn? pos= random?
+ this->setPosition(rnd(0, fieldWidth_), rnd(0, fieldHeigth_), 0);
+ if(r){
+ this.r = r*0.5;
+ }else{
+ this.r = rnd(15, 50);
+ }
- if (player != nullptr)
- {
- float newZ = 2/(pow(std::abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);
- setVelocity(Vector3(1000.f - level * 100 , 0, newZ));
- }
- SUPER(InvaderEnemy, tick, dt);
+ //random Geschwindigkeit und Richtung
+ velocity.x = rnd(0, maxspeed);
+ velocity.y = rnd(0, maxspeed);
}
+//Bis hier geschrieben
+ void AsteroidsStone::tick(float dt)
+ {
+ Vector3 pos = this->getPosition();
+ pos.x += velocity.x*dt;
+ pos.y += velocity.y*dt;
+ setPosition(pos);
+ SUPER(AsteroidsStone, tick, dt);
+ }
- inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+ inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
{
if(orxonox_cast<InvaderShip*>(otherObject))
removeHealth(2000);
@@ -70,20 +76,5 @@
return false;
}
- Invader* InvaderEnemy::getGame()
- {
- if (game == nullptr)
- {
- for (Invader* invader : ObjectList<Invader>())
- game = invader;
- }
- return game;
- }
- void InvaderEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
- {
- Pawn::damage(damage, healthdamage, shielddamage, originator, cs);
- if (getGame() && orxonox_cast<InvaderShip*>(originator) != nullptr && getHealth() <= 0)
- getGame()->addPoints(42);
- }
}
Modified: code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h 2017-10-30 15:01:47 UTC (rev 11515)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h 2017-10-30 15:04:29 UTC (rev 11516)
@@ -31,41 +31,31 @@
@brief Declaration of the InvaderEnemy class.
*/
-#ifndef _InvaderEnemy_H__
-#define _InvaderEnemy_H__
+#ifndef _AsteroidsStone_H__
+#define _AsteroidsStone_H__
-#include "invader/InvaderPrereqs.h"
+#include "asteroids/AsteroidsPrereqs.h"
-#include "worldentities/pawns/Pawn.h"
+#include "worldentities/MovableEntity.h"
namespace orxonox
{
- class _InvaderExport InvaderEnemy : public Pawn
+ class _AsteroidsExport AsteroidsStone : public MovableEntity
{
public:
- InvaderEnemy(Context* context);
-
+ AsteroidsStone(Context* context);
virtual void tick(float dt) override;
- virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
- virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override;
- virtual void setInvaderPlayer(InvaderShip* player){this->player = player;}
+ float r;
int level;
protected:
- Invader* getGame();
- WeakPtr<Invader> game;
- WeakPtr<InvaderShip> player;
- Camera* camera;
- bool isFireing;
- float speed, damping;
- float lastTimeFront, lastTimeLeft;
- float lifetime;
- struct Velocity
- {
- float x;
- float y;
- } velocity, desiredVelocity;
+ float fieldWidth_;
+ float fieldHeight_;
+ Vector2 velocity;
+ float maxspeed;
+
+
};
}
Modified: code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt 2017-10-30 15:01:47 UTC (rev 11515)
+++ code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt 2017-10-30 15:04:29 UTC (rev 11516)
@@ -1,17 +1,14 @@
-SET_SOURCE_FILES(Invader_SRC_FILES
-BUILD_UNIT InvaderBuildUnit.cc
- Invader.cc
- InvaderCenterPoint.cc
+SET_SOURCE_FILES(ASTEROIDS_SRC_FILES
+BUILD_UNIT AsteroidsBuildUnit.cc
+ Asteroids.cc
+ AsteroidsCenterPoint.cc
InvaderShip.cc
- InvaderEnemy.cc
- InvaderEnemyShooter.cc
- InvaderWeapon.cc
- InvaderWeaponEnemy.cc
- InvaderHUDinfo.cc
+ AsteroidsStone.cc
+ AsteroidsWeapon.cc
END_BUILD_UNIT
)
-ORXONOX_ADD_LIBRARY(invader
+ORXONOX_ADD_LIBRARY(asteroids
PLUGIN
FIND_HEADER_FILES
LINK_LIBRARIES
@@ -18,5 +15,5 @@
orxonox
overlays
weapons
- SOURCE_FILES ${Invader_SRC_FILES}
+ SOURCE_FILES ${ASTEROIDS_SRC_FILES}
)
More information about the Orxonox-commit
mailing list