diff --git a/Privyet/Assets.xcassets/gameboard.imageset/gameboard.png b/Privyet/Assets.xcassets/gameboard.imageset/gameboard.png index 924ad1e..f129b18 100644 Binary files a/Privyet/Assets.xcassets/gameboard.imageset/gameboard.png and b/Privyet/Assets.xcassets/gameboard.imageset/gameboard.png differ diff --git a/Privyet/Assets.xcassets/gameboard.imageset/gameboard@2x.png b/Privyet/Assets.xcassets/gameboard.imageset/gameboard@2x.png index f5bd959..032d436 100644 Binary files a/Privyet/Assets.xcassets/gameboard.imageset/gameboard@2x.png and b/Privyet/Assets.xcassets/gameboard.imageset/gameboard@2x.png differ diff --git a/Privyet/Block.swift b/Privyet/Block.swift index 7366c08..0e32bbb 100644 --- a/Privyet/Block.swift +++ b/Privyet/Block.swift @@ -9,11 +9,9 @@ import Foundation import SpriteKit -let NumberOfColors: UInt32 = 6 - // Colors that may be applied to blocks (whcih controls the sprite image they use) -enum BlockColor: Int, CustomStringConvertible { - case Blue = 0, Orange, Purple, Red, Teal, Yellow +enum BlockColor: Int, CustomStringConvertible, CaseIterable { + case Blue = 0, Orange, Purple, Red, Teal, Yellow, Green var spriteName: String { switch self { @@ -29,6 +27,8 @@ enum BlockColor: Int, CustomStringConvertible { return "teal" case .Yellow: return "yellow" + case .Green: + return "green" } } @@ -37,7 +37,7 @@ enum BlockColor: Int, CustomStringConvertible { } static func random() -> BlockColor { - return BlockColor(rawValue:Int(arc4random_uniform(NumberOfColors)))! + return BlockColor.allCases.shuffled().first! } } diff --git a/Privyet/GameScene.swift b/Privyet/GameScene.swift index 99ee8ad..e1c9639 100644 --- a/Privyet/GameScene.swift +++ b/Privyet/GameScene.swift @@ -170,13 +170,13 @@ class GameScene: SKScene { // Animate the "removed" blocks "exploding" for rowToRemove in linesToRemove { for block in rowToRemove { - let randomRadius = CGFloat(UInt(arc4random_uniform(400) + 100)) - let goLeft = arc4random_uniform(100) % 2 == 0 + let randomRadius = CGFloat(Float.random(in: 100.0 ... 500.0)) + let goLeft = Bool.random() var point = pointForColumn(column: block.column, row: block.row) point = CGPoint(x: point.x + (goLeft ? -randomRadius : randomRadius), y: point.y) - let randomDuration = TimeInterval(arc4random_uniform(2)) + 0.5 + let randomDuration = TimeInterval(Float.random(in: 0.5 ... 2.5)) var startAngle = CGFloat(Double.pi) var endAngle = startAngle * 2 diff --git a/Privyet/Shape.swift b/Privyet/Shape.swift index 574fb83..47fd7ea 100644 --- a/Privyet/Shape.swift +++ b/Privyet/Shape.swift @@ -9,10 +9,10 @@ import Foundation import SpriteKit -let NumOrientations: UInt32 = 4 +//let NumOrientations: UInt32 = 4 // Represents the orientation of a shape in increments of 90 degrees -enum Orientation: Int, CustomStringConvertible { +enum Orientation: Int, CustomStringConvertible, CaseIterable { case Zero = 0, Ninety, OneEighty, TwoSeventy var description: String { @@ -29,7 +29,7 @@ enum Orientation: Int, CustomStringConvertible { } static func random() -> Orientation { - return Orientation(rawValue:Int(arc4random_uniform(NumOrientations)))! + return Orientation.allCases.shuffled().first! } // Returns the orientation resulting from a rotation in either direction. @@ -45,7 +45,7 @@ enum Orientation: Int, CustomStringConvertible { } // The number of total shape varieties -let NumShapeTypes: UInt32 = 7 +let NumShapeTypes = 7 // Shape indexes let FirstBlockIdx: Int = 0 @@ -192,7 +192,7 @@ class Shape: Hashable, CustomStringConvertible { // Generates a random shape. final class func random(startingColumn: Int, startingRow: Int) -> Shape { - switch Int(arc4random_uniform(NumShapeTypes)) { + switch Int.random(in: 0 ..< NumShapeTypes) { case 0: return SquareShape(column: startingColumn, row: startingRow) case 1: diff --git a/Privyet/Sprites.atlas/blue.png b/Privyet/Sprites.atlas/blue.png index 16337e9..644a25d 100755 Binary files a/Privyet/Sprites.atlas/blue.png and b/Privyet/Sprites.atlas/blue.png differ diff --git a/Privyet/Sprites.atlas/blue@2x.png b/Privyet/Sprites.atlas/blue@2x.png index 9deb295..8918912 100755 Binary files a/Privyet/Sprites.atlas/blue@2x.png and b/Privyet/Sprites.atlas/blue@2x.png differ diff --git a/Privyet/Sprites.atlas/green.png b/Privyet/Sprites.atlas/green.png new file mode 100644 index 0000000..1f54313 Binary files /dev/null and b/Privyet/Sprites.atlas/green.png differ diff --git a/Privyet/Sprites.atlas/green@2x.png b/Privyet/Sprites.atlas/green@2x.png new file mode 100644 index 0000000..009f1c8 Binary files /dev/null and b/Privyet/Sprites.atlas/green@2x.png differ diff --git a/Privyet/Sprites.atlas/orange.png b/Privyet/Sprites.atlas/orange.png index ffd8099..493c445 100755 Binary files a/Privyet/Sprites.atlas/orange.png and b/Privyet/Sprites.atlas/orange.png differ diff --git a/Privyet/Sprites.atlas/orange@2x.png b/Privyet/Sprites.atlas/orange@2x.png index 92c328f..a127170 100755 Binary files a/Privyet/Sprites.atlas/orange@2x.png and b/Privyet/Sprites.atlas/orange@2x.png differ diff --git a/Privyet/Sprites.atlas/purple.png b/Privyet/Sprites.atlas/purple.png index b9c02a2..c0e38d9 100755 Binary files a/Privyet/Sprites.atlas/purple.png and b/Privyet/Sprites.atlas/purple.png differ diff --git a/Privyet/Sprites.atlas/purple@2x.png b/Privyet/Sprites.atlas/purple@2x.png index b4d0409..b3d5c53 100755 Binary files a/Privyet/Sprites.atlas/purple@2x.png and b/Privyet/Sprites.atlas/purple@2x.png differ diff --git a/Privyet/Sprites.atlas/red.png b/Privyet/Sprites.atlas/red.png index 524a39f..fc81583 100755 Binary files a/Privyet/Sprites.atlas/red.png and b/Privyet/Sprites.atlas/red.png differ diff --git a/Privyet/Sprites.atlas/red@2x.png b/Privyet/Sprites.atlas/red@2x.png index 3fba602..076f1c6 100755 Binary files a/Privyet/Sprites.atlas/red@2x.png and b/Privyet/Sprites.atlas/red@2x.png differ diff --git a/Privyet/Sprites.atlas/teal.png b/Privyet/Sprites.atlas/teal.png index 736fcd1..be8a6d5 100755 Binary files a/Privyet/Sprites.atlas/teal.png and b/Privyet/Sprites.atlas/teal.png differ diff --git a/Privyet/Sprites.atlas/teal@2x.png b/Privyet/Sprites.atlas/teal@2x.png index 246b293..243f71e 100755 Binary files a/Privyet/Sprites.atlas/teal@2x.png and b/Privyet/Sprites.atlas/teal@2x.png differ diff --git a/Privyet/Sprites.atlas/yellow.png b/Privyet/Sprites.atlas/yellow.png index f2c9ff1..a4fac10 100755 Binary files a/Privyet/Sprites.atlas/yellow.png and b/Privyet/Sprites.atlas/yellow.png differ diff --git a/Privyet/Sprites.atlas/yellow@2x.png b/Privyet/Sprites.atlas/yellow@2x.png index e4e50d0..e398c96 100755 Binary files a/Privyet/Sprites.atlas/yellow@2x.png and b/Privyet/Sprites.atlas/yellow@2x.png differ