Changeset 11845 for code/branches
- Timestamp:
- Apr 1, 2018, 12:12:17 AM (7 years ago)
- 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 49 49 this->localAngularAcceleration_.setValue(1, 1, 1); 50 50 51 this->velocity .setValue(1, 0, 0);51 this->velocity(1, 0, 0); 52 52 53 53 this->setCollisionType(CollisionType::Dynamic); … … 115 115 this->actuelposition = this->getPosition(); 116 116 117 move(); 118 119 120 /* 121 122 //Calculate next move 123 124 this->actuelposition = this->getPosition(); 125 117 //Stop, if target arrived 126 118 if(((this->actuelposition.x - this->target_x)<0.1) && ((this->actuelposition.z - this->target_z)<0.1)){ 127 119 this->ismoving = false; 128 120 } 129 121 122 //Move, if ghost hasn't arrived yet 130 123 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 } 135 132 } 136 137 else{ //Check on which position ghost is 133 134 //Check on which position ghost has arrived and set new target 135 else{ 138 136 if(((this->actuelposition.x - possibleposition[0].x)<0.1) && ((this->actuelposition.z - possibleposition[0].z)<0.1)){ 139 137 this->target_x = possibleposition[1].x; … … 149 147 } //End of Position table 150 148 } 151 */ 152 } 153 154 149 150 } 151 152 153 154 void move(float dt){ 155 this->setPosition(actuelposition+velocity*dt); 156 } 155 157 156 158 … … 163 165 void PacmanGhost::moveFrontBack(const Vector2& value) 164 166 { 165 this->setPosition(dt*(actuelposition + velocity_));167 //this->setPosition(dt*(actuelposition + velocity_)); 166 168 } 167 169 -
code/branches/3DPacman_FS18/src/modules/Pacman/PacmanGhost.h
r11843 r11845 54 54 virtual void rotatePitch(const Vector2& value); 55 55 virtual void rotateRoll(const Vector2& value); 56 57 virtual void move(); 56 58 57 59 //virtual void resetGhost(); … … 140 142 Vector3 actuelposition; 141 143 Vector3 velocity; 144 Vector3 resetposition; 142 145 }; 143 146
Note: See TracChangeset
for help on using the changeset viewer.