{"id":15038528,"url":"https://github.com/halilozel1903/stonepaperscissorsgame","last_synced_at":"2025-04-09T23:41:19.202Z","repository":{"id":91423832,"uuid":"141718709","full_name":"halilozel1903/StonePaperScissorsGame","owner":"halilozel1903","description":"Rock Paper Scissors 🪨 📄 ✂️  game is an iOS application developed 💻 with Swift 5.7 🏆","archived":false,"fork":false,"pushed_at":"2023-10-07T15:22:32.000Z","size":3347,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T01:35:17.451Z","etag":null,"topics":["game","game-developement","game-development","ios","ios-animation","ios-app","ios-app-development","ios-application","ios-demo","ios-dev","ios-game","ios-swift","ios-ui","stone-paper-scissors","swift","swift-5","swift-game","swift-game-engine","swift-language","swift5"],"latest_commit_sha":null,"homepage":"https://halilozel1903.medium.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halilozel1903.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-07-20T13:58:58.000Z","updated_at":"2024-06-18T06:21:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"d222aa97-c916-45dd-af3b-f5db6e649841","html_url":"https://github.com/halilozel1903/StonePaperScissorsGame","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FStonePaperScissorsGame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FStonePaperScissorsGame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FStonePaperScissorsGame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FStonePaperScissorsGame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halilozel1903","download_url":"https://codeload.github.com/halilozel1903/StonePaperScissorsGame/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131467,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game","game-developement","game-development","ios","ios-animation","ios-app","ios-app-development","ios-application","ios-demo","ios-dev","ios-game","ios-swift","ios-ui","stone-paper-scissors","swift","swift-5","swift-game","swift-game-engine","swift-language","swift5"],"created_at":"2024-09-24T20:38:47.089Z","updated_at":"2025-04-09T23:41:19.181Z","avatar_url":"https://github.com/halilozel1903.png","language":"Swift","funding_links":["https://www.buymeacoffee.com/halilozel1903"],"categories":[],"sub_categories":[],"readme":"# Rock 🪨 Paper 📃 Scissors ✂️ Game 🏆\n\n![Screenshot](taskagitmakas.jpg)\n\n## The goal of the project 🌎\n\nRock Paper Scissors game is an iOS application developed with Swift-5.\nThe aim is to show the user how to play in a simple way in iOS applications.\n\n## Project Content ℹ️\nIt is a project developed with Swift 5.5 You will learn the usage of components such as Button, Image, Label. \u003cbr\u003e\n\n## How to Play the Game ⁉️\nThere are 2 competitors in the game, a user and a computer. Our opponent is random according to our choice\nit waits for its result against us by offering a choice. If he uses a good employee from us, he gets 1 point. If we win\nour score increases by 1. If it is equal, the game continues without changing anything. The states of the structures relative to each other\nis as follows:\n\n1. Rock - Paper: Paper\n2. Rock - Scissors: Stone\n3. Rock - Rock: Draw\n4. Paper - Paper: Draw\n5. Paper - Scissors: Scissors\n6. Paper - Rock: Paper\n7. Scissors - Paper: Scissors\n8. Scissors - Scissors: Draw\n9. Scissors - Rock: Stone\n\n \u003cbr\u003e\n\n## Screen Design 📱\n\n\u003cp\u003e\n  \u003cimg src=\"pic1.png\" width=\"300\" \u003e\n\u003c/p\u003e\n\nWe used various structures in screen design. 3 buttons were used. Other remaining structures are label elements.\nIt was designed with a label, with fields where values are updated in cases of gain or loss.\nYou can find the pictures used in the background of the buttons in the following file:\n\nhttps://github.com/halilozel1903/StonePaperScissorsGame/tree/master/TasKagitMakas/TasKagitMakas/Assets.xcassets\n\nWe are now linking the designed codes in the ```ViewController.swift``` file:\n\n```java \n  // MARK: - Variables \n  // MARK: - IBOutlets\n  // MARK: - IBActions\n```\n We are editing the codes we have written with a new usage style. Defined structures are variables, definitions\n and button operations. We will be able to navigate easily within the project as follows:\n \n \u003cp\u003e\n  \u003cimg src=\"Screen%20Shot%202018-07-22%20at%2011.27.02%20PM.png\" \u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n## Writing the Codes 💻\n\n\n```swift \n// MARK: - Variables\n    var myPoints = 0\n    var pcPoints = 0\n    let array = [\"rock\",\"paper\",\"scissors\"] // An array of string type was created.\n```\nTwo variables were defined to keep the user's score and the computer's score. 0 is assigned to their initial value.\nAn array of type string has been defined. The options used in the game have been added into the Array.\n\n\u003cbr\u003e\n\n```swift \n // MARK: - IBOutlets\n    @IBOutlet weak var myChoiseLabel: UILabel!\n    @IBOutlet weak var pcChoiseLabel: UILabel!\n    @IBOutlet weak var theEndLabel: UILabel!\n    @IBOutlet weak var myPointsLabel: UILabel!\n    @IBOutlet weak var pcPointsLabel: UILabel!\n```\n\nWe defined the Labels in the design with code. Labels showing the points obtained by the user and the computer,\na label indicating who is the winner and a label describing who won according to the total result.\n\n\u003cbr\u003e\n\nNow we will write 3 methods to define the operations that will occur when the buttons are clicked. Their functions are similar.\n\n```swift \n@IBAction func rockSelected(_ sender: Any) {\n        \n        let randomSelected = Int(arc4random_uniform(3)) // 0,1,2\n        let pcSelected = array[randomSelected] // random element will be taken from the array.\n        \n        if pcSelected == \"rock\" {\n            myChoiseLabel.text = \"Your Choice : Rock\"\n            pcChoiseLabel.text = \"Computer Choice : Rock\"\n            theEndLabel.text = \"Tie.\"\n            \n            \n        }else if pcSelected == \"paper\" {\n            myChoiseLabel.text = \"Your Choice : Rock\"\n            pcChoiseLabel.text = \"Computer Choice : Paper\"\n            theEndLabel.text = \"Computer won.\"\n            \n            pcPoints += 1\n            \n            pcPointsLabel.text = String(pcPoints)\n            \n        }else if pcSelected == \"scissors\" {\n            myChoiseLabel.text = \"Your Choice : Rock\"\n            pcChoiseLabel.text = \"Computer Choice : Scissors\"\n            theEndLabel.text = \"You won\"\n            \n            myPoints += 1\n            \n            myPointsLabel.text = String(myPoints)\n            \n        }\n    }\n```\n\nWe generate a random number between 0-2 using the random number generator function. This generated value is assigned to the value of array.\nThen the comparison is made. If the computer selects the \"stone\" option, a stone will be written on the selected part of the screen. As a result, because we chose stones, the result is a draw. If we choose stone and paper on the computer, the computer wins the game and gets 1 point. The message on the screen shows the computer won. If we are stone and computer scissors, we win and our score increases by 1 and the screen says you won.\n\n \u003cbr\u003e\n\n```swift \n\n // paper handling\n    @IBAction func paperSelected(_ sender: Any) {\n        \n        let randomSelected = Int(arc4random_uniform(3)) // 0,1,2\n        let pcSelected = array[randomSelected] // random element will be taken from the array.\n        \n        if pcSelected == \"rock\" {\n            myChoiseLabel.text = \"Your Choice : Paper\"\n            pcChoiseLabel.text = \"Computer Choice : Rock\"\n            theEndLabel.text = \"You won.\"\n            \n            myPoints += 1\n            \n            myPointsLabel.text = String(myPoints)\n            \n            \n        }else if pcSelected == \"paper\" {\n            myChoiseLabel.text = \"Your Choice : Paper\"\n            pcChoiseLabel.text = \"Computer Choice : Paper\"\n            theEndLabel.text = \"Tie.\"\n            \n        \n            \n        }else if pcSelected == \"scissors\" {\n            myChoiseLabel.text = \"Your Choice : Paper\"\n            pcChoiseLabel.text = \"Computer Choice : Scissors\"\n            theEndLabel.text = \"Computer won.\"\n            \n            pcPoints += 1\n            \n            pcPointsLabel.text = String(pcPoints)\n            \n        }\n        \n    }\n\n```\n\nThis time, we become paper in our choices. The status of the paper compared to other components is checked. Much to the stone method\nThis similar method performs the desired operations with only a slight change.\n\n \u003cbr\u003e\n\n```swift \n\n// scissors related operations\n    @IBAction func scissorSelected(_ sender: Any) {\n        \n        let randomSelected = Int(arc4random_uniform(3)) // 0,1,2\n        let pcSelected = array[randomSelected] // random element will be taken from the array.\n        \n        if pcSelected == \"rock\" {\n            myChoiseLabel.text = \"Your Choice  : Rock\"\n            pcChoiseLabel.text = \"Bilgisayarın seçimi : Taş\"\n            theEndLabel.text = \"Computer won.\"\n            \n            pcPoints += 1\n            \n            pcPointsLabel.text = String(pcPoints)\n            \n            \n        }else if pcSelected == \"paper\" {\n            myChoiseLabel.text = \"Your Choice  : scissors\"\n            pcChoiseLabel.text = \"Computer Choice : Paper\"\n            theEndLabel.text = \"You won.\"\n            \n            myPoints += 1\n            \n            myPointsLabel.text = String(myPoints)\n           \n            \n        }else if pcSelected == \"scissors\" {\n            myChoiseLabel.text = \"Your Choice  : scissors\"\n            pcChoiseLabel.text = \"Computer Choice : scissors\"\n            theEndLabel.text = \"Tie\"\n           \n            \n        }\n        \n    }\n\n```\n\nWe have created a method to do the latest scissors related operations. If the scissors prevail, our score will increase by 1 if\nIf the value of the computer wins, the value of the computer will increase by 1. The result will not change if we have equal options.\n\n \u003cbr\u003e\n\n## Application Demo 📸\n\n\n\u003cimg src=\"https://github.com/halilozel1903/StonePaperScissorsGame/blob/master/res1.png\" width=\"200\" /\u003e  \u003cimg src=\"https://github.com/halilozel1903/StonePaperScissorsGame/blob/master/res2.png\" width=\"200\" /\u003e  \u003cimg src=\"https://github.com/halilozel1903/StonePaperScissorsGame/blob/master/res3.png\" width=\"200\" /\u003e\n\n  \u003cimg src=\"res4.png\" width=\"200\" /\u003e  \u003cimg src=\"res5.png\" width=\"200\" /\u003e \u003cimg src=\"res6.png\" width=\"200\" /\u003e\n\n \u003cbr\u003e\n \n ## Donation 💸\n\nIf this project help 💁 you to develop, you can give me a cup of coffee. ☕\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/halilozel1903)\n\n## License 📚\n```\nMIT License\n\nCopyright (c) 2023 Halil OZEL\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fstonepaperscissorsgame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalilozel1903%2Fstonepaperscissorsgame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fstonepaperscissorsgame/lists"}