[Metaballs] Randomly position and give velocity to balls when they are added

Add 10 balls to the field on start!
This commit is contained in:
Eryn Wells 2017-08-06 07:48:26 -07:00
parent 8dcd0910f1
commit 79236d805b
2 changed files with 15 additions and 6 deletions

View file

@ -40,7 +40,10 @@ class ViewController: NSViewController, RendererDelegate {
override func viewWillAppear() {
super.viewWillAppear()
renderer.mtkView(metalView, drawableSizeWillChange: metalView.drawableSize)
field.add(ballWithRadius: 10.0)
for _ in 1...10 {
let r = Float(20 + arc4random_uniform(50))
field.add(ballWithRadius: r)
}
}
private func newErrorView() -> NSView {