Last active
June 11, 2022 03:36
-
-
Save Drumsin/4913c13dc68f76586a6886835e74cb0b to your computer and use it in GitHub Desktop.
AoE4 Generated Map Function: Circle Fill
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
--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