Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 12, 2018, 4:12:25 PM (6 years ago)
Author:
dreherm
Message:

Moving ghosts

File:
1 edited

Legend:

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

    r11844 r11859  
    2727 */
    2828
    29 #include "PacmanGhost.h"
     29#include "PacmanPointSphere.h"
    3030
    3131#include "core/CoreIncludes.h"
     
    3434namespace orxonox
    3535{
    36     RegisterClass(PacmanGhost);
     36    RegisterClass(PacmanPointSphere);
    3737
    3838    /**
     
    4242        The creator of this object.
    4343    */
    44     PacmanGhost::PacmanGhost(Context* context) : ControllableEntity(context)
     44    PacmanPointSphere::PacmanPointSphere(Context* context) : ControllableEntity(context)
    4545    {
    46         RegisterObject(PacmanGhost);
    47 
    48         this->myController_ = NULL;
    49 
    50         this->localLinearAcceleration_.setValue(0, 0, 0);
    51         this->localAngularAcceleration_.setValue(0, 0, 0);
    52         this->primaryThrust_  = 100;
    53         this->auxiliaryThrust_ = 100;
    54         this->rotationThrust_ = 10;
    55 
    56         this->setCollisionType(CollisionType::Dynamic);
     46        RegisterObject(PacmanPointSphere);
     47        this->setCollisionType(CollisionType::none);
    5748    }
    5849
     
    6152        Destructor. Destroys controller, if present.
    6253    */
    63     PacmanGhost::~PacmanGhost()
     54    PacmanPointSphere::~PacmanPointSphere()
    6455    {
    6556        // Deletes the controller if the object was initialized and the pointer to the controller is not NULL.
    66         if( this->isInitialized() && this->myController_ != NULL )
    67             delete this->myController_;
    6857    }
    6958
     
    7261        Method for creating a AutonomousDrone through XML.
    7362    */
    74     void PacmanGhost::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     63    void PacmanPointSphere::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7564    {
    76         // This calls the XMLPort function of the parent class
    77         SUPER(PacmanGhost, XMLPort, xmlelement, mode);
     65        SUPER(PacmanPointSphere, XMLPort, xmlelement, mode);
    7866
    79         XMLPortParam(PacmanGhost, "primaryThrust", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
    80         // Make sure you add the variables auxiliaryThrust_ and rotationThrust_ to XMLPort.
    81         // Variables can be added by the following command
    82         // XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunctionName, getFunctionName, xmlelement, mode);
    83         // Also make sure that you also create the get- and set-functions in AutonomousDrone.h. As you can see, the get- and set-functions for the variable primaryThrust_ has already been specified there, so you can get your inspiration from there.
     67        XMLPortParam(PacmanPointSphere, "resetposition", setResetPosition, getResetPosition, xmlelement, mode);
    8468    }
    8569
    86     /**
    87     @brief
    88         Defines which actions the AutonomousDrone has to take in each tick.
    89     @param dt
    90         The length of the tick.
    91     */
    92     void PacmanGhost::tick(float dt)
     70
     71    void PacmanPointSphere::tick(float dt)
    9372    {
    9473        SUPER(PacmanGhost, tick, dt);
    95 
    96         this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxiliaryThrust_);
    97         this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxiliaryThrust_);
    98         if (this->localLinearAcceleration_.z() > 0)
    99             this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxiliaryThrust_);
    100         else
    101             this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
    102         this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
    103         this->localLinearAcceleration_.setValue(0, 0, 0);
    104 
    105         this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
    106         this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
    107         this->localAngularAcceleration_.setValue(0, 0, 0);
    108 
    10974    }
    11075
    111     /**
    112     @brief
    113         Moves the AutonomousDrone in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
    114     @param value
    115         The vector determining the amount of the movement.
    116     */
    117     void PacmanGhost::moveFrontBack(const Vector2& value)
     76    bool PacmanPointSphere::taken(Vector3 playerpos)
    11877    {
    119         this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
     78      if((abs(this->resetposition.x - playerpos.x)<0.1) && (abs(this->resetposition.z - playerpos.z)<0.1)){
     79        this->setPosition(Vector3(resetposition.x, -50, resetposition.z));
     80        return true;
     81      }
     82
     83      return false;
    12084    }
    12185
    122     /**
    123     @brief
    124         Moves the AutonomousDrone in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector.
    125     @param value
    126         The vector determining the amount of the movement.
    127     */
    128     void PacmanGhost::moveRightLeft(const Vector2& value)
    129     {
    130         this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
     86
     87    void PacmanPointSphere::resetPacmanPointSphere(){
     88        this->setPosition(resetposition);
    13189    }
    132 
    133     /**
    134     @brief
    135         Moves the AutonomousDrone in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector.
    136     @param value
    137         The vector determining the amount of the movement.
    138     */
    139     void PacmanGhost::moveUpDown(const Vector2& value)
    140     {
    141         this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
    142     }
    143 
    144     /**
    145     @brief
    146         Rotates the AutonomousDrone around the y-axis by the amount specified by the first component of the input 2-dim vector.
    147     @param value
    148         The vector determining the amount of the angular movement.
    149     */
    150     void PacmanGhost::rotateYaw(const Vector2& value)
    151     {
    152         this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
    153     }
    154 
    155     /**
    156     @brief
    157         Rotates the AutonomousDrone around the x-axis by the amount specified by the first component of the input 2-dim vector.
    158     @param value
    159         The vector determining the amount of the angular movement.
    160     */
    161     void PacmanGhost::rotatePitch(const Vector2& value)
    162     {
    163         this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
    164     }
    165 
    166     /**
    167     @brief
    168         Rotates the AutonomousDrone around the z-axis by the amount specified by the first component of the input 2-dim vector.
    169     @param value
    170         The vector determining the amount of the angular movement.
    171     */
    172     void PacmanGhost::rotateRoll(const Vector2& value)
    173     {
    174         this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
    175     }
    176 
    17790}
Note: See TracChangeset for help on using the changeset viewer.