Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/3DPacman_FS19/src/modules/pacman/PacmanCyan.cc @ 12320

Last change on this file since 12320 was 12320, checked in by peterf, 5 years ago

began PacmanBrown and Cyan implementation

File size: 2.0 KB
Line 
1#include "PacmanCyan.h"
2//#include "Pacman.h"
3
4#include "core/CoreIncludes.h"
5#include "BulletDynamics/Dynamics/btRigidBody.h"
6
7
8
9        namespace orxonox{
10
11                RegisterClass(PacmanCyan);
12
13                PacmanCyan::PacmanCyan(Context* context) : PacmanGhost(context){
14
15        RegisterObject(PacmanCyan);
16        this->target_x=0;
17        this->target_z=15;
18        this->lastPlayerPassedPoint=Vector3(70,10,-135);
19         
20    }
21
22
23    /**
24    @brief
25        Method for creating a ghost through XML.
26    */
27    void PacmanCyan::XMLPort(Element& xmlelement, XMLPort::Mode mode)
28    {
29        SUPER(PacmanCyan, XMLPort, xmlelement, mode);
30    }
31
32
33
34    void PacmanCyan::tick(float dt)
35    {
36       
37        SUPER(PacmanGhost, tick, dt);
38
39        this->actuelposition = this->getPosition();
40
41
42
43        //Stop, if target arrived
44        if((abs(this->actuelposition.x - this->target_x)<0.5) && (abs(this->actuelposition.z - this->target_z)<0.5)){
45           
46                 this->ismoving = false;
47        }
48
49        //Move, if ghost hasn't arrived yet
50        if(this->ismoving){
51           
52            if(!(abs(this->actuelposition.z-target_z)<0.5)) {
53                velocity = Vector3(0,0,-sgn(this->actuelposition.z-this->target_z));
54                move(dt, actuelposition, velocity);
55            }   
56            if(!(abs(this->actuelposition.x-target_x)<0.5)){
57                velocity = Vector3(-sgn(this->actuelposition.x-this->target_x),0,0);
58                move(dt, actuelposition, velocity);
59            }
60           
61        }
62
63        //Check on which position the ghost has arrived and set new target
64        else{
65
66            while(lockmove){};
67            lockmove = true;
68
69               
70
71            Vector3 cyanPos=Vector3(this->target_x, 10, this->target_z);
72           
73
74
75            lockmove=false; //NEVER FORGET THIS ONE !!!!!!!
76        }
77       
78    }
79
80
81        void PacmanCyan::nextMove( Vector3 cyanPosP, Vector3 playerPos){
82       
83        Vector3 nextTarget;
84
85           nextTarget = getShortestPath(cyanPosP, playerPos);
86       
87           setNewTargetGhost(nextTarget);
88        }
89
90
91}
Note: See TracBrowser for help on using the repository browser.