Created
May 8, 2017 19:54
-
-
Save robertmryan/3a58c5e251a15d30d833113bf7e44cdc 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
| func pillarPlacement(x: CGFloat, y: CGFloat) -> CGPoint { | |
| let pillarX: CGFloat | |
| let pillarY: CGFloat | |
| let random = Int(arc4random_uniform(2)) | |
| if random == 1 { | |
| pillarX = x + 39 | |
| pillarY = y - 29 | |
| } else { | |
| pillarX = x - 40 | |
| pillarY = y - 30 | |
| } | |
| return CGPoint(x: pillarX, y: pillarY) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note, I also replaced
arc4random() % 2witharc4random_uniform(2)as that solves subtle modulo bias problem ofarc4randomwith%operator.