Skip to content

Commit 93ec771

Browse files
committed
Create gameViewDelegate protocol
1 parent ddb252b commit 93ec771

13 files changed

+130
-89
lines changed

‎ps4/peggleclone.xcodeproj/project.pbxproj‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
6882BA8527CA85C0009F3DAD /* PointsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6882BA8427CA85C0009F3DAD /* PointsView.swift */; };
4444
6882BA8727CA94D4009F3DAD /* RemainingPegsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6882BA8627CA94D4009F3DAD /* RemainingPegsView.swift */; };
4545
6882BA8927CA9801009F3DAD /* NumberOfPegsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6882BA8827CA9801009F3DAD /* NumberOfPegsView.swift */; };
46+
6882BA8B27CAA2C2009F3DAD /* GameLogicDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6882BA8A27CAA2C2009F3DAD /* GameLogicDelegate.swift */; };
47+
6882BA8F27CAA31A009F3DAD /* GameEngineManager+GameLogicDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6882BA8E27CAA31A009F3DAD /* GameEngineManager+GameLogicDelegate.swift */; };
4648
68861F0627C92DB500D2AEF7 /* SLPhysicsTriangle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68861F0527C92DB500D2AEF7 /* SLPhysicsTriangle.swift */; };
4749
689A4A0027A2CD0D00A2E4E6 /* Level.swift in Sources */ = {isa = PBXBuildFile; fileRef = 689A49FF27A2CD0D00A2E4E6 /* Level.swift */; };
4850
689A4A0227A2CD7C00A2E4E6 /* AllLevelsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 689A4A0127A2CD7C00A2E4E6 /* AllLevelsManager.swift */; };
@@ -56,7 +58,7 @@
5658
68B6B8D327C54117004CE9E2 /* PegPersistance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B6B8D227C54117004CE9E2 /* PegPersistance.swift */; };
5759
68B6B8D527C54138004CE9E2 /* PeggleObjectPersistance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B6B8D427C54138004CE9E2 /* PeggleObjectPersistance.swift */; };
5860
68B6B8D727C558FE004CE9E2 /* PointPersistance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B6B8D627C558FE004CE9E2 /* PointPersistance.swift */; };
59-
68B6B8D927C5E30A004CE9E2 /* GameLogicDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B6B8D827C5E30A004CE9E2 /* GameLogicDelegate.swift */; };
61+
68B6B8D927C5E30A004CE9E2 /* GameDisplayDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B6B8D827C5E30A004CE9E2 /* GameDisplayDelegate.swift */; };
6062
68B6B8DB27C5E35B004CE9E2 /* LevelManager+GameLogicDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B6B8DA27C5E35B004CE9E2 /* LevelManager+GameLogicDelegate.swift */; };
6163
68C1B1E0279DCCCC002DF357 /* PeggleCloneApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68C1B1DF279DCCCC002DF357 /* PeggleCloneApp.swift */; };
6264
68C1B1E2279DCCCC002DF357 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68C1B1E1279DCCCC002DF357 /* ContentView.swift */; };
@@ -101,6 +103,8 @@
101103
6882BA8427CA85C0009F3DAD /* PointsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointsView.swift; sourceTree = "<group>"; };
102104
6882BA8627CA94D4009F3DAD /* RemainingPegsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemainingPegsView.swift; sourceTree = "<group>"; };
103105
6882BA8827CA9801009F3DAD /* NumberOfPegsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberOfPegsView.swift; sourceTree = "<group>"; };
106+
6882BA8A27CAA2C2009F3DAD /* GameLogicDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameLogicDelegate.swift; sourceTree = "<group>"; };
107+
6882BA8E27CAA31A009F3DAD /* GameEngineManager+GameLogicDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GameEngineManager+GameLogicDelegate.swift"; sourceTree = "<group>"; };
104108
68861F0527C92DB500D2AEF7 /* SLPhysicsTriangle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SLPhysicsTriangle.swift; sourceTree = "<group>"; };
105109
689A49FF27A2CD0D00A2E4E6 /* Level.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Level.swift; sourceTree = "<group>"; };
106110
689A4A0127A2CD7C00A2E4E6 /* AllLevelsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllLevelsManager.swift; sourceTree = "<group>"; };
@@ -114,7 +118,7 @@
114118
68B6B8D227C54117004CE9E2 /* PegPersistance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PegPersistance.swift; sourceTree = "<group>"; };
115119
68B6B8D427C54138004CE9E2 /* PeggleObjectPersistance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeggleObjectPersistance.swift; sourceTree = "<group>"; };
116120
68B6B8D627C558FE004CE9E2 /* PointPersistance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointPersistance.swift; sourceTree = "<group>"; };
117-
68B6B8D827C5E30A004CE9E2 /* GameLogicDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameLogicDelegate.swift; sourceTree = "<group>"; };
121+
68B6B8D827C5E30A004CE9E2 /* GameDisplayDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameDisplayDelegate.swift; sourceTree = "<group>"; };
118122
68B6B8DA27C5E35B004CE9E2 /* LevelManager+GameLogicDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LevelManager+GameLogicDelegate.swift"; sourceTree = "<group>"; };
119123
68C1B1DC279DCCCC002DF357 /* peggleclone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = peggleclone.app; sourceTree = BUILT_PRODUCTS_DIR; };
120124
68C1B1DF279DCCCC002DF357 /* PeggleCloneApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeggleCloneApp.swift; sourceTree = "<group>"; };
@@ -171,10 +175,12 @@
171175
isa = PBXGroup;
172176
children = (
173177
68143575279FEEDF00A16058 /* LevelManager.swift */,
174-
68B6B8D827C5E30A004CE9E2 /* GameLogicDelegate.swift */,
178+
68B6B8D827C5E30A004CE9E2 /* GameDisplayDelegate.swift */,
175179
689A4A0127A2CD7C00A2E4E6 /* AllLevelsManager.swift */,
176180
687C2B3E27B61ABF00D1BB1E /* GameEngineManager.swift */,
181+
6882BA8E27CAA31A009F3DAD /* GameEngineManager+GameLogicDelegate.swift */,
177182
68B6B8DA27C5E35B004CE9E2 /* LevelManager+GameLogicDelegate.swift */,
183+
6882BA8A27CAA2C2009F3DAD /* GameLogicDelegate.swift */,
178184
);
179185
path = ViewModels;
180186
sourceTree = "<group>";
@@ -423,6 +429,7 @@
423429
68686A9C27B373EC00B97394 /* SLPhysicsBody.swift in Sources */,
424430
68861F0627C92DB500D2AEF7 /* SLPhysicsTriangle.swift in Sources */,
425431
684FFA3E27C4D547000CD3D5 /* Vector.swift in Sources */,
432+
6882BA8F27CAA31A009F3DAD /* GameEngineManager+GameLogicDelegate.swift in Sources */,
426433
68B6B8D127C540C5004CE9E2 /* LevelPersistance.swift in Sources */,
427434
6834AD1C27C680BA00F5A4E3 /* Bucket.swift in Sources */,
428435
68B6B8CE27C4F33D004CE9E2 /* PeggleObject.swift in Sources */,
@@ -431,10 +438,11 @@
431438
6834AD2927C76DB300F5A4E3 /* SpookyPegPersistance.swift in Sources */,
432439
68B6B8D727C558FE004CE9E2 /* PointPersistance.swift in Sources */,
433440
6834AD2527C762BD00F5A4E3 /* SpookyPeg.swift in Sources */,
441+
6882BA8B27CAA2C2009F3DAD /* GameLogicDelegate.swift in Sources */,
434442
6882BA8727CA94D4009F3DAD /* RemainingPegsView.swift in Sources */,
435443
68143574279FEE2100A16058 /* Peg.swift in Sources */,
436444
6834AD1A27C6787100F5A4E3 /* BucketView.swift in Sources */,
437-
68B6B8D927C5E30A004CE9E2 /* GameLogicDelegate.swift in Sources */,
445+
68B6B8D927C5E30A004CE9E2 /* GameDisplayDelegate.swift in Sources */,
438446
689A4A0027A2CD0D00A2E4E6 /* Level.swift in Sources */,
439447
68143563279EE71700A16058 /* BackgroundView.swift in Sources */,
440448
6882BA8927CA9801009F3DAD /* NumberOfPegsView.swift in Sources */,

