()
| 320 | } |
| 321 | |
| 322 | private runGame(): boolean{ |
| 323 | // Variable used to calc the quest speedup later |
| 324 | var questSpeedUp: number = 0; |
| 325 | |
| 326 | // Handle the keys |
| 327 | if(Keyboard.isKeyPressed("down")){ |
| 328 | // We try to make the ship go down |
| 329 | this.shipYPosition += 1; |
| 330 | |
| 331 | // If there's a collision, we revert |
| 332 | if(this.checkCollision()) |
| 333 | this.shipYPosition -= 1; |
| 334 | } |
| 335 | else if(Keyboard.isKeyPressed("up")){ |
| 336 | // We try to make the ship go up |
| 337 | this.shipYPosition -= 1; |
| 338 | |
| 339 | // If there's a collision, we revert |
| 340 | if(this.checkCollision()) |
| 341 | this.shipYPosition += 1; |
| 342 | } |
| 343 | |
| 344 | // Shift asteroids on the left |
| 345 | for(var i = 0; i < this.asteroids.length; i++){ |
| 346 | // If we can shift it, we do so |
| 347 | if(this.asteroids[i].x > 0) |
| 348 | this.asteroids[i].x -= 1; |
| 349 | // Else, we delete it |
| 350 | else{ |
| 351 | this.asteroids.splice(i, 1); |
| 352 | i--; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | // Add asteroids |
| 357 | this.addAsteroids(); |
| 358 | |
| 359 | // Increase the score |
| 360 | this.score = Math.ceil(Math.pow(this.score, 1.00015)); |
| 361 | |
| 362 | // Increase the power |
| 363 | if(this.power < this.maxPower) |
| 364 | this.power += 1; |
| 365 | |
| 366 | // Check the collision of the player with asteroids |
| 367 | if(this.checkCollisionWithAsteroids()) |
| 368 | this.goToLose(); |
| 369 | |
| 370 | return false; |
| 371 | } |
| 372 | |
| 373 | private runSplashScreen(): boolean{ |
| 374 | // If the timer is >= 0 |
no test coverage detected