# Object Moving - Grid Based

Get help using Construct 2

### » Thu May 09, 2013 9:41 pm

I want to move , drag and drop, an object in a grid based pattern..need helpDesory2013-05-09 21:42:22
B
3
S
1
Posts: 32
Reputation: 391

### » Fri May 10, 2013 12:26 am

Real easy to do. Just needs a little math. So suppose your grid is based on 16x16 sized squares. So if a block is anywhere from pixel (I'll just be talking about horizontally so the x-axis but the same will apply to the vertical Y-axis) 0-15, it will be in grid 1 and if it is in 16-31, then grid 2 and so on. So lets pick a pixel location say at x position 17. Take that number 17 and divide by the size of your grids which is 16. 17/16 = 1.0625. Now we want to use the floor fuction on that number so the floor(1.0625) = 1. Now multiply your new number 1 by the size of your grid which is...16! And you get 16. So any location from 0-15 will become 0, any location from 16 to 31 will become 16 and so on.

Here's some more math stuff you can play around with.
https://www.scirra.com/manual/126/system-expressions
B
10
S
3
Posts: 102
Reputation: 1,888

### » Fri May 10, 2013 7:54 am

amazing answer thank you really much
B
3
S
1
Posts: 32
Reputation: 391

### » Fri May 10, 2013 8:20 am

can you post an example? maybe i got it wrong mhm dunno how to do it with specific objects e.g. move, and let workers run normally

edit: did it, just seemed like nothing happened, my grid is too small to see something thank you =)
Desory2013-05-10 09:03:18
B
3
S
1
Posts: 32
Reputation: 391

Return to How do I....?

### Who is online

Users browsing this forum: OhhBaby, savvito123 and 19 guests