Is grid movement possible in microscript/studio
I've been trying to make grid movement code without much success. I also tryed searching but didnt find code about grid movement for microscript/studio. Any help would be appreciated.
I've been trying to make grid movement code without much success. I also tryed searching but didnt find code about grid movement for microscript/studio. Any help would be appreciated.
update = function()
gridx = floor(touch.x / grid) * grid
gridy = floor(touch.y / grid) * grid
end
draw = function()
screen.clear()
screen.fillRect(gridx, gridy, 50, 50, "white")
end
As an example, let's say grid is 50 and touch.x is 155. 155/50 = 3.1. The floor function returns the value rounded down to the lower integer. So floor(155/50)=floor(3.1)=3. 3 * 50 = 150 so gridx will be 150.