Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
388 changes: 388 additions & 0 deletions Contained/Contained.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Contained.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
37 changes: 37 additions & 0 deletions Contained/Contained/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// AppDelegate.swift
// Contained
//
// Created by Cora Jacobson on 6/2/20.
// Copyright © 2020 Cora Jacobson. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Contained/Contained/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "game_controller.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "game_controller@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "game_controller@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Contained/Contained/Assets.xcassets/info.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "info.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "info@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "info@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "settings.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "settings@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "settings@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Contained/Contained/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
85 changes: 85 additions & 0 deletions Contained/Contained/CustomScene.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// CustomScene.swift
// Contained
//
// Created by Cora Jacobson on 6/3/20.
// Copyright © 2020 Cora Jacobson. All rights reserved.
//

import Foundation

import SpriteKit

class CustomScene: SKScene {
let crab = SKSpriteNode()

// Add and center child, initializing animation sequence
override func sceneDidLoad() {
super.sceneDidLoad()
addChild(crab)
if Settings.shared.texture == "HappyCrab" {
crab.loadTextures(named: "HappyCrab", forKey: SKSpriteNode.textureKey)
} else {
crab.loadTextures(named: "WaitingCrab", forKey: SKSpriteNode.textureKey)
}

if let lastPosition = Settings.shared.lastPosition {
crab.position = lastPosition
} else {
crab.position = CGPoint(x: frame.midX, y: frame.midY)
}
Comment on lines +26 to +30
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job figuring out the position persistence


}

// Move to touch
public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

// Fetch a touch or leave
guard !touches.isEmpty, let touch = touches.first else { return }

// Retrieve position
let position = touch.location(in: self)

Settings.shared.lastPosition = position

// Create move action
let actionDuration = 1.0
let moveAction = SKAction.move(to: position, duration: actionDuration)

let rollAction = SKAction.rotate(byAngle: CGFloat.pi * 2, duration: actionDuration)
let zoomAction = SKAction.scale(by: 1.3, duration: 0.3)
let unzoomAction = SKAction.scale(to: 1.0, duration: 0.1)
let fadeOutAction = SKAction.fadeOut(withDuration: actionDuration / 2)
let fadeInAction = SKAction.fadeIn(withDuration: actionDuration / 2)
let danceStartAction = SKAction.rotate(byAngle: -(CGFloat.pi * 0.25), duration: actionDuration / 12)
let danceRightAction = SKAction.rotate(byAngle: CGFloat.pi * 0.5, duration: actionDuration / 6)
let danceLeftAction = SKAction.rotate(byAngle: -(CGFloat.pi * 0.5), duration: actionDuration / 6)
let danceEndAction = SKAction.rotate(byAngle: CGFloat.pi * 0.25, duration: actionDuration / 12)

switch Settings.shared.shouldZoom {
case false:
crab.run(moveAction)
case true:
let sequenceAction = SKAction.sequence([zoomAction, moveAction, unzoomAction])
crab.run(sequenceAction)
}

if Settings.shared.shouldRoll {
crab.run(rollAction)
}

switch Settings.shared.shouldFade {
case false:
crab.run(moveAction)
case true:
let sequenceAction = SKAction.sequence([fadeOutAction, fadeInAction, moveAction])
crab.run(sequenceAction)
}

if Settings.shared.shouldDance {
let sequenceAction = SKAction.sequence([danceStartAction, danceRightAction, danceLeftAction, danceRightAction, danceLeftAction, danceRightAction, danceLeftAction, danceEndAction, moveAction])
crab.run(sequenceAction)
}
Comment on lines +79 to +82
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! One thing I will say, is with long lines like this, most places have a line limit that they like to stick to, so you might consider putting a return in there somewhere, or even putting each item on it's own line. It's all personal style though (you will have to use a linter later in the course which basically enforces some formatting rules).


}
}
Loading