diff --git a/DouShouQi_App/DouShouQi_App/Views/Game/GameView.swift b/DouShouQi_App/DouShouQi_App/Views/Game/GameView.swift index 9ea517b..ee83ab3 100644 --- a/DouShouQi_App/DouShouQi_App/Views/Game/GameView.swift +++ b/DouShouQi_App/DouShouQi_App/Views/Game/GameView.swift @@ -10,24 +10,50 @@ import SpriteKit import DouShouQiModel struct GameView: View { - @StateObject var gameVM: PlayingGameVM = PlayingGameVM(withRules: ClassicRules(), andPlayer1: DouShouQiModel.HumanPlayer(withName: "Rémi", andId: .player1)!, andPlayer2: DouShouQiModel.HumanPlayer(withName: "Nathan", andId: .player2)!)! + + @StateObject var gameVM: PlayingGameVM + + @State private var showHome = false var body: some View { - VStack { - TopGameBoard(gameVM: gameVM).frame(maxHeight: 200) - SpriteView(scene: GameScene(size: CGSize(width: 700, height: 900), gameVM: gameVM)) - } - .onAppear { - MusicPlayer.shared.playBackgroundMusic(music: "GameMusic") - } - .onDisappear { - MusicPlayer.shared.stopBackgroundMusic() + ZStack { + VStack { + TopGameBoard(gameVM: gameVM).frame(maxHeight: 200) + SpriteView(scene: GameScene(size: CGSize(width: 700, height: 900), gameVM: gameVM)) + } + .onAppear { + MusicPlayer.shared.playBackgroundMusic(music: "GameMusic") + } + .onDisappear { + MusicPlayer.shared.stopBackgroundMusic() + } + + if (gameVM.game.isOver) { + HStack { + Spacer() + + VStack(alignment: .center) { + Text("Game Over") + .font(.title2) + Text("Winner: \(gameVM.winner)") + } + .background(Colors.WinnerBackground) + + Spacer() + } + .onAppear { + Timer.scheduledTimer(withTimeInterval: 10, repeats: false) { _ in + + // Il faut retourner au home + } + } + } } } } -struct GameView_Previews: PreviewProvider { +/*struct GameView_Previews: PreviewProvider { static var previews: some View { GameView() } -} +}*/