diff --git a/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj b/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj index bf697b9..62777f8 100644 --- a/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj +++ b/DouShouQi_App/DouShouQi_App.xcodeproj/project.pbxproj @@ -31,7 +31,6 @@ 649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59AD2BF64EAB002BAE38 /* AppImages.swift */; }; 649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B12BF65392002BAE38 /* TextStyles.swift */; }; 649B59B42BF653E1002BAE38 /* ViewTitleTextStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */; }; - EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */; }; EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4F82C0371660048CD0B /* MusicPlayer.swift */; }; EC62C4FB2C038BD20048CD0B /* PlayersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FA2C038BD20048CD0B /* PlayersView.swift */; }; EC62C4FD2C0391D30048CD0B /* PlayerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */; }; @@ -104,7 +103,6 @@ 649B59AD2BF64EAB002BAE38 /* AppImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppImages.swift; sourceTree = ""; }; 649B59B12BF65392002BAE38 /* TextStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStyles.swift; sourceTree = ""; }; 649B59B32BF653E1002BAE38 /* ViewTitleTextStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTitleTextStyle.swift; sourceTree = ""; }; - EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = ""; }; EC62C4F82C0371660048CD0B /* MusicPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicPlayer.swift; sourceTree = ""; }; EC62C4FA2C038BD20048CD0B /* PlayersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayersView.swift; sourceTree = ""; }; EC62C4FC2C0391D30048CD0B /* PlayerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerRow.swift; sourceTree = ""; }; @@ -156,7 +154,6 @@ isa = PBXGroup; children = ( 643AB69A2BFCFB5C0018DA73 /* HistoricView.swift */, - EC62C4EE2BFE367F0048CD0B /* SwiftUIView.swift */, ); path = Game; sourceTree = ""; @@ -498,7 +495,6 @@ 649B59AE2BF64EAB002BAE38 /* AppImages.swift in Sources */, 649ABF602BF60F2D002E8894 /* MainMenuButton.swift in Sources */, 643AB6932BFCEFD00018DA73 /* GameResumeFrame.swift in Sources */, - EC62C4EF2BFE367F0048CD0B /* SwiftUIView.swift in Sources */, 649B59B22BF65392002BAE38 /* TextStyles.swift in Sources */, EC62C5092C0467240048CD0B /* SplashScreenView.swift in Sources */, EC62C4F92C0371660048CD0B /* MusicPlayer.swift in Sources */, diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/AppImages.swift b/DouShouQi_App/DouShouQi_App/Assets/Images/AppImages.swift index 1a06ad9..e133776 100644 --- a/DouShouQi_App/DouShouQi_App/Assets/Images/AppImages.swift +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/AppImages.swift @@ -11,6 +11,12 @@ import SwiftUI public struct AppImages { static let TitleImage = "TitlePageImage" static let SemiLion = "SemiLion" + static let SemiDog = "SemiDog" + static let SemiElephant = "SemiElephant" + static let SemiCat = "SemiCat" + static let SemiRat = "SemiRat" + static let SemiLeopard = "SemiLeopard" + static let SemiWolf = "SemiWolf" static let Lion = "Lion" static let Rat = "Rat" static let Elephant = "Elephant" diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiCat.imageset/Contents.json b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiCat.imageset/Contents.json new file mode 100644 index 0000000..0fd38f6 --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiCat.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SemiCat.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiCat.imageset/SemiCat.png b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiCat.imageset/SemiCat.png new file mode 100644 index 0000000..eeb278e Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiCat.imageset/SemiCat.png differ diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiDog.imageset/Contents.json b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiDog.imageset/Contents.json new file mode 100644 index 0000000..0c7dbb7 --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiDog.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SemiDog.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiDog.imageset/SemiDog.png b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiDog.imageset/SemiDog.png new file mode 100644 index 0000000..90b7caa Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiDog.imageset/SemiDog.png differ diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiElephant.imageset/Contents.json b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiElephant.imageset/Contents.json new file mode 100644 index 0000000..42d393a --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiElephant.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SemiElephant.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiElephant.imageset/SemiElephant.png b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiElephant.imageset/SemiElephant.png new file mode 100644 index 0000000..1c10540 Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiElephant.imageset/SemiElephant.png differ diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiLeopard.imageset/Contents.json b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiLeopard.imageset/Contents.json new file mode 100644 index 0000000..362d6c2 --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiLeopard.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SemiLeopard.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiLeopard.imageset/SemiLeopard.png b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiLeopard.imageset/SemiLeopard.png new file mode 100644 index 0000000..07ffa2a Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiLeopard.imageset/SemiLeopard.png differ diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiRat.imageset/Contents.json b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiRat.imageset/Contents.json new file mode 100644 index 0000000..f275ddd --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiRat.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SemiRat.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiRat.imageset/SemiRat.png b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiRat.imageset/SemiRat.png new file mode 100644 index 0000000..a2bd6c8 Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiRat.imageset/SemiRat.png differ diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiTiger.imageset/Contents.json b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiTiger.imageset/Contents.json new file mode 100644 index 0000000..dfafd53 --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiTiger.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SemiTiger.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiTiger.imageset/SemiTiger.png b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiTiger.imageset/SemiTiger.png new file mode 100644 index 0000000..4ecf88e Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiTiger.imageset/SemiTiger.png differ diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiWolf.imageset/Contents.json b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiWolf.imageset/Contents.json new file mode 100644 index 0000000..6b8435c --- /dev/null +++ b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiWolf.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SemiWolf.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiWolf.imageset/SemiWolf.png b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiWolf.imageset/SemiWolf.png new file mode 100644 index 0000000..5b282ef Binary files /dev/null and b/DouShouQi_App/DouShouQi_App/Assets/Images/Images.xcassets/SemiWolf.imageset/SemiWolf.png differ diff --git a/DouShouQi_App/DouShouQi_App/Components/Player/PlayerRow.swift b/DouShouQi_App/DouShouQi_App/Components/Player/PlayerRow.swift index b8acb4e..9f5d053 100644 --- a/DouShouQi_App/DouShouQi_App/Components/Player/PlayerRow.swift +++ b/DouShouQi_App/DouShouQi_App/Components/Player/PlayerRow.swift @@ -41,6 +41,7 @@ struct PlayerRow: View { .foregroundColor(.black) } Button(action: { + }) { Image(systemName: "trash") diff --git a/DouShouQi_App/DouShouQi_App/Views/Game/SwiftUIView.swift b/DouShouQi_App/DouShouQi_App/Views/Game/SwiftUIView.swift deleted file mode 100644 index e544d48..0000000 --- a/DouShouQi_App/DouShouQi_App/Views/Game/SwiftUIView.swift +++ /dev/null @@ -1,98 +0,0 @@ -// -// SwiftUIView.swift -// DouShouQi_App -// -// Created by étudiant on 22/05/2024. -// - -import SwiftUI - -struct SwiftUIView: View { - var body: some View { - VStack { - TitlePageFrame(Text: "DOU SHOU QI", ImageWidth: 200, ImageHeight: 200) - Spacer() - - VStack { - HStack{ - VStack { - Button(action: { - // Action du bouton - }, label: { - Text("Play".uppercased()) - .font(.headline) - .fontWeight(.semibold) - .foregroundColor(.white) - .frame(maxWidth: .infinity, maxHeight: 50) - .background( - Color.red - ) - .cornerRadius(0) - }) - .frame(width: UIScreen.main.bounds.width / 1.7) - .frame(maxWidth: .infinity, alignment: .leading) - - Button(action: { - // Action du bouton - }, label: { - Text("Historique".uppercased()) - .font(.headline) - .fontWeight(.semibold) - .foregroundColor(.white) - .frame(maxWidth: .infinity, maxHeight: 50) - .background( - Color.red - ) - .cornerRadius(0) - }) - .frame(width: UIScreen.main.bounds.width / 1.7) - .frame(maxWidth: .infinity, alignment: .leading) - - Button(action: { - // Action du bouton - }, label: { - Text("Best scores".uppercased()) - .font(.headline) - .fontWeight(.semibold) - .foregroundColor(.white) - .frame(maxWidth: .infinity, maxHeight: 50) - .background( - Color.red - ) - .cornerRadius(0) - }) - .frame(width: UIScreen.main.bounds.width / 1.7) - .frame(maxWidth: .infinity, alignment: .leading) - - Button(action: { - // Action du bouton - }, label: { - Text("Players".uppercased()) - .font(.headline) - .fontWeight(.semibold) - .foregroundColor(.white) - .frame(maxWidth: .infinity, maxHeight: 50) - .background( - Color.red - ) - .cornerRadius(0) - }) - .frame(width: UIScreen.main.bounds.width / 1.7) - .frame(maxWidth: .infinity, alignment: .leading) - } - .padding() - } - } - .padding(.horizontal, 10) - - Spacer() - } - } -} - - -struct SwiftUIView_Previews: PreviewProvider { - static var previews: some View { - SwiftUIView() - } -} diff --git a/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift b/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift index 402941e..d0e7004 100644 --- a/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift +++ b/DouShouQi_App/DouShouQi_App/Views/Menu/MainMenuView.swift @@ -10,6 +10,10 @@ import SwiftUI struct MainMenuView: View { @State private var showSplash = true + @State private var currentImage: String? + @State private var timer: Timer? + @State private var showImage = false + let images: [String] = [AppImages.SemiLion, AppImages.SemiDog, AppImages.SemiRat, AppImages.SemiWolf, AppImages.SemiLeopard, AppImages.SemiElephant, AppImages.SemiCat] // Add your image names here var body: some View { NavigationView { @@ -37,10 +41,19 @@ struct MainMenuView: View { MainMenuButton(text: "Best Scores", destination: ScoreBoardView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10) MainMenuButton(text: "Players", destination: PlayersView(), sound: "TitleScreenButtonSound", topRightCorner: 10, bottomRightCorner: 10) } - Image(AppImages.SemiLion) - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 200, height: 500) + if let currentImage = currentImage { + Image(currentImage) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 200, height: 500) + .transition(.opacity) + .animation(.easeInOut(duration: 1), value: showImage) + .onAppear { + withAnimation { + showImage = true + } + } + } } } Spacer() @@ -65,15 +78,35 @@ struct MainMenuView: View { Spacer() .onAppear { + startTimer() MusicPlayer.shared.playBackgroundMusic(music: "TitleScreenMusic") } .onDisappear { + stopTimer() MusicPlayer.shared.stopBackgroundMusic() } } } } } + + private func startTimer() { + timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { _ in + changeImage() + } + changeImage() // Immediately change the image on appear + } + + private func stopTimer() { + timer?.invalidate() + timer = nil + } + + private func changeImage() { + DispatchQueue.main.async { + currentImage = images.randomElement() + } + } } struct MainMenuView_Previews: PreviewProvider {