Skip to content

Commit 8008c46

Browse files
committed
Merge branch 'letterBoxing'
2 parents 2f31f3a + ef3ab56 commit 8008c46

21 files changed

+471
-214
lines changed

‎ps4/peggleclone.xcodeproj/project.pbxproj‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
6882BA9327CB2650009F3DAD /* TimerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6882BA9227CB264F009F3DAD /* TimerView.swift */; };
5050
6882BA9527CB4293009F3DAD /* MusicManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6882BA9427CB4293009F3DAD /* MusicManager.swift */; };
5151
6882BA9727CB467D009F3DAD /* background-music.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 6882BA9627CB467D009F3DAD /* background-music.mp3 */; };
52-
6882BA9A27CB483D009F3DAD /* ball-bounce.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 6882BA9927CB483C009F3DAD /* ball-bounce.mp3 */; };
5352
6882BA9C27CB490E009F3DAD /* ball-bounce.wav in Resources */ = {isa = PBXBuildFile; fileRef = 6882BA9B27CB490E009F3DAD /* ball-bounce.wav */; };
5453
68861F0627C92DB500D2AEF7 /* SLPhysicsTriangle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68861F0527C92DB500D2AEF7 /* SLPhysicsTriangle.swift */; };
5554
689A4A0027A2CD0D00A2E4E6 /* Level.swift in Sources */ = {isa = PBXBuildFile; fileRef = 689A49FF27A2CD0D00A2E4E6 /* Level.swift */; };
@@ -115,7 +114,6 @@
115114
6882BA9227CB264F009F3DAD /* TimerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerView.swift; sourceTree = "<group>"; };
116115
6882BA9427CB4293009F3DAD /* MusicManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicManager.swift; sourceTree = "<group>"; };
117116
6882BA9627CB467D009F3DAD /* background-music.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "background-music.mp3"; sourceTree = "<group>"; };
118-
6882BA9927CB483C009F3DAD /* ball-bounce.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "ball-bounce.mp3"; sourceTree = "<group>"; };
119117
6882BA9B27CB490E009F3DAD /* ball-bounce.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "ball-bounce.wav"; sourceTree = "<group>"; };
120118
68861F0527C92DB500D2AEF7 /* SLPhysicsTriangle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SLPhysicsTriangle.swift; sourceTree = "<group>"; };
121119
689A49FF27A2CD0D00A2E4E6 /* Level.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Level.swift; sourceTree = "<group>"; };
@@ -251,7 +249,6 @@
251249
isa = PBXGroup;
252250
children = (
253251
6882BA9B27CB490E009F3DAD /* ball-bounce.wav */,
254-
6882BA9927CB483C009F3DAD /* ball-bounce.mp3 */,
255252
6882BA9627CB467D009F3DAD /* background-music.mp3 */,
256253
6882BA9427CB4293009F3DAD /* MusicManager.swift */,
257254
);
@@ -391,7 +388,6 @@
391388
isa = PBXResourcesBuildPhase;
392389
buildActionMask = 2147483647;
393390
files = (
394-
6882BA9A27CB483D009F3DAD /* ball-bounce.mp3 in Resources */,
395391
6882BA9727CB467D009F3DAD /* background-music.mp3 in Resources */,
396392
68C1B1E7279DCCD3002DF357 /* Preview Assets.xcassets in Resources */,
397393
68C1B1E4279DCCD3002DF357 /* Assets.xcassets in Resources */,

‎ps4/peggleclone/Data/Seed.json‎

Lines changed: 143 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,188 @@
11
[
22
{
3-
"id":"FDEC4F07-87CE-4BD7-9E78-6D8A1903AF34",
3+
"height":1060,
4+
"id":"6059CB65-A7B5-4BA4-B245-D5521607F413",
45
"spookyPegPersistances":[
56
{
6-
"radius":25,
7-
"id":"D8FBE88D-4813-4690-A4C2-5A58AAE80FA6",
7+
"radius":24.300000000000001,
8+
"maxRadius":48.600000000000001,
9+
"minRadius":24.300000000000001,
10+
"id":"C2BF6268-C2A8-4923-A7D7-7607D75DD160",
811
"center":{
9-
"xCoordinate":367,
10-
"yCoordinate":840.5
12+
"xCoordinate":775,
13+
"yCoordinate":836.5
1114
},
1215
"color":"peg-green"
13-
},
16+
}
17+
],
18+
"width":810,
19+
"kaboomPegPersistances":[
1420
{
15-
"radius":25,
16-
"id":"4195205D-E239-4B07-A136-9AB82A764E1F",
21+
"radius":24.300000000000001,
22+
"maxRadius":48.600000000000001,
23+
"minRadius":24.300000000000001,
24+
"id":"3D377FD2-F084-4747-8163-C69FCC6B6A91",
1725
"center":{
18-
"xCoordinate":477,
19-
"yCoordinate":744.5
26+
"xCoordinate":766.5,
27+
"yCoordinate":152
2028
},
2129
"color":"peg-green"
30+
}
31+
],
32+
"trianglePegPersistances":[
33+
{
34+
"base":48.600000000000001,
35+
"height":52.673964843749999,
36+
"center":{
37+
"xCoordinate":420.5,
38+
"yCoordinate":449.5
39+
},
40+
"id":"705C33AE-442D-41C9-B1E0-21ED8B0B9AF5",
41+
"minBase":48.600000000000001,
42+
"maxHeight":105.3479296875,
43+
"maxBase":97.200000000000003,
44+
"minHeight":52.673964843749999
45+
}
46+
],
47+
"normalPegPersistances":[
48+
{
49+
"radius":24.300000000000001,
50+
"maxRadius":48.600000000000001,
51+
"minRadius":24.300000000000001,
52+
"id":"1A8528D4-BDFD-4B14-BAC9-BD2E688E32B3",
53+
"center":{
54+
"xCoordinate":40,
55+
"yCoordinate":140.5
56+
},
57+
"color":"peg-orange"
2258
},
2359
{
24-
"radius":25,
25-
"id":"A1867069-46B5-4D66-A560-28AE2DDECF76",
60+
"radius":24.300000000000001,
61+
"maxRadius":48.600000000000001,
62+
"minRadius":24.300000000000001,
63+
"id":"D6C3203F-C958-45AD-A742-302BDBDBCBEC",
2664
"center":{
27-
"xCoordinate":522,
28-
"yCoordinate":772.5
65+
"xCoordinate":33.5,
66+
"yCoordinate":836.5
2967
},
30-
"color":"peg-green"
68+
"color":"peg-blue"
3169
}
3270
],
71+
"name":"Default level 1"
72+
},
73+
{
74+
"height":1060,
75+
"id":"13E02619-258C-45B6-BE52-E92CC4CC9C68",
76+
"spookyPegPersistances":[
77+
78+
],
79+
"width":810,
3380
"kaboomPegPersistances":[
81+
{
82+
"radius":24.300000000000001,
83+
"maxRadius":48.600000000000001,
84+
"minRadius":24.300000000000001,
85+
"id":"E694400D-9D32-48B8-9255-0C1EB2F3E404",
86+
"center":{
87+
"xCoordinate":379.5,
88+
"yCoordinate":176
89+
},
90+
"color":"peg-green"
91+
}
92+
],
93+
"trianglePegPersistances":[
3494

3595
],
36-
"name":"Default LEVEL 1",
3796
"normalPegPersistances":[
3897
{
39-
"radius":25,
40-
"id":"A8FF5993-FCAC-484C-B5C7-456261FF2D82",
98+
"radius":24.300000000000001,
99+
"maxRadius":48.600000000000001,
100+
"minRadius":24.300000000000001,
101+
"id":"F315ECD6-B101-45C9-B445-BC34AD90F785",
41102
"center":{
42-
"xCoordinate":236,
43-
"yCoordinate":647
103+
"xCoordinate":55.5,
104+
"yCoordinate":817.5
44105
},
45106
"color":"peg-orange"
46107
},
47108
{
48-
"radius":25,
49-
"id":"8FE59661-1FB9-4DA3-8AC3-405FBB3EDF75",
109+
"radius":24.300000000000001,
110+
"maxRadius":48.600000000000001,
111+
"minRadius":24.300000000000001,
112+
"id":"8F37ABD8-03CB-45E4-AD77-A7CA60E9CAA9",
50113
"center":{
51-
"xCoordinate":439.5,
52-
"yCoordinate":514.5
114+
"xCoordinate":744,
115+
"yCoordinate":815
53116
},
54117
"color":"peg-orange"
55-
},
118+
}
119+
],
120+
"name":"Default level 2"
121+
},
122+
{
123+
"height":1060,
124+
"id":"F532FB45-A0D1-430E-B130-601BCB026226",
125+
"spookyPegPersistances":[
126+
127+
],
128+
"width":810,
129+
"kaboomPegPersistances":[
130+
131+
],
132+
"trianglePegPersistances":[
56133
{
57-
"radius":25,
58-
"id":"A68268B4-5B95-4C53-A5BC-2A4B39BC7352",
134+
"base":48.600000000000001,
135+
"height":52.673964843749999,
59136
"center":{
60-
"xCoordinate":627.5,
61-
"yCoordinate":463
137+
"xCoordinate":55.5,
138+
"yCoordinate":818.5
62139
},
63-
"color":"peg-orange"
140+
"id":"C2721F0E-9463-40BB-A7DC-34D1B076CD98",
141+
"minBase":48.600000000000001,
142+
"maxHeight":105.3479296875,
143+
"maxBase":97.200000000000003,
144+
"minHeight":52.673964843749999
64145
},
65146
{
66-
"radius":25,
67-
"id":"A94F32D0-AC7A-4224-9801-25C6610D1091",
147+
"base":48.600000000000001,
148+
"height":52.673964843749999,
68149
"center":{
69-
"xCoordinate":438,
70-
"yCoordinate":635
150+
"xCoordinate":750.5,
151+
"yCoordinate":824
71152
},
72-
"color":"peg-orange"
153+
"id":"2430477C-8F54-45ED-BE88-015F3D46F579",
154+
"minBase":48.600000000000001,
155+
"maxHeight":105.3479296875,
156+
"maxBase":97.200000000000003,
157+
"minHeight":52.673964843749999
73158
},
74159
{
75-
"radius":25,
76-
"id":"1B7E2D33-22E7-4E59-A4CE-C2CD37EAC677",
160+
"base":48.600000000000001,
161+
"height":52.673964843749999,
77162
"center":{
78-
"xCoordinate":213.5,
79-
"yCoordinate":806
163+
"xCoordinate":381,
164+
"yCoordinate":508.5
165+
},
166+
"id":"73B23A48-2276-4D41-94E7-1BC66AAC5B8C",
167+
"minBase":48.600000000000001,
168+
"maxHeight":105.3479296875,
169+
"maxBase":97.200000000000003,
170+
"minHeight":52.673964843749999
171+
}
172+
],
173+
"normalPegPersistances":[
174+
{
175+
"radius":24.300000000000001,
176+
"maxRadius":48.600000000000001,
177+
"minRadius":24.300000000000001,
178+
"id":"BFC07712-5341-414D-ACA9-6D8F495B8E26",
179+
"center":{
180+
"xCoordinate":385.5,
181+
"yCoordinate":611
80182
},
81183
"color":"peg-orange"
82184
}
83-
]
185+
],
186+
"name":"Default level 3"
84187
}
85188
]

