Skip to content

Commit

Permalink
Merge branch 'release/0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lalabuy948 committed Jul 29, 2020
2 parents 7c29e67 + 2a99944 commit 8c87835
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# TinyRage
<br>

FlappyBird clone written in `swift 5` using `spriteKit` for watchOS 6 as standalone game.
<h1 align="center">TinyRage 🐧</h1>

<p align="center">
<a href="https://developer.apple.com/swift/"><img src="https://badgen.net/badge/Swift/5.2/orange"/></a>
<a href="https://github.com/lalabuy948/TinyRage/releases"><img src="https://badgen.net/github/release/lalabuy948/TinyRage"/></a>
<a href="/LICENCE"><img src="https://img.shields.io/badge/licence-ccpl-green"/></a>
</p>

<p align="center">
FlappyBird clone written in `swift 5` using `spriteKit` for watchOS 6 as standalone game.
</p>

## Gameplay

Expand Down
46 changes: 27 additions & 19 deletions TinyRage WatchKit Extension/Game/GameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -98,6 +99,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
}

// MARK: initBird

func initBird() -> Void {
// Bird texture
let birdTexture = SKTexture(imageNamed: "birdPicture");
Expand All @@ -123,6 +125,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
}

// MARK: initGround

func initGround() -> Void {
// Ground texture
let groundTexture = SKTexture(imageNamed: "groundPictureLight");
Expand All @@ -140,6 +143,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
}

// MARK: spawnPipes

func spawnPipes() -> Void {

let pipesGap: CGFloat = 1.0;
Expand Down Expand Up @@ -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 {
Expand All @@ -204,6 +205,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
}

// MARK: collisions

func didBegin(_ contact: SKPhysicsContact) -> Void {
var firstBody:SKPhysicsBody;
var secondBody:SKPhysicsBody;
Expand All @@ -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;
Expand All @@ -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
}
Expand Down
16 changes: 8 additions & 8 deletions TinyRage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 = "";
Expand All @@ -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 = "";
Expand All @@ -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 = "";
Expand All @@ -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 = "";
Expand Down

0 comments on commit 8c87835

Please sign in to comment.