‎ps4/peggleclone/SLGameEngine/PowerUpHandler.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PowerUpHandler {
1212
private var spookyBallsActivated = 0
1313

1414
func handlePowerUp(
15-
powerPeg: Peg, mappings: [PeggleObject: SLPhysicsBody], cannonBall: Peg, gameLogicDelegate: GameLogicDelegate) {
15+
powerPeg: Peg, mappings: [PeggleObject: SLPhysicsBody], cannonBall: Peg, gameDisplayDelegate: GameDisplayDelegate) {
1616
if let spookyPeg = powerPeg as? SpookyPeg {
1717
if !spookyPeg.activated {
1818
spookyBallsActivated += 1
@@ -41,7 +41,7 @@ class PowerUpHandler {
4141
}
4242
kaboomPeg.setActivated()
4343
}
44-
gameLogicDelegate.renderExplosion(kaboomPeg: kaboomPeg)
44+
gameDisplayDelegate.renderExplosion(kaboomPeg: kaboomPeg)
4545
}
4646
}
4747

@@ -59,13 +59,13 @@ class PowerUpHandler {
5959

6060
func handleCannonBall(
6161
canvasDimension: CGRect, cannonBall: Peg, cannonBallPhysicsBody: SLPhysicsBody,
62-
gameLogicDelegate: GameLogicDelegate) {
62+
gameDisplayDelegate: GameDisplayDelegate) {
6363
if spookyBallsActivated > 0 {
64-
gameLogicDelegate.spookCannonBall(cannonBall: cannonBall)
64+
gameDisplayDelegate.spookCannonBall(cannonBall: cannonBall)
6565
}
6666

6767
if spookyBallsActivated > 0 && isOutOfScreen(peg: cannonBall, canvasDimensions: canvasDimension) {
68-
gameLogicDelegate.didMove(peggleObject: cannonBall,
68+
gameDisplayDelegate.didMove(peggleObject: cannonBall,
6969
newLocation: Point(xCoordinate: cannonBall.center.xCoordinate, yCoordinate: 0))
7070
cannonBallPhysicsBody.moveTo(position: Point(xCoordinate: cannonBall.center.xCoordinate, yCoordinate: 0))
7171
cannonBallPhysicsBody

‎ps4/peggleclone/SLGameEngine/SLGameEngine.swift‎

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class SLGameEngine {
1414
private let msPerUpdate = TimeInterval(0.016)
1515
private var lag = 0.0
1616
private var previous: Date?
17+
private weak var gameDisplayDelegate: GameDisplayDelegate?
1718
private weak var gameLogicDelegate: GameLogicDelegate?
1819
private var canvasDimensions: CGRect
1920
private var cannonBall: Peg?
@@ -31,8 +32,12 @@ class SLGameEngine {
3132
self.numOfOrangePegs = 0
3233
}
3334

34-
func loadLevel(gameLogicDelegate: GameLogicDelegate, level: Level, bucket: Bucket) {
35+
func loadLevel(
36+
gameDisplayDelegate: GameDisplayDelegate,
37+
gameLogicDelegate: GameLogicDelegate,
38+
level: Level, bucket: Bucket) {
3539
// create physics body for each object, loads to physics engine
40+
self.gameDisplayDelegate = gameDisplayDelegate
3641
self.gameLogicDelegate = gameLogicDelegate
3742
self.bucket = bucket
3843
self.numOfCannonBallsLeft = 10
@@ -77,7 +82,7 @@ class SLGameEngine {
7782
}
7883

7984
func addCannonBall() {
80-
guard let gameLogicDelegate = gameLogicDelegate else {
85+
guard let gameDisplayDelegate = gameDisplayDelegate else {
8186
return
8287
}
8388
let middleOfTopScreen = CGPoint(x: 400, y: 50)
@@ -88,7 +93,7 @@ class SLGameEngine {
8893
return
8994
}
9095
print("cannon ball added \(cannonBallCheck)")
91-
gameLogicDelegate.didAddCannonBall(cannonBall: cannonBall)
96+
gameDisplayDelegate.didAddCannonBall(cannonBall: cannonBall)
9297
self.mostRecentPosition = cannonBall.center
9398
}
9499

@@ -123,30 +128,35 @@ class SLGameEngine {
123128
}
124129

125130
func render(cannonBallCount: Int) {
126-
guard let gameLogicDelegate = gameLogicDelegate,
131+
guard let gameDisplayDelegate = gameDisplayDelegate,
127132
let bucket = bucket,
128-
let bucketPhysicsBody = mappings[bucket] else {
133+
let bucketPhysicsBody = mappings[bucket],
134+
let gameLogicDelegate = gameLogicDelegate else {
129135
return
130136
}
131137

132-
moveBucket(bucket, bucketPhysicsBody, gameLogicDelegate)
138+
moveBucket(bucket, bucketPhysicsBody, gameDisplayDelegate)
133139

134140
guard let cannonBall = cannonBall,
135141
let cannonBallPhysicsBody = mappings[cannonBall] else {
136142
return
137143
}
138144

139-
moveCannonBall(cannonBall, cannonBallPhysicsBody, gameLogicDelegate)
145+
moveCannonBall(cannonBall, cannonBallPhysicsBody, gameDisplayDelegate)
140146

141147
let collisions = cannonBallPhysicsBody.collisionsWith
142-
let currentCollisions = handleCollisions(collisions, gameLogicDelegate, cannonBallCount, cannonBall)
148+
let currentCollisions = handleCollisions(collisions,
149+
gameDisplayDelegate,
150+
gameLogicDelegate,
151+
cannonBallCount,
152+
cannonBall)
143153

144154
let similarPositionLimit = 75
145155

146156
if cannonBallCount == 0 {
147157
cannonBallPhysicsBody.ignore()
148158
mappings.removeValue(forKey: cannonBall)
149-
gameLogicDelegate.didRemove(peg: cannonBall)
159+
gameDisplayDelegate.didRemove(peg: cannonBall)
150160
if cannonBallInBucket {
151161
numOfCannonBallsLeft += 1
152162
cannonBallInBucket = false
@@ -162,7 +172,7 @@ class SLGameEngine {
162172
}
163173
if pegInTouch.hasCollided {
164174
pegInTouch.ignore()
165-
gameLogicDelegate.didRemove(peg: peg)
175+
gameDisplayDelegate.didRemove(peg: peg)
166176
}
167177
}
168178
} else {
@@ -184,13 +194,14 @@ class SLGameEngine {
184194
}
185195

186196
private func moveBucket(
187-
_ bucket: Bucket, _ bucketPhysicsBody: SLPhysicsBody, _ gameLogicDelegate: GameLogicDelegate) {
197+
_ bucket: Bucket, _ bucketPhysicsBody: SLPhysicsBody, _ gameDisplayDelegate: GameDisplayDelegate) {
188198
bucket.center = bucketPhysicsBody.position
189-
gameLogicDelegate.didMove(peggleObject: bucket, newLocation: bucketPhysicsBody.position)
199+
gameDisplayDelegate.didMove(peggleObject: bucket, newLocation: bucketPhysicsBody.position)
190200
}
191201

192202
private func handleCollisions(
193-
_ collisions: [SLPhysicsBody], _ gameLogicDelegate: GameLogicDelegate,
203+
_ collisions: [SLPhysicsBody], _ gameDisplayDelegate: GameDisplayDelegate,
204+
_ gameLogicDelegate: GameLogicDelegate,
194205
_ cannonBallCount: Int, _ cannonBall: Peg) -> [Peg] {
195206
var currentCollisions: [Peg] = []
196207

@@ -202,10 +213,10 @@ class SLGameEngine {
202213
}
203214
if peg is SpookyPeg || peg is KaboomPeg {
204215
powerUpHandler.handlePowerUp(powerPeg: peg, mappings: mappings,
205-
cannonBall: cannonBall, gameLogicDelegate: gameLogicDelegate)
216+
cannonBall: cannonBall, gameDisplayDelegate: gameDisplayDelegate)
206217
}
207218
if cannonBallCount == 0 {
208-
gameLogicDelegate.didRemove(peg: peg)
219+
gameDisplayDelegate.didRemove(peg: peg)
209220
mappings.removeValue(forKey: peg)
210221
if peg.color != cannonBall.color {
211222
gameLogicDelegate.didAddPoints(peg.points)
@@ -226,17 +237,17 @@ class SLGameEngine {
226237
}
227238

228239
private func moveCannonBall(
229-
_ cannonBall: Peg, _ cannonBallPhysicsBody: SLPhysicsBody, _ gameLogicDelegate: GameLogicDelegate) {
240+
_ cannonBall: Peg, _ cannonBallPhysicsBody: SLPhysicsBody, _ gameDisplayDelegate: GameDisplayDelegate) {
230241
cannonBall.center = cannonBallPhysicsBody.position
231-
gameLogicDelegate.didMove(peggleObject: cannonBall, newLocation: cannonBallPhysicsBody.position)
242+
gameDisplayDelegate.didMove(peggleObject: cannonBall, newLocation: cannonBallPhysicsBody.position)
232243

233244
if isCannonBallInBucket(cannonBallPhysicsBody) {
234245
cannonBallInBucket = true
235246
}
236247
powerUpHandler.handleCannonBall(canvasDimension: canvasDimensions,
237248
cannonBall: cannonBall,
238249
cannonBallPhysicsBody: cannonBallPhysicsBody,
239-
gameLogicDelegate: gameLogicDelegate)
250+
gameDisplayDelegate: gameDisplayDelegate)
240251
}
241252

242253
private func isOutOfScreen(peg: Peg) -> Bool {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// GameLogicDelegate.swift
3+
// peggleclone
4+
//
5+
// Created by Stuart Long on 23/2/22.
6+
//
7+
8+
import Foundation
9+
10+
protocol GameDisplayDelegate: AnyObject {
11+
func didMove(peggleObject: PeggleObject, newLocation: Point)
12+
func didRemove(peg: Peg)
13+
func didAddCannonBall(cannonBall: Peg)
14+
func spookCannonBall(cannonBall: Peg)
15+
func renderExplosion(kaboomPeg: KaboomPeg)
16+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// GameEngineManager+GameLogicDelegate.swift
3+
// peggleclone
4+
//
5+
// Created by Stuart Long on 27/2/22.
6+
//
7+
8+
import Foundation
9+
10+
extension GameEngineManager: GameLogicDelegate {
11+
func gameWin() {
12+
self.isGameWon = true
13+
self.isGameLost = false
14+
}
15+
16+
func gameLose() {
17+
self.isGameLost = true
18+
self.isGameWon = false
19+
}
20+
21+
func didAddPoints(_ points: Int) {
22+
self.points += points
23+
}
24+
25+
func resetPoints() {
26+
self.points = 0
27+
self.isGameWon = false
28+
self.isGameLost = false
29+
}
30+
}

‎ps4/peggleclone/ViewModels/GameEngineManager.swift‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@ import Foundation
99
import SwiftUI
1010

1111
class GameEngineManager: ObservableObject {
12+
@Published var isGameWon: Bool
13+
@Published var isGameLost: Bool
14+
@Published var points: Int = 0
1215
private var gameEngine: SLGameEngine
1316

1417
init(canvasDimension: CGRect) {
1518
gameEngine = SLGameEngine(canvasDimensions: canvasDimension)
19+
self.isGameWon = false
20+
self.isGameLost = false
1621
}
1722

1823
func loadLevel(levelManager: LevelManager) {
19-
gameEngine.loadLevel(gameLogicDelegate: levelManager, level: levelManager.level, bucket: levelManager.bucket)
24+
gameEngine.loadLevel(gameDisplayDelegate: levelManager,
25+
gameLogicDelegate: self,
26+
level: levelManager.level,
27+
bucket: levelManager.bucket)
2028
}
2129

2230
func start() {

‎ps4/peggleclone/ViewModels/GameLogicDelegate.swift‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
// GameLogicDelegate.swift
33
// peggleclone
44
//
5-
// Created by Stuart Long on 23/2/22.
5+
// Created by Stuart Long on 27/2/22.
66
//
77

88
import Foundation
99

1010
protocol GameLogicDelegate: AnyObject {
11-
func didMove(peggleObject: PeggleObject, newLocation: Point)
12-
func didRemove(peg: Peg)
13-
func didAddCannonBall(cannonBall: Peg)
1411
func gameWin()
1512
func gameLose()
16-
func spookCannonBall(cannonBall: Peg)
17-
func renderExplosion(kaboomPeg: KaboomPeg)
1813
func didAddPoints(_ points: Int)
1914
func resetPoints()
2015
}

‎ps4/peggleclone/ViewModels/LevelManager+GameLogicDelegate.swift‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
extension LevelManager: GameLogicDelegate {
10+
extension LevelManager: GameDisplayDelegate {
1111
func didMove(peggleObject: PeggleObject, newLocation: Point) {
1212
if let peg = peggleObject as? Peg {
1313
movePeg(peg: peg, newLocation: newLocation)
@@ -26,29 +26,11 @@ extension LevelManager: GameLogicDelegate {
2626
level.addPeggleObject(peggleObject: cannonBall)
2727
}
2828

29-
func gameWin() {
30-
self.isGameWon = true
31-
self.isGameLost = false
32-
}
33-
34-
func gameLose() {
35-
self.isGameLost = true
36-
self.isGameWon = false
37-
}
38-
3929
func spookCannonBall(cannonBall: Peg) {
4030
level.spookCannonBall(cannonBall: cannonBall)
4131
}
4232

4333
func renderExplosion(kaboomPeg: KaboomPeg) {
4434
level.renderExplosion(kaboomPeg: kaboomPeg)
4535
}
46-
47-
func didAddPoints(_ points: Int) {
48-
self.points += points
49-
}
50-
51-
func resetPoints() {
52-
self.points = 0
53-
}
5436
}

0 commit comments

Comments
 (0)