Results 1 to 9 of 9

Thread: Map Editor

  1. #1
    supra s is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default Map Editor (example added)

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

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    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. #3
    supra s is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default

    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 09:22 PM.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

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

    Default

    Quote Originally Posted by Fubarable View Post
    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. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    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. #7
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Talking

    emm...
    an array element ? :rolleyes:
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    @Webuser - What?

  9. #9
    supra s is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by Webuser View Post
    emm...
    an array element ? :rolleyes:
    how do you mean ?

Similar Threads

  1. Design Editor
    By Psyclone in forum NetBeans
    Replies: 5
    Last Post: 02-04-2010, 05:28 PM
  2. Help for a Text Editor.
    By necroninja in forum Advanced Java
    Replies: 0
    Last Post: 08-01-2009, 06:21 PM
  3. Editor for Java
    By peiceonly in forum New To Java
    Replies: 4
    Last Post: 08-13-2008, 09:27 AM
  4. oXygen XML editor 9.3
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 07-11-2008, 03:47 PM
  5. Xml Editor
    By Marty in forum XML
    Replies: 3
    Last Post: 05-11-2007, 10:27 AM

Posting Permissions

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