Skip to content

Commit 3608f71

Browse files
committed
initial commit
1 parent 85b8134 commit 3608f71

File tree

5 files changed

+40
-43
lines changed

5 files changed

+40
-43
lines changed

.DS_Store

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

WWDC 2018 Debug Xcode Project/WWDC SUBMISSION 2018.playground/Contents.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import PlaygroundSupport
22
import SpriteKit
3-
//import UIKit
43
import Cocoa
54

65
let scene = GameScene(fileNamed: "GameScene")
76

8-
let frame = CGRect(x:0, y:0, width:1920, height:1080)
9-
let view = SKView(frame:frame)
7+
let frame = CGRect(x: 0, y: 0, width: 1920, height: 1080)
8+
let view = SKView(frame: frame)
109

11-
//scene.backgroundColor = .white
12-
//scene.scaleMode = .aspectFit
13-
14-
let options = [NSTrackingArea.Options.mouseMoved, NSTrackingArea.Options.activeInKeyWindow, NSTrackingArea.Options.activeAlways, NSTrackingArea.Options.inVisibleRect, ] as NSTrackingArea.Options
15-
let tracker = NSTrackingArea(rect:frame, options: options, owner:view, userInfo: nil)
10+
//add tracker to detect mouse location
11+
let options = [NSTrackingArea.Options.mouseMoved, NSTrackingArea.Options.activeInKeyWindow, NSTrackingArea.Options.activeAlways, NSTrackingArea.Options.inVisibleRect,] as NSTrackingArea.Options
12+
let tracker = NSTrackingArea(rect: frame, options: options, owner: view, userInfo: nil)
1613
view.addTrackingArea(tracker)
1714

1815
PlaygroundPage.current.needsIndefiniteExecution = true

WWDC 2018 Debug Xcode Project/WWDC SUBMISSION 2018.playground/Sources/GameScene.swift

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -232,38 +232,37 @@ public class GameScene: SKScene, SKPhysicsContactDelegate {
232232

233233
//these don't need to be ranges anymore cuz we stopped using random values, fix later
234234
switch bodyANode.position.x {
235-
case -350 ... -300:
236-
checkNote(length: length, noteToPlay: "C1")
237-
case -299 ... -250:
238-
checkNote(length: length, noteToPlay: "D1")
239-
case -249 ... -200:
240-
checkNote(length: length, noteToPlay: "E1")
241-
case -199 ... -150:
242-
checkNote(length: length, noteToPlay: "F1")
243-
case -149 ... -100:
244-
checkNote(length: length, noteToPlay: "G1")
245-
case -99 ... -50:
246-
checkNote(length: length, noteToPlay: "A1")
247-
case -49 ... 0:
248-
checkNote(length: length, noteToPlay: "B1")
249-
case 1...50:
250-
checkNote(length: length, noteToPlay: "C2")
251-
case 51...100:
252-
checkNote(length: length, noteToPlay: "D2")
253-
case 101...150:
254-
checkNote(length: length, noteToPlay: "E2")
255-
case 151...200:
256-
checkNote(length: length, noteToPlay: "F2")
257-
case 201...250:
258-
checkNote(length: length, noteToPlay: "G2")
259-
case 251...300:
260-
checkNote(length: length, noteToPlay: "A2")
261-
case 301...350:
262-
checkNote(length: length, noteToPlay: "B2")
263-
default:
264-
print("this shouldn't happen")
235+
case -350 ... -300:
236+
checkNote(length: length, noteToPlay: "C1")
237+
case -299 ... -250:
238+
checkNote(length: length, noteToPlay: "D1")
239+
case -249 ... -200:
240+
checkNote(length: length, noteToPlay: "E1")
241+
case -199 ... -150:
242+
checkNote(length: length, noteToPlay: "F1")
243+
case -149 ... -100:
244+
checkNote(length: length, noteToPlay: "G1")
245+
case -99 ... -50:
246+
checkNote(length: length, noteToPlay: "A1")
247+
case -49 ... 0:
248+
checkNote(length: length, noteToPlay: "B1")
249+
case 1...50:
250+
checkNote(length: length, noteToPlay: "C2")
251+
case 51...100:
252+
checkNote(length: length, noteToPlay: "D2")
253+
case 101...150:
254+
checkNote(length: length, noteToPlay: "E2")
255+
case 151...200:
256+
checkNote(length: length, noteToPlay: "F2")
257+
case 201...250:
258+
checkNote(length: length, noteToPlay: "G2")
259+
case 251...300:
260+
checkNote(length: length, noteToPlay: "A2")
261+
case 301...350:
262+
checkNote(length: length, noteToPlay: "B2")
263+
default:
264+
print("this shouldn't happen")
265265
}
266-
267266
contact.bodyA.node!.removeFromParent()
268267
contact.bodyB.node!.removeFromParent()
269268
}
@@ -280,14 +279,15 @@ public class GameScene: SKScene, SKPhysicsContactDelegate {
280279
} else {
281280
//print("this is not a quarter or half note...")
282281
}
283-
284282
checkCorrect(noteToCheck: noteToPlay)
285283
}
286284

287285
////////////////
288286
//MARK:Scoring//
289287
////////////////
290288

289+
//FIX THIS
290+
291291
var notesPlayed = 0
292292
var nextNote : String!
293293
var targetNote : String!
@@ -322,7 +322,6 @@ public class GameScene: SKScene, SKPhysicsContactDelegate {
322322

323323
public override func mouseDown(with event: NSEvent) {
324324
shootBeam()
325-
print("clicked")
326325
}
327326

328327
////////////////////
@@ -369,13 +368,14 @@ public class GameScene: SKScene, SKPhysicsContactDelegate {
369368
if i < (song.songArray.count - 1) {
370369
if ((song.songArray[i]).0) == "N/A" {
371370
//delay here
372-
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(Int((song.songArray[i]).2))) {
371+
delay(Double((song.songArray[i]).2)) {
373372
self.playSong()
374373
}
375374
} else {
376375
//spawn note
377376
spawnNote(note: ((song.songArray[i]).0), octave: ((song.songArray[i]).1), length: ((song.songArray[i]).2))
378-
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(Int((song.songArray[i]).2))) {
377+
//delay
378+
delay(Double((song.songArray[i]).2)) {
379379
self.playSong()
380380
}
381381
}

0 commit comments

Comments
 (0)