Last active
September 5, 2015 18:43
-
-
Save kuccello/9c6fefb2df5cac1f9b64 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function roundm(n, m) return math.floor(((n + m - 1)/m))*m end | |
| -- Now we can change the returned value from getRandomPointInCircle to: | |
| function getRandomPointInCircle(radius) | |
| local t = 2*math.pi*math.random() | |
| local u = math.random()+math.random() | |
| local r = nil | |
| if u > 1 then r = 2-u else r = u end | |
| return roundm(radius*r*math.cos(t), tile_size), | |
| roundm(radius*r*math.sin(t), tile_size) | |
| end | |
| function getRandomPointInEllipse(ellipse_width, ellipse_height) | |
| local t = 2*math.pi*math.random() | |
| local u = math.random()+math.random() | |
| local r = nil | |
| if u > 1 then r = 2-u else r = u end | |
| return roundm(ellipse_width*r*math.cos(t)/2, tile_size), | |
| roundm(ellipse_height*r*math.sin(t)/2, tile_size) | |
| end |
Author
Author
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From: http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php