public MapDisplay( String level, String picpath, String shadowpath, int col, int row, GamePanel p) { tiles = new Vector<Tile>(); parent = (Game) p; loadLevelData(level); control = ImageControl.getInstance(); control.setSourceImage(picpath, col, row); control.setShadowImage(shadowpath, col, row); display = new Rectangle2D.Double(0, 0, parent.getWidth(), parent.getHeight()); }
public void drawVisibleMap(Graphics g) { for (Tile t : tiles) { if (t.intersects(display)) { double dx = t.x - display.getX(); double dy = t.y - display.getY(); g.drawImage((Image) (control.getImageAt(t.getImageNumber())), (int) dx, (int) dy, null); } } }
public Color getColorForPoint(Point p) { for (Tile t : tiles) { double dx = t.x - display.getX(); double dy = t.y - display.getY(); Rectangle temp2 = new Rectangle((int) dx, (int) dy, (int) t.getWidth(), (int) t.getHeight()); if (temp2.contains(p)) { int px = (int) (p.x - dx); int py = (int) (p.y - dy); Color c = new Color( ImageControl.getInstance().getShadowImageAt(t.getImageNumber()).getRGB(px, py)); return c; } } return null; }