25: guess rock, scissors, paper

그루두·2024년 5월 8일
0

100 days of SwiftUI

목록 보기
34/108

100 days of swiftui: 25
https://www.hackingwithswift.com/100/swiftui/25

challenge

So, very roughly:

  • Each turn of the game the app will randomly pick either rock, paper, or scissors.
  • Each turn the app will alternate between prompting the player to win or lose.
  • The player must then tap the correct move to win or lose the game.
  • If they are correct they score a point; otherwise they lose a point.
  • The game ends after 10 questions, at which point their score is shown.

So, if the app chose “Rock” and “Win” the player would need to choose “Paper”, but if the app chose “Rock” and “Lose” the player would need to choose “Scissors”.

solution

코드 파일
https://github.com/treesofgroo/Ios-GuessFlags/blob/main/GuessRockScissorsPaper/GuessRockScissorsPaper/ContentView.swift

history 순서
1. 가위, 바위, 보를 랜덤으로 선택 후 사용자가 선택할 수 있는 선택지 버튼과 함께 화면에 나타낸다.

https://github.com/treesofgroo/Ios-GuessFlags/commits/main/GuessRockScissorsPaper/GuessRockScissorsPaper/ContentView.swift

  1. win, lose 상황을 만들고 각 상황에 올바른 선택을 했느냐에 따라 결과를 결정한다.

    https://github.com/treesofgroo/Ios-GuessFlags/commit/2e8365a3131eae87d6faa07a60b4334f3d16c89b

  2. 선택지를 선택하면 화면에 alert를 나타낸다.

    https://github.com/treesofgroo/Ios-GuessFlags/commit/391f466b57541fea8fe94508bfacdc0acf075075

  3. alert에서 버튼을 클릭하면 새로운 문제를 세팅한다.

    https://github.com/treesofgroo/Ios-GuessFlags/commit/802e3c7570fed2c72663b16150ba5968e64741ff

  4. score를 만들고 결과에 따라 값을 조정한다.

    https://github.com/treesofgroo/Ios-GuessFlags/commit/ee796e64b6ee80a9f158667c0199311337b311e5

  5. 문제의 진행도를 설정하고 화면에 나타낸다.

    https://github.com/treesofgroo/Ios-GuessFlags/commit/50154ff8a464370683c2ef986302c8b97c3d955f

profile
계속 해보자

0개의 댓글

관련 채용 정보