Skip to content

Commit

Permalink
Merge pull request #15 from DreamEmulator/release/0.0.3
Browse files Browse the repository at this point in the history
Release/0.0.3
  • Loading branch information
DreamEmulator authored Feb 12, 2023
2 parents f64dcf7 + 337e172 commit 4ae0794
Show file tree
Hide file tree
Showing 49 changed files with 1,661 additions and 561 deletions.
184 changes: 160 additions & 24 deletions Fidget.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
Binary file added Resources/DJ Game.pdf
Binary file not shown.
7 changes: 0 additions & 7 deletions Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
Expand Down
10 changes: 10 additions & 0 deletions Resources/Philoshophy.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ A great way to learn.
## The Well
The basis for this project is this [**phenomenal** post](https://medium.com/@nathangitter/building-fluid-interfaces-ios-swift-9732bb934bf5)
[Apple Haptics](https://developer.apple.com/documentation/corehaptics/delivering_rich_app_experiences_with_haptics)

## Learnings
State machines are cool, but you have to be discplined.
- Make sure not to put the side effects in the state machine
- Handle side-effects in the subscribe functions of your classes
- Hide the state so you encourage yourself not to use it in comparison

It's a cool way to think though...
Each class that subscribes has a responsibility (showing something, updating UI, playing a sound), you go to the class
and think "what should it do in this state?" and add the side effects in the subscribtion.
Binary file added Resources/Sounds/failed.m4a
Binary file not shown.
Binary file added Resources/Sounds/missed.m4a
Binary file not shown.
Binary file added Resources/Sounds/released.m4a
Binary file not shown.
Binary file added Resources/Sounds/scored.m4a
Binary file not shown.
Binary file added Resources/Sounds/touched.m4a
Binary file not shown.
17 changes: 17 additions & 0 deletions Sources/App.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// App.swift
// Bondi Ball
//
// Created by Sebastiaan Hols on 24/01/2023.
// Copyright © 2023 Dream Emulator. All rights reserved.
//

import Foundation

class App {
static let shared = App()
var game = GameController()
private init() {
game.state.start()
}
}
16 changes: 16 additions & 0 deletions Sources/Domain/Badge.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Badge.swift
// Bondi Ball
//
// Created by Sebastiaan Hols on 24/01/2023.
// Copyright © 2023 Dream Emulator. All rights reserved.
//

import UIKit
import SpriteKit

struct Badge {
var icon: UIImage
var title: String
var animation: SKScene
}
7 changes: 3 additions & 4 deletions Sources/Domain/Board.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import Foundation

struct Board: BoardProtocol {
var id = UUID()
var rows = 4
var columns = 3
var spring: DampedHarmonicSpring = .init(dampingRatio: 0.35, frequencyResponse: 0.95)
var rows: Int
var columns: Int
var spring: DampedHarmonicSpring
}
25 changes: 25 additions & 0 deletions Sources/Domain/BondiBall.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// BondiBall.swift
// Bondi Ball
//
// Created by Sebastiaan Hols on 06/02/2023.
// Copyright © 2023 Dream Emulator. All rights reserved.
//

import UIKit

/// The different states the PIP view can be in.
enum BondiBallState {
/// Starting scenario
case initial
/// The Bondi ball view is at rest at the specified endpoint.
case idle(at: CGPoint)

/// The user is actively moving the Bondi ball view starting from the specified
/// initial position using the specified gesture recognizer.
case interaction(with: UIPanGestureRecognizer, from: CGPoint)

/// The Bondi ball view is being animated towards the specified endpoint with
/// the specified animator.
case animating(to: CGPoint, using: UIViewPropertyAnimator)
}
42 changes: 0 additions & 42 deletions Sources/Domain/Extensions/UIView+Extensions.swift

This file was deleted.

38 changes: 18 additions & 20 deletions Sources/Domain/Level.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,36 @@

import Foundation

struct Level: BoardProtocol, LevelProtocol {
var id = UUID()
var rows: Int
var columns: Int
var spring: DampedHarmonicSpring
struct Level: LevelProtocol {
var id: String
var board: Board
var dragCost: Int
var wrongPocketCost: Int
var pocketHistory: [EndpointIndicatorView]
var startPocket: EndpointIndicatorView
var endPocket: EndpointIndicatorView
var pocketHistory: [PocketView]
var startPocket: (Int, Int)
var endPocket: (Int, Int) // TODO: Rename to goal pocket
var costIncurred: Int
var points: Int
var maxPoints: Int
var pocketCount: Int { board.rows * board.columns }

init(board: Board,
init(id: String,
board: Board,
dragCost: Int,
wrongPocketCost: Int,
pocketHistory: [EndpointIndicatorView],
startPocket: EndpointIndicatorView,
endPocket: EndpointIndicatorView,
points: Int,
maxPoints: Int)
pocketHistory: [PocketView],
startPocket: (Int, Int),
endPocket: (Int, Int),
costIncurred: Int,
points: Int)
{
self.id = UUID()
self.rows = board.rows
self.columns = board.columns
self.spring = board.spring
self.id = id
self.board = board
self.dragCost = dragCost
self.wrongPocketCost = wrongPocketCost
self.pocketHistory = pocketHistory
self.startPocket = startPocket
self.endPocket = endPocket
self.costIncurred = costIncurred
self.points = points
self.maxPoints = maxPoints
}
}
15 changes: 7 additions & 8 deletions Sources/Domain/Protocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,27 @@
import Foundation

protocol BoardProtocol {
var id: UUID { get }
var rows: Int { get set } // TODO: Just get in production mode
var columns: Int { get set }
var spring: DampedHarmonicSpring { get set }
}

protocol LevelProtocol {
var id: UUID { get }
var id: String { get }
/// Pocket from which the first shot is swiped
var startPocket: EndpointIndicatorView { get } // TODO: Extract model and reference here
var startPocket: (Int, Int) { get } // Row, Column
/// Goal pocket to put the ball in
var endPocket: EndpointIndicatorView { get } // TODO: Extract model and reference here
var endPocket: (Int, Int) { get } // Row, Column
/// Price for dragging
var dragCost: Int { get }
/// Cost for putting the ball in a wrong pocket
var wrongPocketCost: Int { get }
/// Tally of points: max points - costs
var points: Int { get set }
/// Costs are talley'ed and deducted from the points
var costIncurred: Int { get set }
/// The starting amount and max of points the level, user should see this decrease as point are incurred
var maxPoints: Int { get }
var points: Int { get }
/// History of the pockets the ball landed in
var pocketHistory: [EndpointIndicatorView] { get set }
var pocketHistory: [PocketView] { get set }
}

protocol GameProtocol {
Expand Down
15 changes: 15 additions & 0 deletions Sources/Domain/Sounds.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Sounds.swift
// Bondi Ball
//
// Created by Sebastiaan Hols on 11/02/2023.
// Copyright © 2023 Dream Emulator. All rights reserved.
//

enum Sounds: String {
case scoredSound = "scored"
case missedSound = "missed"
case failedSound = "failed"
case touchedSound = "touched"
case releasedSound = "released"
}
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions Sources/Extensions/Collection+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Collection+Extensions.swift
// Bondi Ball
//
// Created by Sebastiaan Hols on 06/02/2023.
// Copyright © 2023 Dream Emulator. All rights reserved.
//

extension Collection where Indices.Iterator.Element == Index {
public subscript(safe index: Index) -> Iterator.Element? {
return (startIndex <= index && index < endIndex) ? self[index] : nil
}
}
28 changes: 28 additions & 0 deletions Sources/Extensions/UIColor+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// UIColor+Extensions.swift
// Bondi Ball
//
// Created by Sebastiaan Hols on 05/02/2023.
// Copyright © 2023 Dream Emulator. All rights reserved.
//

import Foundation
import UIKit

/// Extension for random value get.
extension CGFloat {
static func randomValue() -> CGFloat {
return CGFloat(arc4random()) / CGFloat(UInt32.max)
}
}
/// Extension for random color using random value.
extension UIColor {
static func randomColor() -> UIColor {
return UIColor(
red: .randomValue(),
green: .randomValue(),
blue: .randomValue(),
alpha: 1.0
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ extension RootNavigationController {
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
// Implement navigationController(_:animationControllerFor:from:to:), returning an instance of the animation controller we just created. We can use the operation object to see if it's a push or pop transition, so that the animation can be customized based on this.
if operation == .push {
return FadeAnimationController(presenting: true)
} else {
return FadeAnimationController(presenting: false)
} else {
return FadeAnimationController(presenting: true)
}
}
}
26 changes: 26 additions & 0 deletions Sources/Extensions/UINib+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// UINib+Extensions.swift
// Bondi Ball
//
// Created by Sebastiaan Hols on 06/02/2023.
// Copyright © 2023 Dream Emulator. All rights reserved.
//

import UIKit

extension UINib {
@propertyWrapper private struct Named {
let wrappedValue: UINib

init(_ name: String, in bundle: Bundle = .main) {
wrappedValue = UIKit.UINib(nibName: name, bundle: bundle)
}
}

@Named("Game") static var game
@Named("Score") static var score

func firstView(owner ownerOrNil: AnyObject?, options optionsOrNil: [UINib.OptionsKey: Any]? = nil) -> UIView? {
instantiate(withOwner: ownerOrNil, options: optionsOrNil)[0] as? UIView
}
}
Loading

0 comments on commit 4ae0794

Please sign in to comment.