‎ps4/peggleclone/Models/KaboomPeg.swift‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,34 @@ class KaboomPeg: Peg {
1313
var explosionState = 1
1414
var radiusOfPeg: Double
1515

16-
init(center: Point, radius: Double = 25) {
16+
init(center: Point, radius: Double) {
1717
self.radiusOfPeg = radius
1818
super.init(color: .greenPeg, center: center, radius: radius)
1919
self.shadow = .red
2020
self.shadowRadius = 30.0
2121
}
2222

23-
init(id: UUID, center: Point, radius: Double = 25) {
23+
init(center: Point, radius: Double, minRadius: Double, maxRadius: Double) {
2424
self.radiusOfPeg = radius
25-
super.init(id: id, center: center, color: .greenPeg, radius: radius)
25+
super.init(color: .greenPeg, center: center, radius: radius, minRadius: minRadius, maxRadius: maxRadius)
26+
self.shadow = .red
27+
self.shadowRadius = 30.0
28+
}
29+
30+
init(id: UUID, center: Point, radius: Double, minRadius: Double, maxRadius: Double) {
31+
self.radiusOfPeg = radius
32+
super.init(id: id, center: center, color: .greenPeg, radius: radius,
33+
minRadius: minRadius, maxRadius: maxRadius)
2634
self.shadow = .red
2735
self.shadowRadius = 30.0
2836
}
2937

3038
override func glow() {
3139
renderExplosion()
32-
// self.color = .greenGlow
3340
}
3441

3542
override func copy() -> Peg {
36-
KaboomPeg(center: self.center, radius: self.radius)
43+
KaboomPeg(center: self.center, radius: self.radius, minRadius: pegMinRadius, maxRadius: pegMaxRadius)
3744
}
3845

3946
func setActivated() {

‎ps4/peggleclone/Models/Level.swift‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,30 @@ struct Level: Identifiable {
4747
}
4848
}
4949

50-
mutating func save(name: String, peggleObjects: [PeggleObject]) {
50+
mutating func save(name: String, peggleObjects: [PeggleObject], levels: [Level]) {
5151
self.peggleObjects = peggleObjects
5252
let trimmedName = name.trimmingCharacters(in: .whitespacesAndNewlines)
5353
if !trimmedName.isEmpty {
54-
self.name = trimmedName
54+
var nameToSave = trimmedName
55+
var count = 1
56+
while containsSameName(name: nameToSave, levels: levels) {
57+
nameToSave = "\(trimmedName) (\(count))"
58+
count += 1
59+
}
60+
self.name = nameToSave
5561
}
5662
countDifferentPegs()
5763
}
5864

65+
private func containsSameName(name: String, levels: [Level]) -> Bool {
66+
for level in levels {
67+
if level.name.trimmingCharacters(in: .whitespacesAndNewlines) == name && level.id != self.id {
68+
return true
69+
}
70+
}
71+
return false
72+
}
73+
5974
mutating func move(peggleObject: PeggleObject, newLocation: Point) {
6075
for peggleObj in peggleObjects where peggleObj.id == peggleObject.id {
6176
peggleObj.shiftTo(location: newLocation)
@@ -124,14 +139,9 @@ struct Level: Identifiable {
124139
}
125140
}
126141

127-
// func scale(peggleObject: PeggleObject, scale: Double) {
128-
// for peggleObj in peggleObjects where peggleObj.id == peggleObject.id {
129-
// peggleObj.scale(scale)
130-
// }
131-
// }
132-
func resizeObject(peggleObject: PeggleObject, location: Point) {
142+
func resizeObject(peggleObject: PeggleObject, location: Point, width: Double, height: Double) {
133143
for peggleObj in peggleObjects where peggleObj.id == peggleObject.id {
134-
peggleObj.resizeObject(location: location, peggleObjects: peggleObjects)
144+
peggleObj.resizeObject(location: location, peggleObjects: peggleObjects, width: width, height: height)
135145
}
136146
}
137147
}

0 commit comments

Comments
 (0)