Skip to content

Instantly share code, notes, and snippets.

@whilb
Created February 18, 2014 20:46
Show Gist options
  • Save whilb/9079733 to your computer and use it in GitHub Desktop.
Save whilb/9079733 to your computer and use it in GitHub Desktop.
Shows the gist (geddit? XD) of how to draw on a map the players location.
public void drawMap(Player player) {
MapCanvas myCanvas;
int playerX = player.getLocation().getX(); //the 'true' coordinates
int playerZ = player.getLocation().getZ();
/* Assumes that you have a class PartyManager which has a method to get the Party of a player
The Party class has a method called getPlayers(), which returns an ArrayList of players in the party. Simple.
*/
for(Player p : PartyManager.getParty(player).getPlayers()) {
int pX = p.getLocation().getX(); // the 'true' coordinates
int pZ = p.getLocation().getZ();
int pRelativeX = (pX - playerX); // the 'relative' coordinates, using player (the map holder) as 0,0
int pRelativeZ = (pZ - playerZ); // in second thought, I realise that the bottom left corner of the map might be 0,0 , but I'm assuming it's not.
myCanvas.setPixel(pRelativeX, pRelativeZ, 2); //Assuming MapCanvas is set up correctly, I was unable to do so.
}
myRenderer.render(myMapView, myCanvas, player);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment