[Orxonox-commit 7041] r11660 - code/branches/Asteroid_HS17/src/modules/asteroids2D
vyang at orxonox.net
vyang at orxonox.net
Mon Dec 11 16:06:44 CET 2017
Author: vyang
Date: 2017-12-11 16:06:44 +0100 (Mon, 11 Dec 2017)
New Revision: 11660
Modified:
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.h
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h
Log:
Projektile fliegen in 2D Ebene, jedoch in eine falsche Richtung. Kommentare hinzugefuegt
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc 2017-12-11 15:06:44 UTC (rev 11660)
@@ -20,20 +20,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Viviane Yang
* Co-authors:
* ...
*
*/
-/*TODO: Punktesystem aufbauen -> in HUD anzeigen
- Schwierigkeitsgrad mit jedem levelup erhöhen -> mehr Steine spawnen?
- spawnStone Methode schreiben
- templates für die drei Grössen von Asteroiden erstellen
+
/**
@file Asteroids2D.cc
@brief Implementation of the Asteroids2D class.
+
+ TODO:
+ - Implement a counting system for the score
+ - HUD can be improved (display health, points, level etc.)
+ - Projectiles still
*/
#include "Asteroids2D.h"
@@ -61,7 +63,7 @@
this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
this->center_ = nullptr;
this->setHUDTemplate("Asteroids2DHUD");
- levelupTimer.setTimer(60.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this)));
+ levelupTimer.setTimer(30.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this))); //level up every 30s
}
@@ -91,7 +93,7 @@
showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Asteroids2D::toggleShowLevel, this)));
- //Nach jedem Level Up werden mehr Steine gespawnt -> abhängig vom Schwierigkeitsgrad
+ //After level up -> spawn stones
for(int i = 0; i < level*2; i++){
spawnStone();
}
@@ -100,7 +102,7 @@
void Asteroids2D::tick(float dt)
{
- //Do this only for the first tick, generate 5 stones for the beginning
+ //Do this only for the first tick, generate 5 stones in the beginning
if(this->firstTick_)
{
getPlayer();
@@ -117,6 +119,8 @@
void Asteroids2D::spawnStone()
{
+
+ //stones are created with a size
Asteroids2DStone* newStone = new Asteroids2DStone(this->center_->getContext());
newStone->setAsteroids2DPlayer(player);
@@ -157,7 +161,7 @@
}
};
-//Funktion wird als erstes im Level aufgerufen
+ //The first function that will be called
void Asteroids2D::start()
{
orxout() << "start" << endl;
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h 2017-12-11 15:06:44 UTC (rev 11660)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Viviane Yang
* Co-authors:
* ...
*
@@ -30,7 +30,11 @@
/**
@file Asteroids2D.h
- @brief Gametype.
+ @brief Gametype:
+ - Goal: Survive as long as you can, do not collide with stones
+ - spawns stones in every level up
+ - if you shoot and hit a stone, it will spit into two smaller stones
+ -
@ingroup Asteroids2D
*/
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc 2017-12-11 15:06:44 UTC (rev 11660)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Viviane Yang
* Co-authors:
* ...
*
@@ -53,6 +53,7 @@
/**
@brief
Method to create a Asteroids2DCenterpoint through XML.
+ Set dimension of the field with "width_, height_"
*/
void Asteroids2DCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
@@ -60,6 +61,8 @@
XMLPortParam(Asteroids2DCenterPoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
}
+
+
void Asteroids2DCenterPoint::checkGametype()
{
if (this->getGametype() != nullptr && this->getGametype()->isA(Class(Asteroids2D)))
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.h 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.h 2017-12-11 15:06:44 UTC (rev 11660)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Viviane Yang
* Co-authors:
* ...
*
@@ -63,7 +63,7 @@
{ return Vector2(this->width_, this->height_); }
private:
- void checkGametype();
+ void checkGametype(); //checks whether the gametype actually is Asteroids2D
float width_, height_;
};
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc 2017-12-11 15:06:44 UTC (rev 11660)
@@ -20,15 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Viviane Yang
* Co-authors:
* ...
*
*/
-/*TODO: orientation/direction of the ship must be defined
- implement shoot function ->or switch it on?
- switch off boosting particles in the back of the ship
+/* TODO:
/**
@file Asteroids2DShip.cc
@@ -53,7 +51,7 @@
this->width = 1043;
this->height = 646;
- timer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2DShip::showposition, this)));
+ //timer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2DShip::showorientation, this)));
}
//Use this function to display your position on the field -> to determine field width and height
@@ -63,12 +61,19 @@
orxout() << "x = "<< pos.x << " y = " << pos.y << " z = "<< pos.z << endl;
}
+ //Same thing for orientation
+ void Asteroids2DShip::showorientation()
+ {
+ Quaternion ort = this->getOrientation();
+ orxout() << "w = " << ort.w << " x = " << ort.x << " y = " << ort.y << "z = " << ort.z << endl;
+ }
+
void Asteroids2DShip::tick(float dt)
{
SUPER(Asteroids2DShip, tick, dt);
Vector3 pos = this->getPosition();
- //haelt ship innerhalb des Kamerafensters, kommt oben bzw seitlich wieder raus. Man spawnt in (0,0)
+ //ensure that the ship stays in playing field
if(pos.x > width/2) pos.x = -width/2;
if(pos.x < -width/2) pos.x = width/2;
if(pos.z > height/2) pos.z = -height/2;
@@ -78,11 +83,16 @@
if(pos.y!=0) pos.y = 0;
this->setPosition(pos);
- //update level
+
//shoot?
}
+ void Asteroids2DShip::boost(bool bBoost)
+ {
+ isFireing = bBoost;
+ }
+
void Asteroids2DShip::updateLevel()
{
if (getGame())
@@ -89,11 +99,6 @@
getGame()->levelUp();
}
- void Asteroids2DShip::boost(bool bBoost)
- {
- //getGame()->bEndGame = bBoost;
- }
-
inline bool Asteroids2DShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
{
@@ -106,7 +111,6 @@
//The ship will be immune for 3 seconds after it has been hit by an asteroid
bImmune = true;
isimmune.setTimer(3.0f, false, createExecutor(createFunctor(&Asteroids2DShip::toggleImmune, this)));
- orxout()<< "touched" << endl;
}
return false;
}
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h 2017-12-11 15:06:44 UTC (rev 11660)
@@ -59,21 +59,18 @@
virtual void tick(float dt) override;
- // Starts or stops fireing
- virtual void boost(bool bBoost) override;
-
//no rotation in x and z direction!
- //virtual void rotateYaw(const Vector2& value) override{}; // Rotate in yaw direction.
virtual void rotatePitch(const Vector2& value) override{}; // Rotate in pitch direction.
virtual void rotateRoll(const Vector2& value) override{}; // Rotate in roll direction.
-
+ virtual void boost(bool boost) override;
virtual void updateLevel();
virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
- float speed, damping, posforeward;
+ float speed, damping;
bool isFireing;
void showposition();
+ void showorientation();
void toggleImmune()
{
bImmune = !bImmune;
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc 2017-12-11 15:06:44 UTC (rev 11660)
@@ -19,17 +19,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Samuel Riedel
+ * Viviane Yang
* Co-authors:
* ...
*
*/
+
+
/**
@file Asteroids2DStone.cc
+
@brief Implementation of the Asteroids2DStone class.
-*/
+ TO DO:
+ - instead of moving over the boarders of the playing field, modify the tick function so that the stones bounce back
+ - when to split? It does not work if you override kill() function...->damage() function?
+*/
+
#include "Asteroids2DStone.h"
#include "Asteroids2D.h"
#include "Asteroids2DShip.h"
@@ -86,6 +93,7 @@
SUPER(Asteroids2DStone, tick, dt);
Vector3 pos = this->getPosition();
+
if(pos.x >= width/2){
pos.x = -width/2;
}else if(pos.x <= -width/2){
@@ -102,9 +110,11 @@
inline bool Asteroids2DStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
{
+ orxout() << "AsteroidStone getroffen" << endl;
if(orxonox_cast<Asteroids2DShip*>(otherObject))
{
- this->split();
+ orxout() << "getroffen von Ship" << endl;
+ split();
}
return false;
}
@@ -111,15 +121,20 @@
void Asteroids2DStone::split()
{
+ orxout() << "split" << endl;
if(size == 1)
{
this->death();
}else if(size == 2){
+
+
+ //Templates can be found in data/levels/templates/asteroidsAsteroids2D.oxt
Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
newStone1->addTemplate("stone1");
Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
newStone2->addTemplate("stone1");
+
}else{
Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition());
newStone1->addTemplate("stone1");
@@ -128,23 +143,4 @@
}
}
-
-
-
- //Overload kill function to generate 2 asteriods
- /*void Asteroids2DStone::kill()
- {
- this->damage(this->health)
- if(this->size < 1)
- {
- this->death();
- }else{
- size -= 1;
-
- }
-
-
- }*/
-
-
}
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc 2017-12-11 15:06:44 UTC (rev 11660)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Viviane Yang
* Co-authors:
* --
*
@@ -47,6 +47,8 @@
#include "weapons/projectiles/Projectile.h"
#include "weapons/MuzzleFlash.h"
+#include "Asteroids2D.h"
+
namespace orxonox
{
RegisterClass(Asteroids2DWeapon);
@@ -54,6 +56,8 @@
Asteroids2DWeapon::Asteroids2DWeapon(Context* context) : HsW01(context)
{
RegisterObject(Asteroids2DWeapon);
+
+
}
Asteroids2DWeapon::~Asteroids2DWeapon()
@@ -61,6 +65,19 @@
}
+ Asteroids2D* Asteroids2DWeapon::getGame()
+ {
+ if (game == nullptr)
+ {
+ for (Asteroids2D* race : ObjectList<Asteroids2D>())
+ {
+ game = race;
+ }
+ }
+ return game;
+ }
+
+
void Asteroids2DWeapon::shot()
{
assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
@@ -74,9 +91,12 @@
model->setScale(5);
this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
- projectile->setOrientation(this->getMuzzleOrientation());
+
+ //projectile->setOrientation(this->getGame()->getPlayer()->getOrientation());
projectile->setPosition(this->getMuzzlePosition());
+
+ //auf 2D Ebene druecken
Vector3 muzzle2D = this->getMuzzleDirection();
muzzle2D.y = 0;
Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h 2017-12-11 14:49:17 UTC (rev 11659)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h 2017-12-11 15:06:44 UTC (rev 11660)
@@ -39,6 +39,8 @@
#include "weapons/WeaponsPrereqs.h"
#include "weapons/weaponmodes/HsW01.h"
+#include "Asteroids2D.h"
+
namespace orxonox
{
class _Asteroids2DExport Asteroids2DWeapon : public HsW01
@@ -46,9 +48,13 @@
public:
Asteroids2DWeapon(Context* context);
virtual ~Asteroids2DWeapon();
+ Asteroids2D* getGame();
+
+
protected:
virtual void shot() override;
WeakPtr<Projectile> projectile;
+ WeakPtr<Asteroids2D> game;
};
}
More information about the Orxonox-commit
mailing list