Skip to content

Instantly share code, notes, and snippets.

@techtide
Last active June 22, 2017 14:39
Show Gist options
  • Save techtide/8c33b10e96beb597a38e41cecc7e53b3 to your computer and use it in GitHub Desktop.
Save techtide/8c33b10e96beb597a38e41cecc7e53b3 to your computer and use it in GitHub Desktop.
This was going to be my submission, but in the end, I didn't submit it due to time constraints and exams on the week.
// |-------------|
// |Arman Bhallla|
// | WWDC17 |
// |Scholarship |
// |Submission |
// |-------------|
// Age: 13, Location: London, Passion: Programming.
import UIKit
import PlaygroundSupport
import AVFoundation;
let splashScreenView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 375.0, height: 667.0))
class StartingViewController: UIViewController {
var musicPlayer = AVAudioPlayer()
let bgMusic = Bundle.main.url(forResource: "bgMusic", withExtension: "mp3")
override public func viewDidLoad() {
do {
try musicPlayer = AVAudioPlayer(contentsOf: bgMusic!)
} catch {
// can't play
print("could not play")
}
musicPlayer.prepareToPlay()
musicPlayer.play()
self.ShowIcon()
let deadlineTime = DispatchTime.now() + .seconds(3)
DispatchQueue.main.asyncAfter(deadline: deadlineTime, execute: {
self.ShowInformation()
})
}
public func ShowIcon() -> Void {
let circle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0))
circle.center = CGPoint(x: splashScreenView.frame.width/2, y: splashScreenView.frame.height/2)
circle.layer.cornerRadius = 10.0
let startingColor = UIColor(red: (253.0/255.0), green: (159.0/255.0), blue: (47.0/255.0), alpha: 1.0)
circle.backgroundColor = startingColor
splashScreenView.addSubview(circle);
let rectangle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0))
rectangle.center = splashScreenView.center
rectangle.layer.cornerRadius = 5.0
rectangle.backgroundColor = UIColor.white
splashScreenView.addSubview(rectangle)
splashScreenView.backgroundColor = UIColor(red: 255, green: 231, blue: 76, alpha: 100)
UIView.animate(withDuration: 3.0, animations: { () -> Void in
let endingColor = UIColor(red: (0.0/0.0), green: (60.0/255.0), blue: (24.0/255.0), alpha: 1.0)
circle.backgroundColor = endingColor
let scaleTransform = CGAffineTransform(scaleX: 5.0, y: 5.0)
circle.transform = scaleTransform
let rotationTransform = CGAffineTransform(rotationAngle: 4)
rectangle.transform = rotationTransform
})
}
public func ShowInformation() -> Void {
// Show the name of the game.
let gameNameLabel = UILabel(frame: CGRect(x: splashScreenView.frame.width/2, y: (splashScreenView.frame.height/3), width: 200, height: 30))
gameNameLabel.center = CGPoint(x: (splashScreenView.frame.width/2), y: 500)
gameNameLabel.textAlignment = .center
gameNameLabel.text = "Parabolic"
gameNameLabel.font = UIFont(name:"HelveticaNeue-Bold", size: 32.0)
splashScreenView.addSubview(gameNameLabel)
// Show instructions to begin the game.
let instructionsLabel = UILabel(frame: CGRect(x: splashScreenView.frame.width/2, y: (splashScreenView.frame.height/3), width: splashScreenView.frame.width, height: 30))
instructionsLabel.center = CGPoint(x: (splashScreenView.frame.width/2), y: 525)
instructionsLabel.textAlignment = .center
instructionsLabel.text = "Touch to play. Force touch to learn about me."
instructionsLabel.font = UIFont(name:"HelveticaNeue-Light", size: 16.0)
splashScreenView.addSubview(instructionsLabel)
UIView.animate(withDuration: 1, delay:0.7, options: [.repeat, .autoreverse], animations: {
instructionsLabel.alpha = 1
instructionsLabel.alpha = 0
instructionsLabel.alpha = 1
UIView.setAnimationRepeatCount(4)
})
}
}
PlaygroundPage.current.liveView = splashScreenView
@techtide
Copy link
Author

techtide commented Mar 7, 2017

Day 1 (March 7, 2017): Added splash screen, along with music from https://soundcloud.com/musicelectrohouse/chillout-house-music-vibes. Spent about one hour throughout the day working on the project in total.

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