Changeset 11984 for code/branches/3DPacman_FS18/src
- Timestamp:
- May 24, 2018, 2:25:15 PM (7 years ago)
- Location:
- code/branches/3DPacman_FS18/src/modules/pacman
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
r11979 r11984 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Marc Dreher 24 24 * Co-authors: 25 25 * ... … … 34 34 #include "Pacman.h" 35 35 #include "core/CoreIncludes.h" 36 //Test37 36 38 37 namespace orxonox … … 52 51 void Pacman::levelUp() 53 52 { 53 //Reset each object 54 54 for(PacmanPointSphere* nextsphere : ObjectList<PacmanPointSphere>()){ 55 55 nextsphere->resetPacmanPointSphere(); … … 60 60 } 61 61 62 //Level up ghosts 62 63 for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){ 63 64 nextghost->levelupvelo(); 64 65 } 66 //Reset ghosts and player 65 67 this->posreset(); 66 68 69 //Increase maximum of points and level 67 70 totallevelpoint = ObjectList<PacmanPointSphere>().size() + totallevelpoint; 68 71 level++; … … 77 80 SUPER(Pacman, tick, dt); 78 81 82 //Needed for gameover 79 83 if(deathtime != 0){ 80 84 dead(dt); 81 85 } 82 86 87 //ingame loop 83 88 else{ 84 89 85 if(afraid){86 timer = timer - dt;87 if(timer<=0){88 setNormal();89 }90 }91 92 93 int i = 0;94 for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){95 ghosts[i] = nextghost;96 i++;97 }98 99 player = this->getPlayer(); 100 if (player != nullptr)101 {102 currentPosition = player->getWorldPosition();103 }104 105 106 bcolli = false; 107 for(int nrghost = 0; (nrghost<8) && (!bcolli); ++nrghost){108 bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);109 //orxout() << "GHOST" << nrghost << ghosts[nrghost]->getPosition() << endl;110 }111 112 if(bcolli){ 113 this->catched(dt);114 }115 116 i = 0; 117 for(PacmanPointSphere* nextsphere : ObjectList<PacmanPointSphere>()){118 i f(collis(nextsphere->getPosition(), currentPosition)){119 takePoint(nextsphere);120 }121 }122 123 for(PacmanPointAfraid* next : ObjectList<PacmanPointAfraid>()){ 124 if(next->taken(currentPosition)){125 setAfraid();126 }127 }90 //Register ghosts 91 int i = 0; 92 for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){ 93 ghosts[i] = nextghost; 94 i++; 95 } 96 97 //Switch ghost to not-catchable, if timer is zero 98 if(afraid){ 99 timer = timer - dt; 100 if(timer<=0){ 101 setNormal(); 102 } 103 } 104 105 //Get position of player 106 player = this->getPlayer(); 107 if (player != nullptr) 108 { 109 currentPosition = player->getWorldPosition(); 110 } 111 112 //Check for collision with ghosts 113 bcolli = false; 114 for(int nrghost = 0; (nrghost<8) && (!bcolli); ++nrghost){ 115 bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition); 116 } 117 118 if(bcolli){ 119 this->catched(dt); 120 } 121 122 //Check for collision with PointSpheres and PacmanPointAfraid 123 i = 0; 124 for(PacmanPointSphere* nextsphere : ObjectList<PacmanPointSphere>()){ 125 if(collis(nextsphere->getPosition(), currentPosition)) 126 takePoint(nextsphere); 127 } 128 129 for(PacmanPointAfraid* next : ObjectList<PacmanPointAfraid>()){ 130 if(next->taken(currentPosition)) 131 setAfraid(); 132 } 128 133 129 134 } … … 131 136 } 132 137 133 138 //Check for collisions between to objects (compare float numbers) 134 139 bool Pacman::collis(Vector3 one, Vector3 other){ 135 140 if((abs(one.x-other.x)<10) && (abs(one.y-other.y)<10) && (abs(one.z-other.z)<10)) … … 138 143 } 139 144 145 //Decrease live or resetghost 140 146 void Pacman::catched(float dt){ 141 147 142 if(! afraid) {143 if(! lives){148 if(!this->afraid) { 149 if(!this->lives){ 144 150 deathtime = 5; 145 151 this->dead(dt); … … 150 156 else{ 151 157 for(int nrghost = 0; nrghost<8; ++nrghost){ 152 bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);153 if(bcolli) ghosts[nrghost]->resetGhost();154 bcolli = false;158 bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition); 159 if(bcolli) ghosts[nrghost]->resetGhost(); 160 bcolli = false; 155 161 } 156 162 } 157 163 } 158 164 165 //Change ghost design (to afraid) 159 166 void Pacman::setAfraid(){ 160 167 … … 172 179 } 173 180 181 //Change ghost design (to not afraid) 174 182 void Pacman::setNormal(){ 175 183 … … 185 193 } 186 194 187 bool Pacman::getAfraid(){ 188 return afraid; 189 } 190 191 int Pacman::getTimer(){ 192 return timer; 193 } 194 195 int Pacman::getLevel(){ 196 return level; 197 } 198 195 //Reset ghosts and plazer 199 196 void Pacman::posreset(){ 200 197 for(int i = 0; i<4; ++i){ … … 204 201 } 205 202 203 //Collision with PointSphere 206 204 void Pacman::takePoint(PacmanPointSphere* taken){ 207 205 ++point; … … 210 208 return; 211 209 } 210 //Set PointSphere under map 212 211 Vector3 postaken = taken->getPosition(); 213 212 postaken.y = -50; … … 225 224 } 226 225 226 //Getter 227 bool Pacman::getAfraid(){ 228 return afraid; 229 } 230 //Getter 231 int Pacman::getTimer(){ 232 return timer; 233 } 234 //Getter 235 int Pacman::getLevel(){ 236 return level; 237 } 238 //Getter 227 239 int Pacman::getPoints(){ 228 240 return point; 229 241 } 230 242 //Getter 231 243 int Pacman::getLives(){ 232 244 return lives; 233 245 } 246 //Getter 247 bool Pacman::isdead(){ 248 return death; 249 } 234 250 235 251 … … 238 254 Deathmatch::start(); 239 255 256 //Hide afraided ghosts under map 240 257 int i = 0; 241 258 for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){ … … 247 264 } 248 265 266 //Set maximum of points of first level 249 267 totallevelpoint = ObjectList<PacmanPointSphere>().size(); 250 268 251 }252 253 bool Pacman::isdead(){254 return death;255 269 } 256 270 … … 258 272 death = true; 259 273 274 //if (Highscore::exists()) 275 // Highscore::getInstance().storeScore("3DPacman", this->getPoints(), this->playerInfo_); 276 260 277 deathtime = deathtime-dt; 261 278 … … 266 283 void Pacman::end() 267 284 { 268 269 /*270 if (Highscore::exists())271 {272 //int score = this->getPoints();273 //Highscore::getInstance().storeScore("3DPacman", score, this->playerInfo_);274 }275 */276 285 GSLevel::startMainMenu(); 277 286 } -
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc
r11978 r11984 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Marc Dreher 24 24 * Co-authors: 25 25 * ... … … 47 47 { 48 48 SUPER(PacmanGelb, tick, dt); 49 //bring player back to ground 50 actuelposition = this->getPosition(); 49 actuelposition = this->getPosition(); //bring player back to ground 51 50 actuelposition.y = 10; 52 51 this->setPosition(actuelposition); 53 this->rotatePitch(Vector2(0, 0));54 55 56 52 } 57 53 } -
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.h
r11979 r11984 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Marc Dreher 24 24 * Co-authors: 25 25 * ... … … 52 52 virtual void tick(float dt); 53 53 54 // no rotation54 //allow rotation in horizontal manner 55 55 virtual void rotateYaw(const Vector2& value) override{ 56 56 this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x); 57 58 57 Pawn::rotateYaw(value); 59 60 // This function call adds a lift to the ship when it is rotating to make it's movement more "realistic" and enhance the feeling.61 //if (this->getLocalVelocity().z < 0 && std::abs(this->getLocalVelocity().z) < stallSpeed_)62 //this->moveRightLeft(-lift_ / 5.0f * value * sqrt(std::abs(this->getLocalVelocity().y)));63 58 }; 59 60 //forbid rotation in the vertical (doesn't work totally proper, see documentation) 64 61 virtual void rotatePitch(const Vector2& value) override{}; 65 62 66 63 private: 67 64 Vector3 actuelposition; 68 Quaternion actuelorient;69 65 70 66 };
Note: See TracChangeset
for help on using the changeset viewer.