Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
move follow now stops when over player tile and near stop on near tile.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Jan 4, 2017
1 parent 5d0a9c5 commit b40a1a1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ function char(chara, x, y) {
py = Math.floor(this.mapy / 32) + 1;
var moveToDo = this['movstack'].shift();
if (moveToDo[0] == "move") {
if (moveToDo[1] == "follow") {
if (moveToDo[1] == "follow" || moveToDo[1] == "near") {
this.followPlayer()
} else if (moveToDo[1] == "away") {
this.awayPlayer()
Expand All @@ -920,7 +920,16 @@ function char(chara, x, y) {
if (this.checkMapBoundaries(px, py, this.mapwidth, this.mapheight) &&
engine.currentLevel["Level"]["collision"][fpos[0]][fpos[1]] == 0 &&
!(charFacing.nocollision)) {
this.steps = 32

if(moveToDo[1] == "follow" && (px==Math.floor(player.mapx / 32)) && (py== Math.floor(player.mapy / 32) + 1)){
this.waits = 32;
} else if(moveToDo[1] == "near" &&
(px>= Math.floor(player.mapx / 32) -1 && px<= Math.floor(player.mapx / 32) +1) &&
(py>= Math.floor(player.mapy / 32) && py <= Math.floor(player.mapy / 32)+2)){
this.waits = 32;
} else {
this.steps = 32;
}

if ((this.mapx%32==0) && (this.mapy%32==0)) {
//evType [onclick, onover, oncharaover, charaleave], so we are checking charaleave here!
Expand All @@ -933,7 +942,7 @@ function char(chara, x, y) {

}
if (moveToDo[0] == "face") {
if (moveToDo[1] == "follow") {
if (moveToDo[1] == "follow"|| moveToDo[1] == "near") {
this.followPlayer()
} else if (moveToDo[1] == "away") {
this.awayPlayer()
Expand Down

0 comments on commit b40a1a1

Please sign in to comment.