Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

XML Port

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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){
Note: See TracChangeset for help on using the changeset viewer.