Joseph Posted September 23, 2014 Share Posted September 23, 2014 How would some display an area? im not talking about getting all position in an area and displaying them all out. I want like the outline of the area. Link to comment Share on other sites More sharing options...
Isolate Posted September 23, 2014 Share Posted September 23, 2014 (edited) How would some display an area? im not talking about getting all position in an area and displaying them all out. I want like the outline of the area. Sorry if this is wrong, had < 5 to do it. you get the gist though... fix and use: Position[] areaBounds(Position tile1, Position tile2){ List<Position> tiles = new LinkedList<Position>(); //TOP if(tile1.getX() > tile2.getX()){ for(int i = tile1.getX(); i != tile2.getX(); i--){ tiles.add(new Position(i, tile1.getY(), tile1.getZ())); } }else if(tile1.getX() < tile2.getX()){ for(int i = tile1.getX(); i != tile2.getX(); i++){ tiles.add(new Position(i, tile1.getY(), tile1.getZ())); } } //Side 1 if(tile1.getY() > tile2.getY()){ for(int i = tile1.getY(); i != tile2.getY(); i--){ tiles.add(new Position(tile1.getX(), i, tile1.getZ())); } }else if(tile1.getY() < tile2.getY()){ for(int i = tile1.getY(); i != tile2.getY(); i++){ tiles.add(new Position(tile1.getX(), i, tile1.getZ())); } } //side 2 if(tile2.getY() > tile1.getY()){ for(int i = tile2.getY(); i != tile1.getX(); i--){ tiles.add(new Position(tile2.getX(), i, tile2.getZ())); } }else if(tile2.getY() < tile1.getY()){ for(int i = tile2.getY(); i != tile1.getX(); i++){ tiles.add(new Position(tile2.getX(), i, tile2.getZ())); } } //bottom if(tile2.getX() > tile1.getX()){ for(int i = tile2.getX(); i != tile1.getX(); i--){ tiles.add(new Position(i, tile1.getY(), tile1.getZ())); } }else if(tile2.getX() < tile1.getX()){ for(int i = tile2.getX(); i != tile1.getX(); i++){ tiles.add(new Position(tile2.getX(), i, tile2.getZ())); } } //convert list to array, return array or convert constructor to list return null; } Edited September 23, 2014 by Isolate Link to comment Share on other sites More sharing options...
Isolate Posted September 23, 2014 Share Posted September 23, 2014 Ffs, editing post on my phone just fucked up te formattiñg, I'll be home in two hours to fix Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 23, 2014 Share Posted September 23, 2014 I swear people don't know how to use arrays and resort to lists for everything. Link to comment Share on other sites More sharing options...
Botre Posted September 23, 2014 Share Posted September 23, 2014 I swear people don't know how to use arrays and resort to lists for everything. Don't hate, illuminate. 1 Link to comment Share on other sites More sharing options...
Joseph Posted September 23, 2014 Author Share Posted September 23, 2014 Sorry if this is wrong, had < 5 to do it. you get the gist though... fix and use: Position[] areaBounds(Position tile1, Position tile2){ List<Position> tiles = new LinkedList<Position>(); //TOP if(tile1.getX() > tile2.getX()){ for(int i = tile1.getX(); i != tile2.getX(); i--){ tiles.add(new Position(i, tile1.getY(), tile1.getZ())); } }else if(tile1.getX() < tile2.getX()){ for(int i = tile1.getX(); i != tile2.getX(); i++){ tiles.add(new Position(i, tile1.getY(), tile1.getZ())); } } //Side 1 if(tile1.getY() > tile2.getY()){ for(int i = tile1.getY(); i != tile2.getY(); i--){ tiles.add(new Position(tile1.getX(), i, tile1.getZ())); } }else if(tile1.getY() < tile2.getY()){ for(int i = tile1.getY(); i != tile2.getY(); i++){ tiles.add(new Position(tile1.getX(), i, tile1.getZ())); } } //side 2 if(tile2.getY() > tile1.getY()){ for(int i = tile2.getY(); i != tile1.getX(); i--){ tiles.add(new Position(tile2.getX(), i, tile2.getZ())); } }else if(tile2.getY() < tile1.getY()){ for(int i = tile2.getY(); i != tile1.getX(); i++){ tiles.add(new Position(tile2.getX(), i, tile2.getZ())); } } //bottom if(tile2.getX() > tile1.getX()){ for(int i = tile2.getX(); i != tile1.getX(); i--){ tiles.add(new Position(i, tile1.getY(), tile1.getZ())); } }else if(tile2.getX() < tile1.getX()){ for(int i = tile2.getX(); i != tile1.getX(); i++){ tiles.add(new Position(tile2.getX(), i, tile2.getZ())); } } //convert list to array, return array or convert constructor to list return null; } What it looks like your creating an outline with position for the area are you not?Return tiles.toArray(new Position[tiles.size()]); // I did this on my phone so bare with me Link to comment Share on other sites More sharing options...
Isolate Posted September 24, 2014 Share Posted September 24, 2014 What it looks like your creating an outline with position for the area are you not? Return tiles.toArray(new Position[tiles.size()]); // I did this on my phone so bare with me I thought that's what you wanted? I swear people don't know how to use arrays and resort to lists for everything. Feels easier. Link to comment Share on other sites More sharing options...
Joseph Posted September 24, 2014 Author Share Posted September 24, 2014 I thought that's what you wanted? Feels easier. It's a nice idea but i was looking for like a complete outline of the area not like many different position that creates a rectangle. Do you get me, like find the corner of the two position and draw one large rectangle off two points Link to comment Share on other sites More sharing options...
Isolate Posted September 24, 2014 Share Posted September 24, 2014 It's a nice idea but i was looking for like a complete outline of the area not like many different position that creates a rectangle. Do you get me, like find the corner of the two position and draw one large rectangle off two points Oh I seee. would be same result though no? Link to comment Share on other sites More sharing options...
FrostBug Posted September 25, 2014 Share Posted September 25, 2014 (edited) PositionPolygon pp = new PositionPolygon(area.getMinX(), area.getMinY(), area.getMaxX(), area.getMaxY()); graphics.draw(pp.toGeometricArea()); Edited September 25, 2014 by FrostBug 2 Link to comment Share on other sites More sharing options...
Joseph Posted September 25, 2014 Author Share Posted September 25, 2014 PositionPolygon pp = new PositionPolygon(area.getMinX(), area.getMinY(), area.getMaxX(), area.getMaxY()); graphics.draw(pp.toGeometricArea()); Is it really that easy Link to comment Share on other sites More sharing options...