1. Member
Join Date
Jun 2010
Posts
4
Rep Power
0

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 )

*Code -> *

Java 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);
} else {
myTerrain.setClick(e.getX()+200, e.getY());
}
}
oldX = e.getX();
oldY = e.getY();
repaint();
}```
Last edited by supra s; 06-13-2010 at 07:35 PM.

2. 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.

3. Member
Join Date
Jun 2010
Posts
4
Rep Power
0
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
Last edited by supra s; 06-13-2010 at 08:22 PM.

4. 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.

5. Member
Join Date
Jun 2010
Posts
4
Rep Power
0
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

6. 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:
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?

7. Senior Member
Join Date
Dec 2008
Posts
526
Rep Power
0
emm...
an array element ? :rolleyes:

8. @Webuser - What?

9. Member
Join Date
Jun 2010
Posts
4
Rep Power
0
Originally Posted by Webuser
emm...
an array element ? :rolleyes:
how do you mean ?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•