Skip to content

Instantly share code, notes, and snippets.

@Drumsin
Last active June 11, 2022 03:36
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 Drumsin/4913c13dc68f76586a6886835e74cb0b to your computer and use it in GitHub Desktop.
Save Drumsin/4913c13dc68f76586a6886835e74cb0b to your computer and use it in GitHub Desktop.
AoE4 Generated Map Function: Circle Fill
--draws a circle that is filled
--copy and paste code to preview at https://aoe4.app/
local function circleFill(centerCoord, tileCoord, radius)
dx = centerCoord.row - tileCoord.row
dy = centerCoord.col - tileCoord.col
distanceSquared = (dx*dx) + (dy*dy)
return distanceSquared <= radius*radius
end
centerCoord = { row = mapHalfSize, col = mapHalfSize }
radius = 5.25
for row = 1, gridSize do
for col = 1, gridSize do
tileCoord = { row = row, col = col }
if (circleFill(centerCoord, tileCoord, radius)) then
terrainLayoutResult[row][col].terrainType = tt_lake_shallow
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment