public void paint(Graphics g) { int spriteWidth = sprite.getHeight(null); int spriteHeight = sprite.getWidth(null); /* Center it, by moving the sprite halfway up and halfway left */ int renderX = loc.x() - spriteWidth / 2; int renderY = loc.y() - spriteHeight / 2; g.drawImage(sprite, renderX, renderY, null); }
public ArrayList<Location> vertices() { ArrayList<Location> vertices = new ArrayList<Location>(); int mapID = loc.mapID(); int x = loc.x(); int y = loc.y(); // topleft, topright, bottomleft, bottomright vertices.add(new Location(mapID, x - radius, y - radius)); vertices.add(new Location(mapID, x - radius, y + radius)); vertices.add(new Location(mapID, x + radius, y - radius)); vertices.add(new Location(mapID, x + radius, y + radius)); return vertices; }
public Entity(Location l) { id = numCharacters++; loc = l.copy(); sprite = GFX.getSprite(3); name = "" + id; tile().add(this); System.err.println("Spawning Entity " + name + " at " + loc); }
public Tile tile() { return loc.tile(); }