Don't allow pieces to be moved after they're dropped
This commit is contained in:
parent
496f061059
commit
3e7baecd27
|
@ -73,7 +73,8 @@ struct ContentView: View {
|
||||||
func horizDragGesture(geometry: GeometryProxy) -> some Gesture {
|
func horizDragGesture(geometry: GeometryProxy) -> some Gesture {
|
||||||
DragGesture(coordinateSpace: .global)
|
DragGesture(coordinateSpace: .global)
|
||||||
.onChanged { (state) in
|
.onChanged { (state) in
|
||||||
guard let currentPiece = self.controller.currentPiece else { return }
|
guard case .playing(.normal) = self.controller.state,
|
||||||
|
let currentPiece = self.controller.currentPiece else { return }
|
||||||
if self.initialXPosition == nil {
|
if self.initialXPosition == nil {
|
||||||
self.initialXPosition = currentPiece.topLeft.0
|
self.initialXPosition = currentPiece.topLeft.0
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class GameController: ObservableObject {
|
||||||
public let width = 10
|
public let width = 10
|
||||||
public let height = 20
|
public let height = 20
|
||||||
|
|
||||||
var state: GameState = .waitingForStart
|
public var state: GameState = .waitingForStart
|
||||||
|
|
||||||
@Published public var board: GameBoard
|
@Published public var board: GameBoard
|
||||||
|
|
||||||
|
@ -155,12 +155,12 @@ public class GameController: ObservableObject {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum GameState {
|
public enum GameState {
|
||||||
case waitingForStart
|
case waitingForStart
|
||||||
case playing(PlayState)
|
case playing(PlayState)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PlayState {
|
public enum PlayState {
|
||||||
case normal
|
case normal
|
||||||
case dropped
|
case dropped
|
||||||
case switched
|
case switched
|
||||||
|
|
Loading…
Reference in New Issue