Guest User

Untitled

a guest
Oct 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. Polygon getPolyRectangle (Tile currTile, int currPart, int totalPart, int tileHeight) {
  2. if (currPart > totalPart || currPart <= 0)
  3. return null;
  4. final Polygon currPolygon = new Polygon();
  5. for (int i = 0; i < 4; i++) {
  6. double x = (int) Math.ceil((i % 3)/2), y = ((currPart - ((3 - i)/2))/totalPart);
  7. if (!Calculations.isPointOnScreen(currTile.toScreen(x, y, tileHeight)));
  8. return null;
  9. currPolygon.addPoint(x, y);
  10. }
  11. return currPolygon;
  12. }
  13.  
  14. public void draw(final Graphics render, final Color[] colors, final int tileHeight, Tile currTile) {
  15. if (colors.length <= 1) {
  16. if (colors.length == 1)
  17. currTile.draw(render, colors[0], tileHeight);
  18. else
  19. currTile.draw(render, Color.WHITE, tileHeight);
  20. return;
  21. }
  22. if (currTile.isOnMap()) {
  23. final Point p = currTile.toMinimap();
  24. render.setColor(colors[0]);
  25. render.drawLine(p.x, p.y, p.x, p.y);
  26. if (currTile.isOnScreen()) {
  27. for (int i = 0; i < colors.length; i++) {
  28. Polygon currPolygon = getPolyRectangle(currTile, i + 1, colors.length, tileHeight);
  29. if (currPolygon != null) {
  30. render.drawPolygon(currPolygon);
  31. render.setColor(colors[i]);
  32. render.fillPolygon(currPolygon);
  33. }
  34. }
  35. }
  36. }
  37. }
Add Comment
Please, Sign In to add comment