This file was deleted.

@@ -6,26 +6,103 @@
// Copyright (c) 2015 Matthew Allen Lin. All rights reserved.
//
//Actual game play scene
import SpriteKit

class GameScene: SKScene {
class GamePlayView: SKScene {
var lives: Int = 3

//Restitution == how much energy the physics body loses when it bounces
let basketballRestitution: CGFloat = 0.5
let beachBallRestitution: CGFloat = 0.8
let bowlingBallRestiution: CGFloat = 0.2

let gameLayer = SKNode()
let shapeLayer = SKNode()
let LayerPosition = CGPoint(x: 6, y: -6)

//Add feature to have more balls later
//if(basketball chosen)
let ball = SKSpriteNode(imageNamed: "Basketball.jpg");

//else if(beach ball chosen)
//let ball = SKSpriteNode(imageNamed: "Beach Ball.jpg");
//else
//let ball = SKSpriteNode(imageNamed: "Bowling Ball.jpg");
required init(coder aDecoder: NSCoder) {
fatalError("NSCoder not supported")
}

override init(size: CGSize) {
super.init(size: size)


anchorPoint = CGPoint(x: 0, y: 1.0)

//if forest background chosen
let background = SKSpriteNode(imageNamed: "Forest Background.png")
//else if beach background chosen
// let background = SKSpriteNode(imageNamed: "Beach Background.jpg")
//else
// let background = SKSpriteNode(imageNamed: "Desert Background.jpg")
background.position = CGPoint(x: 0, y: 0)
background.anchorPoint = CGPoint(x: 0, y: 1.0)
addChild(background)

addChild(gameLayer)

let gameBoardTexture = SKTexture(imageNamed: "Beach Background.jpg")

shapeLayer.position = LayerPosition
gameLayer.addChild(shapeLayer)
}

func playSound(sound: String) {
runAction(SKAction.playSoundFileNamed(sound, waitForCompletion: false))
}

override func didMoveToView(view: SKView) {
// we live in a world with gravity on the y axis
self.physicsWorld.gravity = CGVectorMake(0, -6)
// we put contraints on the top, left, right, bottom so that our balls can bounce off them
let physicsBody = SKPhysicsBody (edgeLoopFromRect: self.frame)
// we set the body defining the physics to our scene
self.physicsBody = physicsBody

// SkShapeNode is a primitive for drawing like with the AS3 Drawing API
// it has built in support for primitives like a circle, so we pass a radius
let shape = SKShapeNode(circleOfRadius: 20)
// we set the color and line style
shape.strokeColor = UIColor(red: 255, green: 0, blue: 0, alpha: 0.5)
shape.lineWidth = 4

ball.position = CGPoint(x: size.width * 0.1, y: size.height * 0.5) //Set the ball's position
addChild(ball) //Add ball to the display list
// this is the most important line, we define the body
ball.physicsBody = SKPhysicsBody(circleOfRadius: shape.frame.size.width/2) //Not sure why this needs to be shape???
//if basketball
setPhysicsAttributes(0.3, restitution: basketballRestitution, mass: 0.5)
//else if beach ball
//setPhysicsAttributes(0.3, restitution: beachBallRestitution, mass: 0.5)
//else (bowling ball)
//setPhysicsAttributes(0.3, restitution: bowlingBallRestiution, mass: 0.5)
// this will allow the balls to rotate when bouncing off each other
ball.physicsBody!.allowsRotation = true
}

// this defines the mass, roughness and bounciness
func setPhysicsAttributes(friction: CGFloat, restitution: CGFloat, mass: CGFloat) {
ball.physicsBody!.friction = friction
ball.physicsBody!.restitution = restitution
ball.physicsBody!.mass = mass
}

override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
}

}

//
@@ -10,34 +10,74 @@ import UIKit
import SpriteKit
import AVFoundation

class GameViewController: UIViewController {

var scene: GameScene!

let singleton = PlayStartSong.sharedInstance
class GameViewController: UIViewController, UIGestureRecognizerDelegate {

@IBOutlet weak var GameViewControllerOutlet: GameScene!

var scene: GameScene! = nil

@IBOutlet weak var GamePlayViewOutlet: UIView!


var lives: Int = 3


var song: AVAudioPlayer = AVAudioPlayer()

override func viewDidLoad() {
super.viewDidLoad()

//I am not sure what the code below does
// // Configure the view.
// let skView = view as! SKView
// skView.multipleTouchEnabled = false
//
// // Create and configure the scene.
// scene = GameScene(size: skView.bounds.size)
// scene.scaleMode = .AspectFill
//
// // Present the scene.
// skView.presentScene(scene)
//Plays start song
singleton.prepareAudios()
singleton.song.play()
//I am not sure what the code below does
//Configure the view.
let skView = view as! SKView
skView.multipleTouchEnabled = false

// Create and configure the scene.
scene = GameScene(size: skView.bounds.size)
scene.scaleMode = .AspectFill

// Present the scene.
skView.presentScene(scene)

//Plays gameplay song
prepareAudios()
song.play()
}




override func prefersStatusBarHidden() -> Bool {
return true
}

func prepareAudios() {

var path = NSBundle.mainBundle().pathForResource("gameplay", ofType: "mp3")
song = AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: path!), error: nil)
song.prepareToPlay()

song.numberOfLoops = -1 //Makes the song play repeatedly
}

//UITouchGesture Functions
@IBAction func tapBall(sender: AnyObject) {
//If the user taps ball, make the ball bounce up
}

//Gameplay Functions
func gameDidBegin() {

}

//If game ends, stop player interaction and the gameplay song
func gameDidEnd() -> Bool {
if(lives == 0) {
view.userInteractionEnabled = false
song.stop()
scene.playSound("gameover.mp3")
return true
}
return false
}
}
@@ -0,0 +1,43 @@
//
// TitlePage.swift
// Keepy Uppy
//
// Created by Matthew Allen Lin on 9/5/15.
// Copyright (c) 2015 Matthew Allen Lin. All rights reserved.
//
import UIKit
import SpriteKit
import AVFoundation

class TitlePage: UIViewController {

var scene: GameScene!

let singleton = PlayStartSong.sharedInstance

override func viewDidLoad() {
super.viewDidLoad()

//I am not sure what the code below does
// Configure the view.
let skView = view as! SKView
skView.multipleTouchEnabled = false

// Create and configure the scene.
scene = GameScene(size: skView.bounds.size)
scene.scaleMode = .AspectFill

// Present the scene.
skView.presentScene(scene)

//Plays start song
singleton.prepareAudios()
singleton.song.play()
}

override func prefersStatusBarHidden() -> Bool {
return true
}
}