Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075919 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:21:56 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Block cursor snaps to 16x16 pixels, but can move by camera
Pages: [1]
Print
Author Topic: Block cursor snaps to 16x16 pixels, but can move by camera  (Read 502 times)
SuperDisk
Level 1
*



View Profile Email
« on: September 08, 2013, 03:59:20 PM »

This's got to be one of the dumbest questions I've ever asked, but for some reason I can't figure it out.

I've picked up an old project and occasionally work on it from time to time. I've got a cursor on a grid that will snap to the mouse in 16x16 increments.



Now the problem is, I can pan the camera around using WSAD (Which isn't in 16px increments), but the cursor will still remain attached to the mouse (Even if it's un-aligned with the tiles it's supposed to be over.)

What should I do?
Logged
ThemsAllTook
Moderator
Level 10
******


Alex Diener


View Profile WWW
« Reply #1 on: September 08, 2013, 04:07:34 PM »

Use the camera position as an offset for your grid origin, maybe?
Logged
Xienen
Level 3
***


Greater Good Games


View Profile WWW
« Reply #2 on: September 10, 2013, 10:08:00 AM »

Modulus the camera x and y locations by 16 and then add or subtract that result from your grid.
Logged

SuperDisk
Level 1
*



View Profile Email
« Reply #3 on: September 10, 2013, 03:25:53 PM »

That worked great, Xienen!

I had tried something similar earlier, but I realized my mistake: I was adding the modulus to the position THEN doing ((pos/16)*16) to constrain it to 16.

If you add it afterwards, it works.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic