Jump to content

Display Area


Joseph

Recommended Posts

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 by Isolate
Link to comment
Share on other sites

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

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

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...