View difference between Paste ID: dVU4m6xq and MJZ5Teqx
SHOW: | | - or go back to the newest paste.
1-
	public double distance(Location loc) {
1+
	public boolean renderable(Ship object) {
2
		
3-
		int sx = this.getSectorX() - loc.getSectorX();
3+
		double maxRange = getCenterScreen().distance(game.getWidth(), game.getHeight()) / zoom;
4-
		int sy = this.getSectorY() - loc.getSectorY();
4+
		double range = ship.getLocation().distance(object.getLocation()) - (object.getMaxSize()/2);
5
		
6-
		if (Math.abs(sx) > 2) {
6+
		if (range > maxRange)
7-
			return (sx > 0)? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
7+
			return false;
8-
		}
8+
9-
		if (Math.abs(sy) > 2) {
9+
		Point center = getCenterScreen();
10-
			return (sy > 0)? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
10+
		center.x += (object.getLocation().getX() - ship.getLocation().getX())*zoom;
11-
		}
11+
		center.y += (object.getLocation().getY() - ship.getLocation().getY())*zoom;
12
		
13-
		double dx, dy;
13+
		if ((center.x - ((object.getImage().getWidth()*zoom)/2) > game.getWidth())
14-
		double size = sectorXMax - sectorXMin;
14+
			|| (center.x + ((object.getImage().getWidth()*zoom)/2) < 0)
15
			|| (center.y - ((object.getImage().getHeight()*zoom)/2) > game.getHeight())
16-
		dx = Math.pow((((sx * size) + this.getX()) - loc.getX()),2);
16+
			|| (center.y + ((object.getImage().getHeight()*zoom)/2) < 0))
17-
		dy = Math.pow((((sy * size) + this.getY()) - loc.getY()),2);
17+
			return false;
18
		
19-
		return Math.sqrt(Math.abs(dx) + Math.abs(dy));
19+
		object.render(center, zoom);
20
		
21
		return true;
22
		
23
	}