GM:S 1.4 Need Help with Isometric Cursor Snapping to Grid

Discussion in 'Programming' started by Stoneskull, Dec 4, 2018.

  1. Stoneskull

    Stoneskull Member

    Joined:
    Dec 4, 2018
    Posts:
    2
    Hello! I am trying to make an isometric game in GM 1.4.1804 and I need an object to follow the cursor but have it snap to my isometric grid. So far I have my room's grid snap set to 64px by 32px so I can place objects relatively easily but don't have any code built into the objects themselves. My diamond shaped tiles are 64px wide and 32px tall, so I started off by using move_snap(64,32) but that obviously will cause the object to snap between the tiles on their vertices.

    I have also tried implementing an offset by figuring out what column the tile is in and adjust the height by 32px downward but this just causes more issues. I've been scratching my head for hours now and I'd really appreciate any help I can get! Thank you all in advance! :)
     
  2. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    5,647
  3. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,003
  4. Stoneskull

    Stoneskull Member

    Joined:
    Dec 4, 2018
    Posts:
    2
    Thank you for all of that! It'll be really useful for me :) Although sadly after reading that and trying to apply the formulas I still can't get any farther than before :/ I can get the tile to snap to a grid just find but it will still snap between the isometric tiles and I can't think of how to get it to only snap on the correct places..
     
  5. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,003
    Convert room coordinates to isometric coordinates, snap those to the nearest cell, convert them back to room coordinates.
     

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