Created
April 14, 2014 17:06
-
-
Save codepaladin/10665797 to your computer and use it in GitHub Desktop.
Allowable Grid Movement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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