# Map Editor

• 06-13-2010, 06:15 PM
supra s
I am currently working on updating a Java game map editor
now i have a small question and hope someone can answer it.

The map editor has the option to modify the height of "1 square"
or "... squares"

if u look at the code below u can see that the only thing the code does is making the squares bigger/lower, but i want when i use the "... squares" that it flaten the selected tiles all at the same height so the landscape becomes flat and not uneven.

(Example: U see 4 bricks, u can even them one by one but that goes slow, so i want to do all 4 bricks at same time )
http://img815.imageshack.us/img815/2916/picu.jpg

*Code -> *

Code:

```    public void mouseDragged(MouseEvent e) {         if(button == MouseEvent.BUTTON2){             xCamAng -= (e.getX()-oldX);             yCamAng += (e.getY()-oldY);             checkVals();         } else if(button == MouseEvent.BUTTON1){             if (height_e){                 int size = (int) Math.sqrt(height_tiles.length);                 for (int x = 0;x < size;x++)                     for (int y = 0;y < size;y++)                         myMap.heightmap[heightLevel][height_tiles[x+y*size].x][height_tiles[x+y*size].y]-=((e.getX()-oldX)*8);                 myMap.addToRenderer(myTerrain);             } else {               myTerrain.setClick(e.getX()+200, e.getY());             }         }         oldX = e.getX();         oldY = e.getY();         repaint();     }```
• 06-13-2010, 08:01 PM
Norm
What's your algorithm for doing it?
Seems like to put all the "bricks" on a horizontal line, find the brick with the largest y value and change the y value for all the other bricks to that value.

Its hard to understand your code with many variables being of unknown types.
• 06-13-2010, 08:12 PM
supra s
Do you think it's possible you give an example ? i'l try to change it into my code

now i use the x++ and the y++ , if you move ur mouse to left or right the height go's lower / higher so there is not realy a 0 point you can go as high or low as you want

so i was thinking like you make a "o" point and when you click a tile it automaticly goes to that point
• 06-13-2010, 08:16 PM
Fubarable
Supra, welcome to the forum. I strongly request that you avoid using non-standard abbreviations such as "u" as for many here, English isn't a 1st or even 2nd language. It's hard enough to understand posts in another language much less one with unusual non-standard abbreviations. So out of respect for those who are trying to help you, please write out all your words. Thanks.

Best of luck, and again, welcome to the forum.
• 06-13-2010, 08:21 PM
supra s
Quote:

Originally Posted by Fubarable
Supra, welcome to the forum. I strongly request that you avoid using non-standard abbreviations such as "u" as for many here, English isn't a 1st or even 2nd language. It's hard enough to understand posts in another language much less one with unusual non-standard abbreviations. So out of respect for those who are trying to help you, please write out all your words. Thanks.

Best of luck, and again, welcome to the forum.

Thank you and that was a writing fault english is not my main langue but i try to write correct i'l change it right away
• 06-13-2010, 08:34 PM
Norm
Where are the x,y values for each brick kept?
For debugging purposes and to make it easier to see what is happening, break this statement up into several statements:
Quote:

myMap.heightmap[heightLevel][height_tiles[x+y*size].x][height_tiles[x+y*size].y]-=((e.getX()-oldX)*8);
For example:
int secDim = height_tiles[x+y*size].x];
int thirdDim = height_tiles[x+y*size].y;
Then use those values as the indexes.

Can you explain what that statement does?
• 06-14-2010, 03:06 AM
Webuser
emm...
an array element ? :rolleyes:
• 06-14-2010, 03:20 AM
Norm
@Webuser - What?
• 06-15-2010, 01:49 PM
supra s
Quote:

Originally Posted by Webuser
emm...
an array element ? :rolleyes:

how do you mean ?