Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void renderMap(Player p, MapCanvas c) {
- GameMap gamemap = getGameMap();
- if (gamemap == null)
- return;
- Location l = p.getLocation();
- int x = l.getBlockX() - gamemap.getX();
- int y = l.getBlockZ() - gamemap.getY();
- double rad = Math.toRadians(180 - l.getYaw());
- BufferedImage img = RendererTask.rotatedMap(gamemap.getImage(), x * 2, y * 2, rad);
- Graphics2D g = (Graphics2D) img.getGraphics();
- g.setPaint(java.awt.Color.WHITE);
- GameTeam team = getTeam(p);
- team.getPlayers().stream()
- .filter(teammate -> teammate != p && !getSpectatorsClone().contains(teammate)).forEach(teammate -> {
- Location el = teammate.getLocation();
- MapPosition mp = MapPosition.calculatedPos(l, el, rad);
- g.fillRect(mp.x - 2, mp.y - 2, 4, 4);
- });
- g.setPaint(java.awt.Color.GREEN);
- g.fillRect(62, 62, 4, 4);
- if (team.getRole == Role.TERRORIST) {
- if (bomb != null) {
- Location b = bomb.getLocation();
- if (b != null) {
- MapPosition mp = MapPosition.calculatedPos(l, b, rad);
- g.setPaint(java.awt.Color.RED);
- g.fillRect(mp.x - 2, mp.y - 2, 4, 4);
- }
- }
- }
- c.drawImage(0, 0, img);
- }
- // RenderTask.rotatedMap
- public static BufferedImage rotatedMap(BufferedImage map, int x, int y, double rad) {
- BufferedImage i = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
- if (map == null)
- return i;
- Graphics2D ig2 = (Graphics2D) i.getGraphics();
- AffineTransform at = new AffineTransform();
- at.translate(64 - x, 64 - y);
- at.rotate(rad, x, y);
- ig2.drawImage(map, at, null);
- return i;
- }
- //MapPosition.calculatedPos
- public static MapPosition calculatedPos(Location l, Location el, double rad) {
- int xe = (el.getBlockX() - l.getBlockX()) * 2;
- int ye = (el.getBlockZ() - l.getBlockZ()) * 2;
- int xe1 = (int) (xe * Math.cos(rad) - ye * Math.sin(rad));
- int ye1 = (int) (ye * Math.cos(rad) + xe * Math.sin(rad));
- if (xe1 < -63)
- xe1 = -63;
- if (xe1 > 63)
- xe1 = 63;
- if (ye1 < -63)
- ye1 = -63;
- if (ye1 > 63)
- ye1 = 63;
- xe1 += 64;
- ye1 += 64;
- return new MapPosition(xe1, ye1);
- }
Add Comment
Please, Sign In to add comment