diff --git a/README.md b/README.md index 0c5515a..a7c671a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ -# TinyRage +
-FlappyBird clone written in `swift 5` using `spriteKit` for watchOS 6 as standalone game. +

TinyRage 🐧

+ +

+ + + +

+ +

+ FlappyBird clone written in `swift 5` using `spriteKit` for watchOS 6 as standalone game. +

## Gameplay diff --git a/TinyRage WatchKit Extension/Game/GameScene.swift b/TinyRage WatchKit Extension/Game/GameScene.swift index 28d1bf2..a2c166a 100644 --- a/TinyRage WatchKit Extension/Game/GameScene.swift +++ b/TinyRage WatchKit Extension/Game/GameScene.swift @@ -36,21 +36,18 @@ class GameScene: SKScene, SKPhysicsContactDelegate { self.gameOverLabel?.removeFromParent(); self.initGameOverPopup() - // Init score self.initScore() - // Init bird self.initBird(); - // Init ground self.initGround(); - // Pipes textures + // Preload pipes textures pipeUpTexture = SKTexture(imageNamed: "wallPictureDark"); pipeDownTexture = SKTexture(imageNamed: "wallPictureDark"); - let distanceToMove = CGFloat(self.frame.size.width + 2 * pipeUpTexture.size().width); + let distanceToMove = CGFloat(self.frame.size.width + (2 * pipeUpTexture.size().width)); let movePipes = SKAction.moveBy(x: -distanceToMove, y: 0.0, duration: TimeInterval(0.01 * distanceToMove)); @@ -71,6 +68,10 @@ class GameScene: SKScene, SKPhysicsContactDelegate { self.physicsWorld.gravity = CGVector(dx: 0.0, dy: -5.5); self.physicsWorld.contactDelegate = self bird.physicsBody?.isDynamic = true; + + if self.scene?.isPaused == false { + self.scene?.isPaused = true; + }; // Start spawing pipes self.run(spawnThenDelayForever); @@ -98,6 +99,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate { } // MARK: initBird + func initBird() -> Void { // Bird texture let birdTexture = SKTexture(imageNamed: "birdPicture"); @@ -123,6 +125,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate { } // MARK: initGround + func initGround() -> Void { // Ground texture let groundTexture = SKTexture(imageNamed: "groundPictureLight"); @@ -140,6 +143,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate { } // MARK: spawnPipes + func spawnPipes() -> Void { let pipesGap: CGFloat = 1.0; @@ -186,11 +190,8 @@ class GameScene: SKScene, SKPhysicsContactDelegate { self.score += 1; } - @objc func incrementScore() -> Void { - self.score += 1; - } - // MARK: applyBirdImpulse + func applyBirdImpulse() -> Void { if self.scene?.isPaused == true { @@ -204,6 +205,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate { } // MARK: collisions + func didBegin(_ contact: SKPhysicsContact) -> Void { var firstBody:SKPhysicsBody; var secondBody:SKPhysicsBody; @@ -221,6 +223,22 @@ class GameScene: SKScene, SKPhysicsContactDelegate { } } + // MAR: utility + + @objc func incrementScore() -> Void { + self.score += 1; + } + + func updateHighestScore(score: Int) -> Void { + + let defaults = UserDefaults.standard + + let highestScore = defaults.integer(forKey: self.highestScorekey) + if (highestScore < score) { + defaults.set(score, forKey: self.highestScorekey) + } + } + func restartGame() { self.removeAllActions(); self.gameOverLabel.isHidden = false; @@ -237,16 +255,6 @@ class GameScene: SKScene, SKPhysicsContactDelegate { self.bird.removeFromParent(); } - func updateHighestScore(score: Int) -> Void { - - let defaults = UserDefaults.standard - - let highestScore = defaults.integer(forKey: self.highestScorekey) - if (highestScore < score) { - defaults.set(score, forKey: self.highestScorekey) - } - } - override func update(_ currentTime: TimeInterval) -> Void { // Called before each frame is rendered } diff --git a/TinyRage.xcodeproj/project.pbxproj b/TinyRage.xcodeproj/project.pbxproj index f6c41f9..74c72c2 100644 --- a/TinyRage.xcodeproj/project.pbxproj +++ b/TinyRage.xcodeproj/project.pbxproj @@ -466,8 +466,8 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = si.popov.daniil.TinyRage.watchkitapp.watchkitextension; + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = si.popov.daniil.TinyRage.watchkitapp.extension; PRODUCT_NAME = "${TARGET_NAME}"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = watchos; @@ -491,8 +491,8 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = si.popov.daniil.TinyRage.watchkitapp.watchkitextension; + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = si.popov.daniil.TinyRage.watchkitapp.extension; PRODUCT_NAME = "${TARGET_NAME}"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = watchos; @@ -513,7 +513,7 @@ DEVELOPMENT_TEAM = PPKSE537F6; IBSC_MODULE = TinyRage_WatchKit_Extension; INFOPLIST_FILE = "TinyRage WatchKit App/Info.plist"; - MARKETING_VERSION = 1.1; + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = si.popov.daniil.TinyRage.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -535,7 +535,7 @@ DEVELOPMENT_TEAM = PPKSE537F6; IBSC_MODULE = TinyRage_WatchKit_Extension; INFOPLIST_FILE = "TinyRage WatchKit App/Info.plist"; - MARKETING_VERSION = 1.1; + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = si.popov.daniil.TinyRage.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -554,7 +554,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = PPKSE537F6; - MARKETING_VERSION = 1.1; + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = si.popov.daniil.TinyRage; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -570,7 +570,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = PPKSE537F6; - MARKETING_VERSION = 1.1; + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = si.popov.daniil.TinyRage; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "";