Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11845


Ignore:
Timestamp:
Apr 1, 2018, 12:12:17 AM (6 years ago)
Author:
dreherm
Message:

Commit and check ghost class

Location:
code/branches/3DPacman_FS18/src/modules/Pacman
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.cc

    r11843 r11845  
    4949        this->localAngularAcceleration_.setValue(1, 1, 1);
    5050
    51         this->velocity.setValue(1, 0, 0);
     51        this->velocity(1, 0, 0);
    5252
    5353        this->setCollisionType(CollisionType::Dynamic);
     
    115115        this->actuelposition = this->getPosition();
    116116       
    117         move();
    118 
    119 
    120         /*
    121 
    122         //Calculate next move
    123 
    124         this->actuelposition = this->getPosition();
    125 
     117        //Stop, if target arrived
    126118        if(((this->actuelposition.x - this->target_x)<0.1) && ((this->actuelposition.z - this->target_z)<0.1)){
    127119                 this->ismoving = false;
    128120        }
    129121
     122        //Move, if ghost hasn't arrived yet
    130123        if(this->ismoving){
    131             if(!((this->actuelposition.z-target_z)<0.1))
    132                 moveFrontBack(sgn(this->actuelposition.z-this->target_z)*dt*100);
    133             if(!((this->actuelposition.x-target_x)<0.1))
    134               moveRightLeft(sgn(this->actuelposition.x-this->target_x)*dt*100); //Assume dt is quite small
     124            if(!((this->actuelposition.z-target_z)<0.1)) {
     125                velocity = Vector3(sgn(this->actuelposition.x-this->target_x),sgn(this->actuelposition.y-this->target_y),sgn(this->actuelposition.z-this->target_z));
     126                move(dt);
     127            }   
     128            if(!((this->actuelposition.x-target_x)<0.1)){
     129                velocity = Vector3(sgn(this->actuelposition.x-this->target_x),sgn(this->actuelposition.y-this->target_y),sgn(this->actuelposition.z-this->target_z));
     130                move(dt);
     131            }
    135132        }
    136        
    137         else{ //Check on which position ghost is
     133
     134        //Check on which position ghost has arrived and set new target
     135         else{
    138136            if(((this->actuelposition.x - possibleposition[0].x)<0.1) && ((this->actuelposition.z - possibleposition[0].z)<0.1)){
    139137                this->target_x = possibleposition[1].x;
     
    149147            } //End of Position table
    150148            }
    151              */
    152     }
    153 
    154 
     149
     150    }
     151
     152
     153
     154    void move(float dt){
     155        this->setPosition(actuelposition+velocity*dt);
     156    }
    155157
    156158
     
    163165    void PacmanGhost::moveFrontBack(const Vector2& value)
    164166    {
    165         this->setPosition(dt*(actuelposition + velocity_));
     167        //this->setPosition(dt*(actuelposition + velocity_));
    166168    }
    167169
  • code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.h

    r11843 r11845  
    5454            virtual void rotatePitch(const Vector2& value);
    5555            virtual void rotateRoll(const Vector2& value);
     56
     57            virtual void move();
    5658           
    5759            //virtual void resetGhost();
     
    140142            Vector3 actuelposition;
    141143            Vector3 velocity;
     144            Vector3 resetposition;
    142145    };
    143146
Note: See TracChangeset for help on using the changeset viewer.