Skip to content

Instantly share code, notes, and snippets.

@codepaladin
Created April 14, 2014 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codepaladin/10665797 to your computer and use it in GitHub Desktop.
Save codepaladin/10665797 to your computer and use it in GitHub Desktop.
Allowable Grid Movement
local allowableMoves = 3 -- how many tiles a character can move
local x = 0 --starting x position on a grid
local y = 0 --starting y position on a grid
for xMoves = (x - allowableMoves), (x + allowableMoves) do
for yMoves = (y - allowableMoves), (y + allowableMoves) do
if (math.abs(x - xMoves)) + (math.abs(y - yMoves)) <= allowableMoves then
print(xMoves ..","..yMoves) -- this is an allowable movement grid position
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment