All pastes #192373 Raw Edit

Entity

public java v1 · immutable
·published 2006-10-05 21:44 UTC
rendered paste body
import java.awt.Graphics2D;import java.awt.Image;public class Entity {	private float x;	private float y;	private Image image;	private Map map;	private float ang;	private float size = 0.3f;		public Entity(Image image, Map map, float x, float y) {		this.image = image;		this.map = map;		this.x = x;		this.y = y;	}	public boolean move(float dx, float dy) {		float nx = x + dx;		float ny = y + dy;		if (validLocation(nx, ny)) {			x = nx;			y = ny;			ang = (float) (Math.atan2(dy, dx) - (Math.PI / 5));			return true;		}		return false;	}	public boolean validLocation(float nx, float ny) {		if (map.blocked(nx - size, ny - size)) {			return false;		}		if (map.blocked(nx + size, ny - size)) {			return false;		}		if (map.blocked(nx - size, ny + size)) {			return false;		}		if (map.blocked(nx + size, ny + size)) {			return false;		}		return true;	}		public void paint(Graphics2D g) {		int xp = (int) (Map.TILE_SIZE * x);		int yp = (int) (Map.TILE_SIZE * y);				if (Game.left == true){			g.drawImage(image, (int) (xp - 16), (int) (yp - 16), null);		}		if (bleh.right == true){			g.drawImage(image, (int) (xp - 16), (int) (yp - 16), null);		}		if (bleh.up == true){			g.drawImage(image, (int) (xp - 16), (int) (yp - 16), null);		}		if (bleh.down == true){			g.drawImage(image, (int) (xp - 16), (int) (yp - 16), null);		}				g.drawImage(image, (int) (xp - 16), (int) (yp - 16), null);	}}