1
0

Add check for collide missile with opponent turret

This commit is contained in:
Victor 2014-03-16 19:11:35 +02:00
parent 490c03d7b4
commit 11931d3059

View File

@ -35,9 +35,20 @@ public class ShootInfo implements Constants {
return (x < 0) || (x >= Constants.WIDTH) || (y < 0); return (x < 0) || (x >= Constants.WIDTH) || (y < 0);
} }
public boolean isCollideOpponent(boolean server, Terrain tr) {
boolean serverXCheck = server && (x >= WIDTH - PLAYERS_BLOCK_COUNT - 1);
boolean clientXCheck = !server && (x <= PLAYERS_BLOCK_COUNT);
if (serverXCheck || clientXCheck) {
final int opponentY = server ? tr.getLastBlockHeight() : tr.getFirstBlockHeight();
return (Math.abs(y - opponentY) <= 4);
}
return false;
}
public boolean isCollideTerrain(Terrain terrain) { public boolean isCollideTerrain(Terrain terrain) {
return terrain.isCollide((int) x, (int) y); return terrain.isCollide((int) x, (int) y);
} }
private double getDeltaX() { private double getDeltaX() {
return speedX + Math.sin(t) * windSpeed; return speedX + Math.sin(t) * windSpeed;
} }