()
| 1204 | } |
| 1205 | |
| 1206 | playerLanded() { |
| 1207 | |
| 1208 | // if moving down then weve landed |
| 1209 | this.isOnGround = true |
| 1210 | // if were on an ice level then we slide instead |
| 1211 | if (levels[this.currentLevelNo].isIceLevel) { |
| 1212 | this.currentSpeed.y = 0; |
| 1213 | if (this.IsMovingRight()) { |
| 1214 | this.currentSpeed.x -= iceFrictionAcceleration; |
| 1215 | } else { |
| 1216 | this.currentSpeed.x += iceFrictionAcceleration; |
| 1217 | } |
| 1218 | |
| 1219 | } else { |
| 1220 | this.currentSpeed = createVector(0, 0) |
| 1221 | |
| 1222 | } |
| 1223 | |
| 1224 | |
| 1225 | this.isSlidding = false; |
| 1226 | this.hasBumped = false; |
| 1227 | |
| 1228 | if (this.jumpStartingHeight - height / 2 > (height - this.currentPos.y) + height * this.currentLevelNo) { |
| 1229 | this.hasFallen = true; |
| 1230 | } |
| 1231 | |
| 1232 | if (this.GetGlobalHeight() > this.bestHeightReached) { |
| 1233 | this.bestHeightReached = this.GetGlobalHeight(); |
| 1234 | this.reachedHeightAtStepNo = this.brain.currentInstructionNumber; |
| 1235 | |
| 1236 | |
| 1237 | if (this.bestLevelReached < this.currentLevelNo) { |
| 1238 | this.bestLevelReached = this.currentLevelNo; |
| 1239 | this.bestLevelReachedOnActionNo = this.brain.currentInstructionNumber; |
| 1240 | // this.playerStateAtStartOfBestLevel.getStateFromPlayer(this); |
| 1241 | this.getNewPlayerStateAtEndOfUpdate = true; |
| 1242 | |
| 1243 | |
| 1244 | //setup coins |
| 1245 | this.numberOfCoinsPickedUp = 0; |
| 1246 | this.progressionCoinPickedUp = false; |
| 1247 | if(!levels[this.currentLevelNo].hasProgressionCoins){ |
| 1248 | this.progressionCoinPickedUp = true; |
| 1249 | |
| 1250 | } |
| 1251 | this.coinsPickedUpIndexes = []; |
| 1252 | |
| 1253 | |
| 1254 | } |
| 1255 | |
| 1256 | } |
| 1257 | |
| 1258 | // if the ai fell to a previous level then stop the actions and record when it happened |
| 1259 | if (this.currentLevelNo < this.bestLevelReached && this.currentLevelNo !== 23 && !this.hasFinishedInstructions) { |
| 1260 | this.fellToPreviousLevel = true; |
| 1261 | this.fellOnActionNo = this.brain.currentInstructionNumber; |
| 1262 | this.hasFinishedInstructions = true; |
| 1263 |
no test coverage detected