So, I want to make a level editor for my game, and future projects, however the first problem I have is making the mouse's position snap to a set grid (such as 32x32 tiles).
Thanks a bunch,
-redsled
EDIT
Found the solution here: viewtopic.php?f=3&t=14743
Sorry
How to make object snap to grid with mouse's positions?
Re: How to make object snap to grid with mouse's positions?
ive used the following helper function in many of my code dealings:
Code: Select all
--
-- Snaps a source x,y position to a grid based on grid x width and grid y width
--
function snapToGrid(SOURCE_X, SOURCE_Y, GRID_X, GRID_Y)
local x = math.floor((SOURCE_X / GRID_X) +0.5) * GRID_X
local y = math.floor((SOURCE_Y / GRID_Y) +0.5) * GRID_Y
return x, y
end
Who is online
Users browsing this forum: Bing [Bot] and 9 guests