Changeset 11620 for code/branches/FlappyOrx_HS17/src/modules
- Timestamp:
- Dec 3, 2017, 9:22:33 PM (7 years ago)
- Location:
- code/branches/FlappyOrx_HS17/src/modules/flappyorx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.cc
r11600 r11620 34 34 #include "Highscore.h" 35 35 #include "core/CoreIncludes.h" 36 37 36 38 #include "core/EventIncludes.h" 37 39 #include "core/command/Executor.h" … … 45 47 46 48 #include "FlappyOrxCenterPoint.h" 49 #include "FlappyOrxAsteroid.h" 47 50 #include "FlappyOrxShip.h" 48 #include "FlappyOrxAsteroid.h"49 51 50 52 #include "core/command/ConsoleCommand.h" … … 63 65 bIsDead = true; 64 66 firstGame = true; //needed for the HUD 65 speed = 0; 66 spawnDistance=300; //distance between tubes67 68 tubeDistance=200; //distance between tubes 67 69 tubeOffsetX=500; //tube offset (so that we can't see them spawn) 68 70 … … 81 83 82 84 //Spawn a new Tube when the spawn distance is reached 83 if(this->tubes.size()==0||x-tubes.back()+tubeOffsetX> spawnDistance){85 if(this->tubes.size()==0||x-tubes.back()+tubeOffsetX>tubeDistance){ 84 86 spawnTube(); 85 87 this->tubes.push(x+tubeOffsetX); … … 101 103 void FlappyOrx::levelUp(){ 102 104 point++; 103 spawnDistance = spawnDistance-3*point; //smaller spawn Distance104 getPlayer()->setSpeed( this->speed+.5*point); //increase speed105 tubeDistance = tubeDistanceBase-tubeDistanceIncrease*point; //smaller spawn Distance 106 getPlayer()->setSpeed(speedBase+speedIncrease*point); //increase speed 105 107 } 106 108 -
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h
r11600 r11620 36 36 37 37 #include "flappyorx/FlappyOrxPrereqs.h" 38 38 39 39 40 #include "gametypes/Deathmatch.h" … … 95 96 FlappyOrxShip* getPlayer(); 96 97 98 float speedBase; 99 float speedIncrease; 100 101 int tubeDistanceBase; 102 int tubeDistanceIncrease; 103 int tubeDistance; 104 int tubeOffsetX; 105 106 int upwardThrust; 107 int gravity; 108 109 inline void setSpeedBase(int speedBase){ this-> speedBase = speedBase;} 110 inline float getSpeedBase(){ return speedBase;} 111 inline void setSpeedIncrease(int speedIncrease){ this-> speedIncrease = speedIncrease;} 112 inline float getSpeedIncrease(){ return speedIncrease;} 113 114 inline void setTubeDistanceBase(int tubeDistanceBase){ this-> tubeDistanceBase = tubeDistanceBase;} 115 inline int getTubeDistanceBase(){ return tubeDistanceBase;} 116 inline void setTubeDistanceIncrease(int tubeDistanceIncrease){ this-> tubeDistanceIncrease = tubeDistanceIncrease;} 117 inline int getTubeDistanceIncrease(){ return tubeDistanceIncrease;} 118 119 97 120 bool bEndGame; 98 121 bool bIsDead; 99 122 bool firstGame; 100 123 std::string sDeathMessage; 101 std::queue<int> tubes; 102 std::queue<MovableEntity*> asteroids; 103 int spawnDistance; 104 int tubeOffsetX; 124 std::queue<int> tubes; //Saves Position of Tubes 125 std::queue<MovableEntity*> asteroids; //Stores Asteroids which build up the tubes 105 126 float speed = 100; 106 127 … … 136 157 "Congratulations, you get a medal, a wooden one", 137 158 "That was flappin bad!", 138 "Well, that was a waste of time"}; 159 "Well, that was a waste of time", 160 "You suck!", 161 "Maybe try SuperOrxoBros? That game is not as hard.", 162 "Here's a tip: Try not to fly into these grey thingies."}; 139 163 std::vector<std::string> DeathMessage30 = { 140 164 "Getting better!", … … 144 168 "Flappin average", 145 169 "Getting closer to something", 146 "That wasn't crap, not bad"}; 170 "That wasn't crap, not bad", 171 "Surprisingly not bad."}; 147 172 std::vector<std::string> DeathMessage50 = { 148 173 "Flappin great", -
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc
r11600 r11620 33 33 34 34 #include "FlappyOrxShip.h" 35 36 35 #include "core/CoreIncludes.h" 37 36 #include "core/XMLPort.h" 38 #include "FlappyOrx.h"39 37 #include "graphics/Camera.h" 40 #include " weapons/projectiles/Projectile.h"38 #include "graphics/ParticleSpawner.h" 41 39 #include <math.h> 42 40 #include <ctime> … … 50 48 RegisterObject(FlappyOrxShip); 51 49 52 this->UpwardThrust = 1; 53 this->speed = 1; 54 this->gravity = 1; 50 55 51 isDead = true; 56 52 deathTime = 0; 53 54 particleLifespan = 0.1; 55 particleAge = 0; 56 57 particlespawner_ = NULL; 57 58 58 59 } 59 60 60 61 void FlappyOrxShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) 61 { 62 SUPER(FlappyOrxShip, XMLPort, xmlelement, mode); 63 XMLPortParam(FlappyOrxShip, "Speed", setSpeed, getSpeed, xmlelement, mode); 64 XMLPortParam(FlappyOrxShip, "UpwardThrust", setUpwardThrust, getUpwardThrust, xmlelement, mode); 65 XMLPortParam(FlappyOrxShip, "Gravity", setGravity, getGravity, xmlelement, mode); 62 { 63 SUPER(FlappyOrxShip, XMLPort, xmlelement, mode); 64 XMLPortParam(FlappyOrxShip,"speedBase", setSpeedBase, getSpeedBase, xmlelement,mode); 65 XMLPortParam(FlappyOrxShip,"speedIncrease", setSpeedIncrease, getSpeedIncrease, xmlelement,mode); 66 XMLPortParam(FlappyOrxShip,"tubeDistanceBase", setTubeDistanceBase, getTubeDistanceBase, xmlelement,mode); 67 XMLPortParam(FlappyOrxShip,"tubeDistanceIncrease", setTubeDistanceIncrease, getTubeDistanceIncrease, xmlelement,mode); 68 69 XMLPortParam(FlappyOrxShip,"upwardThrust", setUpwardthrust, getUpwardthrust, xmlelement,mode); 70 XMLPortParam(FlappyOrxShip,"gravity", setGravity, getGravity, xmlelement,mode); 66 71 } 67 72 … … 69 74 { 70 75 SUPER(FlappyOrxShip, tick, dt); 76 77 78 particleAge+=dt; 79 //the particle spawner that generates the fire from the backpack when pressed 80 if (particlespawner_ == NULL) { 81 for (WorldEntity* object : this->getAttachedObjects()) 82 { 83 if (object->isA(Class(ParticleSpawner))) 84 particlespawner_ = (ParticleSpawner*) object; 85 } 86 } 87 else if(particleAge>particleLifespan){ 88 particlespawner_->setLifetime(1); 89 } 90 91 71 92 //Execute movement 72 93 if (this->hasLocalController()) … … 87 108 isFlapping = false; 88 109 if(pos.z > -150) 89 velocity.y = - UpwardThrust;110 velocity.y = -upwardThrust; 90 111 } 91 112 … … 122 143 void FlappyOrxShip::boost(bool boost){ 123 144 145 if(not isDead){ 146 particleAge = 0; 147 } 124 148 125 149 if(isDead&&timeUntilRespawn()<=0){ -
code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h
r11600 r11620 39 39 #include "weapons/WeaponsPrereqs.h" 40 40 #include "worldentities/pawns/SpaceShip.h" 41 #include "graphics/ParticleSpawner.h" 42 #include "FlappyOrx.h" 43 41 44 42 45 namespace orxonox … … 49 52 virtual void tick(float dt) override; 50 53 51 52 54 // Starts or stops fireing 53 55 virtual void boost(bool bBoost) override; 54 56 55 //no rotation!56 virtual void rotateYaw(const Vector2& value) override{};57 virtual void rotatePitch(const Vector2& value) override{};58 57 //return to main menu if game has ended. 59 //virtual void rotateRoll(const Vector2& value) override;58 virtual void rotateRoll(const Vector2& value) override; 60 59 61 inline void setSpeed( float speed ){ 62 orxout()<< speed<< endl; 63 this->speed = speed; } 64 inline float getSpeed( ) 65 { return this->speed; } 66 inline void setGravity( float gravity ) 67 { this->gravity = gravity; } 68 inline float getGravity() 69 { return this->gravity; } 70 inline void setUpwardThrust( float UpwardThrust ) 71 { this->UpwardThrust = UpwardThrust; } 72 inline float getUpwardThrust() 73 { return this->UpwardThrust; } 60 inline void setSpeedBase(int speedBase){ getGame()->setSpeedBase(speedBase);} 61 inline float getSpeedBase(){ return getGame()->getSpeedBase();} 62 inline void setSpeedIncrease(int speedIncrease){ getGame()->setSpeedIncrease(speedIncrease);} 63 inline float getSpeedIncrease(){ return getGame()->getSpeedIncrease();} 64 65 inline void setTubeDistanceBase(int tubeDistanceBase){ getGame()->setTubeDistanceBase(tubeDistanceBase);} 66 inline int getTubeDistanceBase(){ return getGame()->getTubeDistanceBase();} 67 inline void setTubeDistanceIncrease(int tubeDistanceIncrease){ getGame()->setTubeDistanceIncrease(tubeDistanceIncrease);} 68 inline int getTubeDistanceIncrease(){ return getGame()->getTubeDistanceIncrease();} 69 70 inline void setUpwardthrust( float upwardThrust ){ this->upwardThrust = upwardThrust; } 71 inline float getUpwardthrust(){ return this->upwardThrust; } 72 inline void setGravity( float gravity ){ this->gravity = gravity; } 73 inline float getGravity(){ return this->gravity; } 74 75 inline void setSpeed( float speed ){ orxout() << "speed set: " << speed << endl; this->speed = speed; } 76 inline float getSpeed( ){ return this->speed; } 77 74 78 75 79 virtual int timeUntilRespawn(); 76 80 77 81 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 82 78 83 79 84 protected: … … 83 88 WeakPtr<FlappyOrx> game; 84 89 Camera* camera; 90 ParticleSpawner* particlespawner_; 85 91 bool isFlapping; 86 92 bool isDead; 87 float speed, UpwardThrust, gravity; 93 float speed, upwardThrust, gravity; 94 float particleAge, particleLifespan; 88 95 long deathTime; 89 96 struct Velocity
Note: See TracChangeset
for help on using the changeset viewer.