Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 20, 2019, 5:22:51 PM (5 years ago)
Author:
peterf
Message:

Red Pacman seems to work partially

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/3DPacman_FS19/src/modules/pacman/PacmanRed.cc

    r12304 r12316  
    44#include "core/CoreIncludes.h"
    55#include "BulletDynamics/Dynamics/btRigidBody.h"
     6
     7
    68
    79        namespace orxonox{
     
    1214
    1315        RegisterObject(PacmanRed);
     16        this->target_x=0;
     17        this->target_z=15;
     18        this->lastPlayerPassedPoint=Vector3(70,10,-135);
    1419         
    1520    }
     
    2530    }
    2631
     32    /*void PacmanRed::setPlayerPos(Vector3 _playerPos)
     33    {
     34        this->playerPos = _playerPos;
     35    }*/
     36
     37    bool PacmanRed::jeanfindpos(Vector3 one, Vector3 other){
     38       if((abs(one.x - other.x)<15) && (abs(one.y - other.y)<15) && (abs(one.z - other.z)<15)) return true;
     39        return false;
     40        }
     41
    2742    void PacmanRed::tick(float dt)
    2843    {
     
    3045
    3146        this->actuelposition = this->getPosition();
     47
     48        for(int u=0; u < 67; u++){//always check if player passed a point
     49            if(jeanfindpos(this->getPlayerPos(), possibleposition[u])){
     50            this->lastPlayerPassedPoint=possibleposition[u];
     51                    }
     52            }
     53
    3254       
    3355        //Stop, if target arrived
     
    5577
    5678                //do red behavior
     79            //Use target_x and target_z for position of red pacman
    5780
    58             Vector3 purePos = setPureArrayPos(this->actuelposition);
    59             //find nearest position on the map to red pos if pacman does not move,
    60             //i.e. reached a point on the map
    61             //Why not simply use target_x and target_z ??????
     81            Vector3 redPos=Vector3(this->target_x, 10, this->target_z);
     82            //nextMove(this->getPlayerPos(), redPos);
    6283
    63             nextMove(purePos, player.actuelposition);
    64             //how do we access the PLAYER variable ??????
    6584
    66             //also, player.lastPassedPoint is maybe better
     85            if(this->actuelposition!=lastPlayerPassedPoint){
     86                //std::cout<<this->target_x<<" "<<this->target_z<<endl;
     87                std::cout<<redPos<<endl;
     88                std::cout<<this->lastPlayerPassedPoint<<endl;
     89                //getShortestPath(Vector3(-215,10,-195),Vector3(70,10,-135));
     90                //getShortestPath(redPos, lastPlayerPassedPoint);
     91            nextMove(redPos, lastPlayerPassedPoint);
     92            }/*
     93            else{// red pacman is at lastPlayerPassedPoint
     94            nextMove(this->getPlayerPos(), redPos);
     95            }*/
     96
     97            //setNewTargetRed(Vector3(70,10,-85));
     98            //std::cout<<this->target_x<<" "<<target_z<<endl;
     99            //std::cout<<"meuh"<<endl;
     100            //std::cout<<this->actuelposition;
     101
     102            lockmove=false; //NEVER FORGET THIS ONE !!!!!!!
    67103        }
    68104       
     
    78114
    79115
    80         void PacmanRed::nextMove(Vector3 playerPos, Vector3 redPos){
    81                 Vector3 nextTarget;
     116        void PacmanRed::nextMove( Vector3 redPosP, Vector3 playerPos){
     117       
     118        Vector3 nextTarget;
    82119
    83         nextTarget = getShortestPath(playerPos, redPos);
     120           nextTarget = getShortestPath(redPosP, playerPos);
    84121       
    85         setNewTargetRed(nextTarget);
     122           setNewTargetRed(nextTarget);
    86123        }
    87124
Note: See TracChangeset for help on using the changeset viewer.