Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Finding the tile size of a grid?

Author
Message
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 3rd Jul 2010 17:41
I have a 9x9 grid here is the code for it,



How do I find out the size of each individual tile? I need to create a snap to tile function. I have placed my entire code if you need it.



Thanks!
Zeus

Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Jul 2010 20:42
Hi Zeus,

I noticed you decided to go with the vector approach I showed.

To snap to the grid, you first have to round off the relative coordinates in that grid:



Afterwards, you recalculate the position using the base vectors:


Afterwards, vector 3 will hold the position on the screen.

On a side note, you might want to use a UDT to make it more understandable though. The 2 temporary vectors make it quite hard to understand.

Cheers!
Sven B

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 3rd Jul 2010 23:12
Thanks Sven B, that really comes in handy.

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 4th Jul 2010 08:02 Edited at: 4th Jul 2010 08:04
It is still not snapping to the inside of the tile, it is snapping to the outside lines...

Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 4th Jul 2010 22:38
Then use



instead for the snap values.

Greets,
Sven

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 4th Jul 2010 23:30
Thanks Sven B! That was the last question I swear.

Login to post a reply

Server time is: 2025-06-06 16:00:35
Your offset time is: 2025-06-06 16:00:35