[Orxonox-commit 6999] r11620 - in code/branches/FlappyOrx_HS17: data/levels data/levels/templates src/modules/flappyorx
pascscha at orxonox.net
pascscha at orxonox.net
Sun Dec 3 21:22:33 CET 2017
Author: pascscha
Date: 2017-12-03 21:22:33 +0100 (Sun, 03 Dec 2017)
New Revision: 11620
Modified:
code/branches/FlappyOrx_HS17/data/levels/FlappyOrx.oxw
code/branches/FlappyOrx_HS17/data/levels/templates/spaceshipFlappyOrx.oxt
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h
Log:
XML Port
Modified: code/branches/FlappyOrx_HS17/data/levels/FlappyOrx.oxw
===================================================================
--- code/branches/FlappyOrx_HS17/data/levels/FlappyOrx.oxw 2017-12-03 18:48:35 UTC (rev 11619)
+++ code/branches/FlappyOrx_HS17/data/levels/FlappyOrx.oxw 2017-12-03 20:22:33 UTC (rev 11620)
@@ -35,8 +35,7 @@
<Light type=directional position="11000, 11000, -7000" lookat="0, 0, 0" diffuse="1, 1, 1, 1" specular="1.0, 0.9, 0.9, 1.0" />
<SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=FlappyOrxShip pawndesign=spaceshipFlappyOrx />
-
-
+
<FlappyOrxCenterPoint name=flappyorxcenter />
Modified: code/branches/FlappyOrx_HS17/data/levels/templates/spaceshipFlappyOrx.oxt
===================================================================
--- code/branches/FlappyOrx_HS17/data/levels/templates/spaceshipFlappyOrx.oxt 2017-12-03 18:48:35 UTC (rev 11619)
+++ code/branches/FlappyOrx_HS17/data/levels/templates/spaceshipFlappyOrx.oxt 2017-12-03 20:22:33 UTC (rev 11620)
@@ -18,12 +18,17 @@
linearDamping = 0.7
angularDamping = 0.9999999
- collisiondamage = 100
- enablecollisiondamage = true
+ collisiondamage = 100
+ enablecollisiondamage = true
-
- UpwardThrust = 200
- Gravity = 700
+ speedBase = 100
+ speedIncrease = 2
+ tubeDistanceBase = 300
+ tubeDistanceIncrease = -3
+
+ upwardThrust = 200
+ gravity = 500
+
>
<engines>
<MultiStateEngine position=" 7.6, 0, 6" template=spaceshipFlappyOrxengine />
@@ -31,6 +36,8 @@
</engines>
<attached>
<Model position="0,0,0" yaw=180 pitch=90 roll=270 scale=9 mesh="FlappyOrxShip.mesh" />
+
+ <ParticleSpawner source="Orxonox/fire3" startdelay=0 position="0,0,20" visible="true"/>
</attached>
<collisionShapes>
Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc 2017-12-03 18:48:35 UTC (rev 11619)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc 2017-12-03 20:22:33 UTC (rev 11620)
@@ -33,6 +33,8 @@
#include "FlappyOrx.h"
#include "Highscore.h"
#include "core/CoreIncludes.h"
+
+
#include "core/EventIncludes.h"
#include "core/command/Executor.h"
#include "core/config/ConfigValueIncludes.h"
@@ -44,8 +46,8 @@
#include "infos/PlayerInfo.h"
#include "FlappyOrxCenterPoint.h"
+#include "FlappyOrxAsteroid.h"
#include "FlappyOrxShip.h"
-#include "FlappyOrxAsteroid.h"
#include "core/command/ConsoleCommand.h"
#include "worldentities/ExplosionPart.h"
@@ -62,8 +64,8 @@
point = 0; //number of cleared tubes
bIsDead = true;
firstGame = true; //needed for the HUD
- speed = 0;
- spawnDistance=300; //distance between tubes
+
+ tubeDistance=200; //distance between tubes
tubeOffsetX=500; //tube offset (so that we can't see them spawn)
circlesUsed=0;
@@ -80,7 +82,7 @@
void FlappyOrx::updatePlayerPos(int x){
//Spawn a new Tube when the spawn distance is reached
- if(this->tubes.size()==0||x-tubes.back()+tubeOffsetX>spawnDistance){
+ if(this->tubes.size()==0||x-tubes.back()+tubeOffsetX>tubeDistance){
spawnTube();
this->tubes.push(x+tubeOffsetX);
}
@@ -100,8 +102,8 @@
//Gets called when we pass through a Tube
void FlappyOrx::levelUp(){
point++;
- spawnDistance = spawnDistance-3*point; //smaller spawn Distance
- getPlayer()->setSpeed(this->speed+.5*point); //increase speed
+ tubeDistance = tubeDistanceBase-tubeDistanceIncrease*point; //smaller spawn Distance
+ getPlayer()->setSpeed(speedBase+speedIncrease*point); //increase speed
}
//Returns our Ship
Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h 2017-12-03 18:48:35 UTC (rev 11619)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h 2017-12-03 20:22:33 UTC (rev 11620)
@@ -35,6 +35,7 @@
#define _FlappyOrx_H__
#include "flappyorx/FlappyOrxPrereqs.h"
+
#include "gametypes/Deathmatch.h"
#include <vector>
@@ -94,14 +95,34 @@
FlappyOrxShip* getPlayer();
+ float speedBase;
+ float speedIncrease;
+
+ int tubeDistanceBase;
+ int tubeDistanceIncrease;
+ int tubeDistance;
+ int tubeOffsetX;
+
+ int upwardThrust;
+ int gravity;
+
+ inline void setSpeedBase(int speedBase){ this-> speedBase = speedBase;}
+ inline float getSpeedBase(){ return speedBase;}
+ inline void setSpeedIncrease(int speedIncrease){ this-> speedIncrease = speedIncrease;}
+ inline float getSpeedIncrease(){ return speedIncrease;}
+
+ inline void setTubeDistanceBase(int tubeDistanceBase){ this-> tubeDistanceBase = tubeDistanceBase;}
+ inline int getTubeDistanceBase(){ return tubeDistanceBase;}
+ inline void setTubeDistanceIncrease(int tubeDistanceIncrease){ this-> tubeDistanceIncrease = tubeDistanceIncrease;}
+ inline int getTubeDistanceIncrease(){ return tubeDistanceIncrease;}
+
+
bool bEndGame;
bool bIsDead;
bool firstGame;
std::string sDeathMessage;
- std::queue<int> tubes;
- std::queue<MovableEntity*> asteroids;
- int spawnDistance;
- int tubeOffsetX;
+ std::queue<int> tubes; //Saves Position of Tubes
+ std::queue<MovableEntity*> asteroids; //Stores Asteroids which build up the tubes
float speed = 100;
private:
@@ -135,7 +156,10 @@
"Hey, maybe you get a participation award, that's good isn't it?",
"Congratulations, you get a medal, a wooden one",
"That was flappin bad!",
- "Well, that was a waste of time"};
+ "Well, that was a waste of time",
+ "You suck!",
+ "Maybe try SuperOrxoBros? That game is not as hard.",
+ "Here's a tip: Try not to fly into these grey thingies."};
std::vector<std::string> DeathMessage30 = {
"Getting better!",
"Training has paid off, huh?",
@@ -143,7 +167,8 @@
"That was somehow enjoyable to watch",
"Flappin average",
"Getting closer to something",
- "That wasn't crap, not bad"};
+ "That wasn't crap, not bad",
+ "Surprisingly not bad."};
std::vector<std::string> DeathMessage50 = {
"Flappin great",
"Good job!",
Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc 2017-12-03 18:48:35 UTC (rev 11619)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc 2017-12-03 20:22:33 UTC (rev 11620)
@@ -32,12 +32,10 @@
*/
#include "FlappyOrxShip.h"
-
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
-#include "FlappyOrx.h"
#include "graphics/Camera.h"
-#include "weapons/projectiles/Projectile.h"
+#include "graphics/ParticleSpawner.h"
#include <math.h>
#include <ctime>
@@ -49,25 +47,48 @@
{
RegisterObject(FlappyOrxShip);
- this->UpwardThrust = 1;
- this->speed = 1;
- this->gravity = 1;
+
isDead = true;
deathTime = 0;
+
+ particleLifespan = 0.1;
+ particleAge = 0;
+
+ particlespawner_ = NULL;
}
void FlappyOrxShip::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(FlappyOrxShip, XMLPort, xmlelement, mode);
- XMLPortParam(FlappyOrxShip, "Speed", setSpeed, getSpeed, xmlelement, mode);
- XMLPortParam(FlappyOrxShip, "UpwardThrust", setUpwardThrust, getUpwardThrust, xmlelement, mode);
- XMLPortParam(FlappyOrxShip, "Gravity", setGravity, getGravity, xmlelement, mode);
+ {
+ SUPER(FlappyOrxShip, XMLPort, xmlelement, mode);
+ XMLPortParam(FlappyOrxShip,"speedBase", setSpeedBase, getSpeedBase, xmlelement,mode);
+ XMLPortParam(FlappyOrxShip,"speedIncrease", setSpeedIncrease, getSpeedIncrease, xmlelement,mode);
+ XMLPortParam(FlappyOrxShip,"tubeDistanceBase", setTubeDistanceBase, getTubeDistanceBase, xmlelement,mode);
+ XMLPortParam(FlappyOrxShip,"tubeDistanceIncrease", setTubeDistanceIncrease, getTubeDistanceIncrease, xmlelement,mode);
+
+ XMLPortParam(FlappyOrxShip,"upwardThrust", setUpwardthrust, getUpwardthrust, xmlelement,mode);
+ XMLPortParam(FlappyOrxShip,"gravity", setGravity, getGravity, xmlelement,mode);
}
void FlappyOrxShip::tick(float dt)
{
SUPER(FlappyOrxShip, tick, dt);
+
+
+ particleAge+=dt;
+ //the particle spawner that generates the fire from the backpack when pressed
+ if (particlespawner_ == NULL) {
+ for (WorldEntity* object : this->getAttachedObjects())
+ {
+ if (object->isA(Class(ParticleSpawner)))
+ particlespawner_ = (ParticleSpawner*) object;
+ }
+ }
+ else if(particleAge>particleLifespan){
+ particlespawner_->setLifetime(1);
+ }
+
+
//Execute movement
if (this->hasLocalController())
{
@@ -86,7 +107,7 @@
if(isFlapping){
isFlapping = false;
if(pos.z > -150)
- velocity.y = -UpwardThrust;
+ velocity.y = -upwardThrust;
}
pos += Vector3(speed + velocity.x, 0, velocity.y) * dt;
@@ -121,6 +142,9 @@
void FlappyOrxShip::boost(bool boost){
+ if(not isDead){
+ particleAge = 0;
+ }
if(isDead&&timeUntilRespawn()<=0){
isDead = false;
Modified: code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h
===================================================================
--- code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h 2017-12-03 18:48:35 UTC (rev 11619)
+++ code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h 2017-12-03 20:22:33 UTC (rev 11620)
@@ -38,7 +38,10 @@
#include "weapons/WeaponsPrereqs.h"
#include "worldentities/pawns/SpaceShip.h"
+#include "graphics/ParticleSpawner.h"
+#include "FlappyOrx.h"
+
namespace orxonox
{
class _FlappyOrxExport FlappyOrxShip : public SpaceShip
@@ -48,34 +51,36 @@
virtual void tick(float dt) override;
-
// Starts or stops fireing
virtual void boost(bool bBoost) override;
- //no rotation!
- virtual void rotateYaw(const Vector2& value) override{};
- virtual void rotatePitch(const Vector2& value) override{};
//return to main menu if game has ended.
- //virtual void rotateRoll(const Vector2& value) override;
+ virtual void rotateRoll(const Vector2& value) override;
- inline void setSpeed( float speed ){
- orxout()<< speed<< endl;
- this->speed = speed; }
- inline float getSpeed( )
- { return this->speed; }
- inline void setGravity( float gravity )
- { this->gravity = gravity; }
- inline float getGravity()
- { return this->gravity; }
- inline void setUpwardThrust( float UpwardThrust )
- { this->UpwardThrust = UpwardThrust; }
- inline float getUpwardThrust()
- { return this->UpwardThrust; }
+ inline void setSpeedBase(int speedBase){ getGame()->setSpeedBase(speedBase);}
+ inline float getSpeedBase(){ return getGame()->getSpeedBase();}
+ inline void setSpeedIncrease(int speedIncrease){ getGame()->setSpeedIncrease(speedIncrease);}
+ inline float getSpeedIncrease(){ return getGame()->getSpeedIncrease();}
+
+ inline void setTubeDistanceBase(int tubeDistanceBase){ getGame()->setTubeDistanceBase(tubeDistanceBase);}
+ inline int getTubeDistanceBase(){ return getGame()->getTubeDistanceBase();}
+ inline void setTubeDistanceIncrease(int tubeDistanceIncrease){ getGame()->setTubeDistanceIncrease(tubeDistanceIncrease);}
+ inline int getTubeDistanceIncrease(){ return getGame()->getTubeDistanceIncrease();}
+
+ inline void setUpwardthrust( float upwardThrust ){ this->upwardThrust = upwardThrust; }
+ inline float getUpwardthrust(){ return this->upwardThrust; }
+ inline void setGravity( float gravity ){ this->gravity = gravity; }
+ inline float getGravity(){ return this->gravity; }
+
+ inline void setSpeed( float speed ){ orxout() << "speed set: " << speed << endl; this->speed = speed; }
+ inline float getSpeed( ){ return this->speed; }
+
virtual int timeUntilRespawn();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
protected:
virtual void death() override;
private:
@@ -82,9 +87,11 @@
FlappyOrx* getGame();
WeakPtr<FlappyOrx> game;
Camera* camera;
+ ParticleSpawner* particlespawner_;
bool isFlapping;
bool isDead;
- float speed, UpwardThrust, gravity;
+ float speed, upwardThrust, gravity;
+ float particleAge, particleLifespan;
long deathTime;
struct Velocity
{
More information about the Orxonox-commit
mailing list