0 Replies - 7260 Views - Last Post: 26 April 2012 - 03:21 PM Rate Topic: -----

#1 jot121  Icon User is offline

  • D.I.C Head

Reputation: -8
  • View blog
  • Posts: 144
  • Joined: 30-October 11

Grid World saying this in less code

Posted 26 April 2012 - 03:21 PM

Location loc = getLocation();
		Location loc1 = loc.getAdjacentLocation(Location.NORTH);
		Location loc2 = loc1.getAdjacentLocation(Location.NORTH);
		
		Location loc3 = loc.getAdjacentLocation(Location.EAST);
		Location loc4 = loc1.getAdjacentLocation(Location.EAST);
		
		Location loc5 = loc.getAdjacentLocation(Location.WEST);
		Location loc6 = loc1.getAdjacentLocation(Location.WEST);
		
		Location loc7 = loc.getAdjacentLocation(Location.SOUTH);
		Location loc8 = loc1.getAdjacentLocation(Location.SOUTH);
		
		Location loc9 = loc.getAdjacentLocation(Location.NORTHEAST);
		Location loc10 = loc1.getAdjacentLocation(Location.NORTHEAST);
		
		Location loc11 = loc.getAdjacentLocation(Location.NORTHWEST);
		Location loc12 = loc1.getAdjacentLocation(Location.NORTHWEST);
		
		Location loc13 = loc.getAdjacentLocation(Location.SOUTHEAST);
		Location loc14 = loc1.getAdjacentLocation(Location.SOUTHEAST);
		
		Location loc15 = loc.getAdjacentLocation(Location.SOUTHWEST);
		Location loc16 = loc.getAdjacentLocation(Location.SOUTHWEST);


ok I want to say something like this that if there is something two cell around it remove it. i am fine with removing it and the code that I wrote above works but it is just a little too much. is there a shorter way of writing the same thing above?

This post has been edited by jot121: 26 April 2012 - 03:22 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1