Skip to content

Commit

Permalink
Enemy Rocketboots now chases the player when they are close to eachother
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatwi committed Nov 29, 2021
1 parent 024d1a3 commit bd627c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The following are links to documents related to the development and use of the g
- [Google Drive Cache](https://drive.google.com/drive/folders/0By31kDj_eHBcYnlpQjEzZHY4SUU?usp=sharing): All of the folders, including the two above, for files related to _all of my open source projects_ that weren't really appropriate to put in their repositories. There's some other misc RocketTux stuff in here as well.

## Development Checklist
*Last Updated: 2021.11.28*
*Last Updated: 2021.11.29*
This list contains all of the bits and pieces that make up the game. The most current release may not include all of the items that have been checked off. To get the most up to date version, download the Git repository and build it using the builder script (requires BASH in Linux and Windows).

### Main Menu
Expand Down Expand Up @@ -245,9 +245,8 @@ This list contains all of the bits and pieces that make up the game. The most cu
- [x] Enemy: Rocketboots
- [ ] Enemy: Proppy
- [ ] Enemy: Fightly Fish
- [ ] Improve Rocketboots AI
- [x] Improve Rocketboots AI
- [ ] Make Mr. Bomb turn towards Tux when while ticking
- [ ] Move enemies and their AI into a custom class
- [x] Enemy sound effects
- [x] Player loses money when bumping into an enemy
- [x] Visual and sound effects when player loses money
Expand Down
17 changes: 15 additions & 2 deletions src/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,21 @@ RocketTux.Game.prototype = {
this.hop(enemy);
} else if (enemy.flyer){
this.turnAround(enemy, 190);

if (this.game.time.time > this.rbLiftTimer){

var xTo = this.player.body.x - enemy.body.x;
var yTo = this.player.body.y - enemy.body.y;

if (Math.abs(xTo) < 260 && Math.abs(yTo) < 180 ){
// Chase the player
this.game.physics.arcade.moveToObject(enemy, this.player, 30, 800); // enemy, player, fps, milliseconds to reach player

// Face correct direction
if (xTo > 1){
enemy.scale.x = -1;
} else {
enemy.scale.x = 1;
}
} else if (this.game.time.time > this.rbLiftTimer){
var rng = this.roll();
enemy.body.velocity.y = -3 * rng; // Lift off

Expand Down

0 comments on commit bd627c0

Please sign in to comment.