Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2017, 9:22:33 PM (7 years ago)
Author:
pascscha
Message:

XML Port

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  
    3434#include "Highscore.h"
    3535#include "core/CoreIncludes.h"
     36
     37
    3638#include "core/EventIncludes.h"
    3739#include "core/command/Executor.h"
     
    4547
    4648#include "FlappyOrxCenterPoint.h"
     49#include "FlappyOrxAsteroid.h"
    4750#include "FlappyOrxShip.h"
    48 #include "FlappyOrxAsteroid.h"
    4951
    5052#include "core/command/ConsoleCommand.h"
     
    6365        bIsDead = true;
    6466        firstGame = true;                   //needed for the HUD
    65         speed = 0;
    66         spawnDistance=300;                  //distance between tubes
     67
     68        tubeDistance=200;                  //distance between tubes
    6769        tubeOffsetX=500;                    //tube offset (so that we can't see them spawn)
    6870
     
    8183
    8284        //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){
    8486            spawnTube();
    8587            this->tubes.push(x+tubeOffsetX);
     
    101103    void FlappyOrx::levelUp(){
    102104        point++;
    103         spawnDistance = spawnDistance-3*point;            //smaller spawn Distance
    104         getPlayer()->setSpeed(this->speed+.5*point);    //increase speed
     105        tubeDistance = tubeDistanceBase-tubeDistanceIncrease*point;            //smaller spawn Distance
     106        getPlayer()->setSpeed(speedBase+speedIncrease*point);    //increase speed
    105107    }
    106108
  • code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrx.h

    r11600 r11620  
    3636
    3737#include "flappyorx/FlappyOrxPrereqs.h"
     38   
    3839
    3940#include "gametypes/Deathmatch.h"
     
    9596            FlappyOrxShip* getPlayer();
    9697           
     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           
    97120            bool bEndGame;
    98121            bool bIsDead;
    99122            bool firstGame;
    100123            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
    105126            float speed = 100;
    106127           
     
    136157                "Congratulations, you get a medal, a wooden one",
    137158                "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."};
    139163            std::vector<std::string> DeathMessage30 = {
    140164                "Getting better!",
     
    144168                "Flappin average",
    145169                "Getting closer to something",
    146                 "That wasn't crap, not bad"};
     170                "That wasn't crap, not bad",
     171                "Surprisingly not bad."};
    147172            std::vector<std::string> DeathMessage50 = {
    148173                "Flappin great",
  • code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.cc

    r11600 r11620  
    3333
    3434#include "FlappyOrxShip.h"
    35 
    3635#include "core/CoreIncludes.h"
    3736#include "core/XMLPort.h"
    38 #include "FlappyOrx.h"
    3937#include "graphics/Camera.h"
    40 #include "weapons/projectiles/Projectile.h"
     38#include "graphics/ParticleSpawner.h"
    4139#include <math.h>
    4240#include <ctime>
     
    5048        RegisterObject(FlappyOrxShip);
    5149
    52         this->UpwardThrust = 1;
    53         this->speed = 1;
    54         this->gravity = 1;
     50       
    5551        isDead = true;
    5652        deathTime = 0;
     53
     54        particleLifespan = 0.1;
     55        particleAge = 0;
     56
     57        particlespawner_ = NULL;
    5758       
    5859    }
    5960
    6061    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);
    6671    }
    6772
     
    6974    {
    7075        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
    7192        //Execute movement
    7293        if (this->hasLocalController())
     
    87108                    isFlapping = false;
    88109                    if(pos.z > -150)
    89                         velocity.y = -UpwardThrust;
     110                        velocity.y = -upwardThrust;
    90111                }
    91112
     
    122143    void FlappyOrxShip::boost(bool boost){
    123144
     145        if(not isDead){
     146            particleAge = 0;
     147        } 
    124148   
    125149        if(isDead&&timeUntilRespawn()<=0){
  • code/branches/FlappyOrx_HS17/src/modules/flappyorx/FlappyOrxShip.h

    r11600 r11620  
    3939#include "weapons/WeaponsPrereqs.h"
    4040#include "worldentities/pawns/SpaceShip.h"
     41#include "graphics/ParticleSpawner.h"
     42#include "FlappyOrx.h"
     43
    4144
    4245namespace orxonox
     
    4952            virtual void tick(float dt) override;
    5053
    51            
    5254            // Starts or stops fireing
    5355            virtual void boost(bool bBoost) override;
    5456
    55             //no rotation!
    56             virtual void rotateYaw(const Vector2& value) override{};
    57             virtual void rotatePitch(const Vector2& value) override{};
    5857            //return to main menu if game has ended.
    59             //virtual void rotateRoll(const Vector2& value) override;
     58            virtual void rotateRoll(const Vector2& value) override;
    6059           
    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           
    7478   
    7579            virtual int timeUntilRespawn();
    7680           
    7781            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     82
    7883
    7984        protected:
     
    8388            WeakPtr<FlappyOrx> game;
    8489            Camera* camera;
     90            ParticleSpawner* particlespawner_;
    8591            bool isFlapping;
    8692            bool isDead;
    87             float speed, UpwardThrust, gravity;
     93            float speed, upwardThrust, gravity;
     94            float particleAge, particleLifespan;
    8895            long deathTime;
    8996            struct Velocity
Note: See TracChangeset for help on using the changeset viewer.