0% found this document useful (0 votes)
95 views2 pages

October 8th

This project uses functions to organize a scene with three bouncing balls (b1, b2, b3) in Xcode. When the view appears, it sets the window title, makes the view with dimensions 800x600, creates a Scene, presents it, and hides the stats. The Scene class contains the balls and its update function automatically draws the background, moves and renders each ball in turn.

Uploaded by

api-437755295
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views2 pages

October 8th

This project uses functions to organize a scene with three bouncing balls (b1, b2, b3) in Xcode. When the view appears, it sets the window title, makes the view with dimensions 800x600, creates a Scene, presents it, and hides the stats. The Scene class contains the balls and its update function automatically draws the background, moves and renders each ball in turn.

Uploaded by

api-437755295
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

October 8th, 2019 Xcode 4.

Project description: I used functions to improve the organization of the project making it easier to
understand.

import Cocoa
import Tin

class ViewController: TController {

//
// viewWillAppear will be called once, just before the view is placed on screen.
//
override func viewWillAppear() {
view.window?.title = "Bounce Objects"
makeView(width: 800.0, height: 600.0)
let scene = Scene()
present(scene: scene)
scene.view?.showStats = false
}

class Scene: TScene {

var b1 = Ball ()
var b2 = Ball ()
var b3 = Ball ()

//
// The update function is called to draw the view automatically.
//
override func update() {
background(gray: 0.5)
b1.move()
b1 . render()

b2 . move()
b2 . render()

b3 .move()
b3 .render()

You might also like