Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Polygon getPolyRectangle (Tile currTile, int currPart, int totalPart, int tileHeight) {
- if (currPart > totalPart || currPart <= 0)
- return null;
- final Polygon currPolygon = new Polygon();
- for (int i = 0; i < 4; i++) {
- double x = (int) Math.ceil((i % 3)/2), y = ((currPart - ((3 - i)/2))/totalPart);
- if (!Calculations.isPointOnScreen(currTile.toScreen(x, y, tileHeight)));
- return null;
- currPolygon.addPoint(x, y);
- }
- return currPolygon;
- }
- public void draw(final Graphics render, final Color[] colors, final int tileHeight, Tile currTile) {
- if (colors.length <= 1) {
- if (colors.length == 1)
- currTile.draw(render, colors[0], tileHeight);
- else
- currTile.draw(render, Color.WHITE, tileHeight);
- return;
- }
- if (currTile.isOnMap()) {
- final Point p = currTile.toMinimap();
- render.setColor(colors[0]);
- render.drawLine(p.x, p.y, p.x, p.y);
- if (currTile.isOnScreen()) {
- for (int i = 0; i < colors.length; i++) {
- Polygon currPolygon = getPolyRectangle(currTile, i + 1, colors.length, tileHeight);
- if (currPolygon != null) {
- render.drawPolygon(currPolygon);
- render.setColor(colors[i]);
- render.fillPolygon(currPolygon);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment