Skip to content

Commit

Permalink
Smashing Day 3
Browse files Browse the repository at this point in the history
  • Loading branch information
marcJV committed Oct 25, 2016
1 parent 585f0e5 commit 3769502
Show file tree
Hide file tree
Showing 41 changed files with 508 additions and 17 deletions.
12 changes: 10 additions & 2 deletions RainCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
BBB66BC21D9C3A670048A87B /* bensound-jazzyfrenchy.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = BBB66BBE1D9C3A670048A87B /* bensound-jazzyfrenchy.mp3 */; };
BBB66BC31D9C3A670048A87B /* bensound-littleidea.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = BBB66BBF1D9C3A670048A87B /* bensound-littleidea.mp3 */; };
BBB66BC51D9C3D8A0048A87B /* SoundManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB66BC41D9C3D8A0048A87B /* SoundManager.swift */; };
BBB66BC71D9C4B480048A87B /* HudNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB66BC61D9C4B480048A87B /* HudNode.swift */; };
BBB66BC91D9C4D9D0048A87B /* MenuScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB66BC81D9C4D9D0048A87B /* MenuScene.swift */; };
BBE2D58F1D9AC5840046B493 /* BackgroundNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBE2D58E1D9AC5840046B493 /* BackgroundNode.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -57,6 +59,8 @@
BBB66BBE1D9C3A670048A87B /* bensound-jazzyfrenchy.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = "bensound-jazzyfrenchy.mp3"; path = "Music/bensound-jazzyfrenchy.mp3"; sourceTree = "<group>"; };
BBB66BBF1D9C3A670048A87B /* bensound-littleidea.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = "bensound-littleidea.mp3"; path = "Music/bensound-littleidea.mp3"; sourceTree = "<group>"; };
BBB66BC41D9C3D8A0048A87B /* SoundManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SoundManager.swift; sourceTree = "<group>"; };
BBB66BC61D9C4B480048A87B /* HudNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HudNode.swift; path = Sprites/HudNode.swift; sourceTree = "<group>"; };
BBB66BC81D9C4D9D0048A87B /* MenuScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MenuScene.swift; path = Scenes/MenuScene.swift; sourceTree = "<group>"; };
BBE2D58E1D9AC5840046B493 /* BackgroundNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BackgroundNode.swift; path = Sprites/BackgroundNode.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -75,6 +79,7 @@
isa = PBXGroup;
children = (
BBA2E4AB1D74A62C00853E63 /* GameScene.swift */,
BBB66BC81D9C4D9D0048A87B /* MenuScene.swift */,
);
name = Scenes;
sourceTree = "<group>";
Expand Down Expand Up @@ -162,6 +167,7 @@
BB8385701D9B1D23001E19AB /* UmbrellaSprite.swift */,
BB4E82371D9C0BA5000D7181 /* CatSprite.swift */,
BB4E82391D9C1358000D7181 /* FoodSprite.swift */,
BBB66BC61D9C4B480048A87B /* HudNode.swift */,
);
name = Sprites;
sourceTree = "<group>";
Expand Down Expand Up @@ -252,7 +258,9 @@
files = (
BB8385711D9B1D23001E19AB /* UmbrellaSprite.swift in Sources */,
BB4E82381D9C0BA5000D7181 /* CatSprite.swift in Sources */,
BBB66BC91D9C4D9D0048A87B /* MenuScene.swift in Sources */,
BB4E823A1D9C1358000D7181 /* FoodSprite.swift in Sources */,
BBB66BC71D9C4B480048A87B /* HudNode.swift in Sources */,
BB83856F1D9AFFD0001E19AB /* Constants.swift in Sources */,
BBA2E4AC1D74A62C00853E63 /* GameScene.swift in Sources */,
BBE2D58F1D9AC5840046B493 /* BackgroundNode.swift in Sources */,
Expand Down Expand Up @@ -388,7 +396,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.thirteen23.RainCat;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 2;
};
name = Debug;
};
Expand All @@ -403,7 +411,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.thirteen23.RainCat;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 2;
};
name = Release;
};
Expand Down
23 changes: 23 additions & 0 deletions RainCat/Assets.xcassets/button_start.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "button_start.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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" : [
{
"idiom" : "universal",
"filename" : "button_start_pressed.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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 RainCat/Assets.xcassets/logo.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "logo.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added RainCat/Assets.xcassets/logo.imageset/logo.png
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 RainCat/Assets.xcassets/quit_button.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "quit_button.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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 RainCat/Assets.xcassets/quit_button_pressed.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "quit_button_pressed.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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 RainCat/Assets.xcassets/speaker_off.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "speaker_off.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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 RainCat/Assets.xcassets/speaker_on.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "speaker_on.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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.
3 changes: 3 additions & 0 deletions RainCat/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ let RainDropCategory : UInt32 = 0x1 << 2
let FloorCategory : UInt32 = 0x1 << 3
let CatCategory : UInt32 = 0x1 << 4
let FoodCategory : UInt32 = 0x1 << 5

let ScoreKey = "RAINCAT_HIGHSCORE"
let MuteKey = "RAINCAT_MUTED"
Binary file added RainCat/Fonts/Pixel Digivolve.otf
Binary file not shown.
4 changes: 4 additions & 0 deletions RainCat/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIAppFonts</key>
<array>
<string>Pixel Digivolve.otf</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down
43 changes: 39 additions & 4 deletions RainCat/Scenes/GameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,24 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
private let umbrellaNode = UmbrellaSprite.newInstance()
private var catNode : CatSprite!
private var foodNode : FoodSprite!
private let hudNode = HudNode()

override func sceneDidLoad() {
hudNode.setup(size: size)

hudNode.quitButtonAction = {
let transition = SKTransition.reveal(with: .up, duration: 0.75)

let gameScene = MenuScene(size: self.size)
gameScene.scaleMode = self.scaleMode

self.view?.presentScene(gameScene, transition: transition)

self.hudNode.quitButtonAction = nil
}

addChild(hudNode)

self.lastUpdateTime = 0

backgroundNode.setup(size: size)
Expand Down Expand Up @@ -51,15 +67,31 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
let touchPoint = touches.first?.location(in: self)

if let point = touchPoint {
umbrellaNode.setDestination(destination: point)
hudNode.touchBeganAtPoint(point: point)

if !hudNode.quitButtonPressed {
umbrellaNode.setDestination(destination: point)
}
}
}

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
let touchPoint = touches.first?.location(in: self)

if let point = touchPoint {
umbrellaNode.setDestination(destination: point)
hudNode.touchMovedToPoint(point: point)

if !hudNode.quitButtonPressed {
umbrellaNode.setDestination(destination: point)
}
}
}

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
let touchPoint = touches.first?.location(in: self)

if let point = touchPoint {
hudNode.touchEndedAtPoint(point: point)
}
}

Expand Down Expand Up @@ -114,6 +146,8 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
catNode.position = CGPoint(x: umbrellaNode.position.x, y: umbrellaNode.position.y - 30)

addChild(catNode)

hudNode.resetPoints()
}

func spawnFood() {
Expand Down Expand Up @@ -173,6 +207,8 @@ class GameScene: SKScene, SKPhysicsContactDelegate {

switch otherBody.categoryBitMask {
case RainDropCategory:
hudNode.resetPoints()

catNode.hitByRain()
case WorldCategory:
spawnCat()
Expand All @@ -195,8 +231,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate {

switch otherBody.categoryBitMask {
case CatCategory:
//TODO increment points
print("fed cat")
hudNode.addPoint()
fallthrough
case WorldCategory:
foodBody.node?.removeFromParent()
Expand Down
Loading

0 comments on commit 3769502

Please sign in to comment.