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; }