1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 How to do Inner Tileset Corners.

Discussion in 'Programming' started by Oliver Melroy, Dec 1, 2019.

  1. Oliver Melroy

    Oliver Melroy Member

    Joined:
    Nov 11, 2019
    Posts:
    9
    Hey! I am currently working on a project, and I watched this video [] on how to make AutoTiling on objects. This video shows how to do the outsides, but not the insides of the Tiles (As in the inner corners). The code will be down below for the autoTiling script, any help is appreciated. I also asked in the comments a few weeks ago, with no answer, so I came here. Thanks!

    P.S: The image below can help with the code.


    AutoTiling Script:
    WR = Tile right side
    WL = Tile left side
    WU = Tile top
    WD = Tile bottom
    Code:
    BS = sprite_width;        //Base Size
    image_speed = 0;
    
    WR = position_meeting(x + BS, y, oDirt);
    WL = position_meeting(x - BS, y, oDirt);
    WU = position_meeting(x, y - BS, oDirt);
    WD = position_meeting(x, y + BS, oDirt);
    
    if (!WL and !WU and !WD and !WR)
        image_index = 0;
    else if (!WL and !WU and WR and WD)
        image_index = 1;
    else if (WR and WL and !WU and WD)
        image_index = 2;
    else if (WL and WD and !WR and !WU)
        image_index = 3;
    else if (!WR and WL and WU and WD)
        image_index = 4;
    else if (WU and WL and !WR and !WD)
        image_index = 5;
    else if (WL and WR and WU and !WD)
        image_index = 6;
    else if (!WL and !WD and WU and WR)
        image_index = 7;
    else if (!WL and WU and WD and WR)
        image_index = 8;
    else if (WL and WR and WD and WU)
        image_index = 9;
    else if (!WL and !WU and !WD and WR)
        image_index = 10;
    else if (WL and !WU and !WD and WR)
        image_index = 11;
    else if (WL and !WU and !WD and !WR)
        image_index = 12;
    else if (!WL and !WU and !WR and WD)
        image_index = 13;
    else if (!WL and !WR and WU and WD)
        image_index = 14;
    else if (!WL and !WR and !WD and WU)
        image_index = 15;
    Also here is the image of the tiles with helpful info:
    [​IMG]

    Original Tileset:
    [​IMG]
     
  2. Oliver Melroy

    Oliver Melroy Member

    Joined:
    Nov 11, 2019
    Posts:
    9
    Sorry for the huge image
     
  3. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    76
    You simply need to expand on this part:
    Code:
        image_index = 9;
    in that section, check the diagonal tiles.
     
  4. Oliver Melroy

    Oliver Melroy Member

    Joined:
    Nov 11, 2019
    Posts:
    9
    So how could I do that exactly (Sorry for asking, I am not the best at gml)
     
  5. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    76
    Well, you add or subtract the BS to find the horizontal and diagonal
    Code:
    WR = position_meeting(x + BS, y, oDirt);
    so now you just need to do it with both coordinates
    Code:
    WRU = position_meeting(x + BS, y - BS, oDirt);
    So it would be something like:
    Code:
    else if (WL and WR and WD and WU){
       WRU = position_meeting(x + BS, y - BS, oDirt);
       WRD = position_meeting(x + BS, y + BS, oDirt);
    
        if( !WRU ) image_index = 18; else
        if( !WRD ) image_index =16; else
       image_index = 9;
    }else if (!WL and !WU and !WD and WR)
    then you just need to add the last 2
     
    Oliver Melroy likes this.
  6. Oliver Melroy

    Oliver Melroy Member

    Joined:
    Nov 11, 2019
    Posts:
    9
    Alright thanks for your help!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice