[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:
parent
8dcd0910f1
commit
79236d805b
2 changed files with 15 additions and 6 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue