Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Created May 8, 2017 19:54
Show Gist options
  • Select an option

  • Save robertmryan/3a58c5e251a15d30d833113bf7e44cdc to your computer and use it in GitHub Desktop.

Select an option

Save robertmryan/3a58c5e251a15d30d833113bf7e44cdc to your computer and use it in GitHub Desktop.
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)
}
@robertmryan

Copy link
Copy Markdown
Author

Note, I also replaced arc4random() % 2 with arc4random_uniform(2) as that solves subtle modulo bias problem ofarc4random with % operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment