Skip to content

Commit

Permalink
Fixed enemies and players going off-map
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Jan 23, 2018
1 parent 6182aae commit a85357d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/io/anuke/mindustry/entities/Player.java
Expand Up @@ -186,6 +186,9 @@ public void update(){
float angle = Angles.mouseAngle(x, y);
this.angle = Mathf.lerpAngDelta(this.angle, angle, 0.1f);
}

x = Mathf.clamp(x, 0, Vars.world.width() * Vars.tilesize);
y = Mathf.clamp(y, 0, Vars.world.height() * Vars.tilesize);
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions core/src/io/anuke/mindustry/entities/enemies/EnemyType.java
Expand Up @@ -131,6 +131,9 @@ public void update(Enemy enemy){
}else{
enemy.angle = Mathf.slerp(enemy.angle, enemy.angleTo(enemy.target), turretrotatespeed * Timers.delta());
}

enemy.x = Mathf.clamp(enemy.x, 0, Vars.world.width() * Vars.tilesize);
enemy.y = Mathf.clamp(enemy.y, 0, Vars.world.height() * Vars.tilesize);
}

public void move(Enemy enemy){
Expand Down

0 comments on commit a85357d

Please sign in to comment.