Stanford University's course CS193p (Developing Applications for iOS using SwiftUI)

Overview

Memorize Game 🎮

Stanford University's course CS193p (Developing Applications for iOS using SwiftUI)

GitHub license GitHub stars GitHub forks visitors




About the game

You need to turn over the cards one by one to find the same cards. When you find two identical cards, you get one point and these cards will disappear. The game ends when you find all the pairs.

Technology

  • Swift
  • SwiftUI
  • MVVM

Screenshots

        

Sample code

MemoryGame.swift

    struct Card: Identifiable {
        var isFaceUp: Bool = false {
            didSet {
                if isFaceUp {
                    startUsingBonusTime()
                } else {
                    stopUsingBonusTime()
                }
            }
        }
        var isMatched: Bool = false {
            didSet {
                stopUsingBonusTime()
            }
        }
        var content: CardContent
        var id: Int
        
        // can be zero which means "no bonus available" for this card
        var bonusTimeLimit: TimeInterval = 10
        
        // how long this card has ever been face up
        private var faceUpTime: TimeInterval {
            if let lastFaceUpDate = self.lastFaceUpDate {
                return pastFaceUpTime + Date().timeIntervalSince(lastFaceUpDate)
            } else {
                return pastFaceUpTime
            }
        }
        // the last time this card was turned face up (and is still face up)
        var lastFaceUpDate: Date?
        // the accumulated  time yhis card has been face up in the past
        // (i.e. not including the current time it`s been face up if it is currently so)
        var pastFaceUpTime: TimeInterval = 0
        
        // how much time left before the bonus opportunity runs out
        var bonusTimeRemaining: TimeInterval {
            max(0, bonusTimeLimit - faceUpTime)
        }
        // percentage of the bonus time remaining
        var bonusRemaining: Double {
            (bonusTimeLimit > 0 && bonusTimeRemaining > 0) ? bonusTimeRemaining/bonusTimeLimit : 0
        }
        // whether the card was matched during the bonus time period
        var hasEarnedBonus: Bool {
            isMatched && bonusTimeRemaining > 0
        }
        // whether we are currently face up, unmatched and have not yet used up the bonus window
        var isConsumingBonusTime: Bool {
            isFaceUp && !isMatched && bonusTimeRemaining > 0
        }
        
        // called when the card transitions to face up state
        private mutating func startUsingBonusTime() {
            if isConsumingBonusTime, lastFaceUpDate == nil {
                lastFaceUpDate = Date()
            }
        }
        // called when the card goes back face down (or gets matched)
        private mutating func stopUsingBonusTime() {
            pastFaceUpTime = faceUpTime
            self.lastFaceUpDate = nil
        }
    }

About the course

Stanford's CS193p course, Developing Applications for iOS, explains the fundamentals of how to build applications for iPhone and iPad using SwiftUI.

Stanford University's course CS193p (Developing Applications for iOS using SwiftUI)

Lectures

  1. Course Logistics and Intro to SwiftUI
  2. MVVM and the Swift Type System
  3. Reactive UI Protocols Layout
  4. Grid enum Optionals
  5. ViewBuilder Shape ViewModifier
  6. Animation
  7. Multithreading EmojiArt
  8. Gestures JSON
  9. Data Flow
  10. Modal Presentation and Navigation
  11. Enroute Picker
  12. Core Data
  13. Persistence
  14. UIKit Integration

Requirements

  • iOS 14.2
  • Xcode 12.0
  • Swift 5.3

Install

Just open project and run 🚀


Buy Me A Coffee

You might also like...
100-Days-of-SwiftUI - a free online course created and delivered by Paul Hudson

100-Days-of-SwiftUI DESCRIPTION 100 Days of SwiftUI is a free online course crea

Flixster-iOS - Flixster iOS Project for CodePath iOS Course
Flixster-iOS - Flixster iOS Project for CodePath iOS Course

Flixster-iOS Flixster iOS Project for CodePath iOS Course Flix Flix is an app th

iOS Course at FMI - Sofia University

iOS 2021/2022 iOS Course at FMI - Sofia University Проекти Моля, попълнете следната форма, след като се запознаете с проектите. Всички проекти може да

Nextflix - Integrating project of the IOS development course by Digital House

nextflix Projeto integrador do curso de desenvolvimento IOS pela Digital House A

Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController.
Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController.

Todo Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController

Essential Feed Course

Essential Feed App – Image Feed Feature BDD Specs Story: Customer requests to see their image feed Narrative #1 As an online customer I want the app t

Intraveneous AR prototype for course project

An AR prototype for intravenous (IV) injection. For Julia Micallef and Matt Chan's project in CSCI 6520G This is a scripted wizard of oz prototype, wh

This is a brain teaser app I created as part of my course with Paul Hudson.
This is a brain teaser app I created as part of my course with Paul Hudson.

RockPaperScissorBrainTeaser This is a brain teaser app I created as part of my course with Paul Hudson. In this app my challenges were: Each turn of t

Memorize Applications for iOS using SwiftUI
Memorize Applications for iOS using SwiftUI

Memorize My first application for iPhone that I wrote on Stanford University's Course CS193P (Developing Applications for iOS using SwiftUI). Below ar

Releases(01)
Owner
Sergey Maslennikov
iOS developer. From Odessa, Ukraine
Sergey Maslennikov
Stanford University's course CS193p (Developing Applications for iOS using SwiftUI)

Memorize Game ?? Stanford University's course CS193p (Developing Applications for iOS using SwiftUI) About the game You need to turn over the cards on

Sergey Maslennikov 19 Dec 17, 2022
Stanford University's course CS193p (Developing Applications for iOS using SwiftUI)

Memorize Game ?? Stanford University's course CS193p (Developing Applications for iOS using SwiftUI) About the game You need to turn over the cards on

Sergey Obrien 12 Jul 28, 2021
CS193p---Assignments - Assignment Solutions for Stanford CS193p - Developing Apps for iOS

Assignment Solutions for Stanford CS193p - Developing Apps for iOS Note: This is ongoing work Task done Programming Assignment 1 x Programming Assignm

null 0 Jan 12, 2022
Developing Applications for iOS using SwiftUI [cs193p] course

Files for Developing Applications for iOS using SwiftUI [cs193p] course Study material for the course Developing Applications for iOS using SwiftUI gi

ZiXiang Luo 2 Apr 25, 2022
MyHeart Counts is a ResearchKit app developed by Stanford.

Building the App ###Requirements Xcode 6.4 iOS 8.4 SDK ###Getting the source First, check out the source, including all the dependencies: git clone --

null 63 Dec 27, 2022
It contain's the basic utils for iOS developing.

GCCoreUtils Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation GCCore

GreedyLazy 0 Nov 24, 2021
Movies is a collection of a few UI/UX ideas that came up whilst developing an iOS app

Movies Introduction: Movies is a collection of a few UI/UX ideas that came up whilst developing an iOS app called Wattmo You'll find tableviews, detai

Kevin Mindeguia 861 Nov 19, 2022
E-commerce app built in SwiftUI. Built in the course SwiftUI Masterclass in Udemy.

Touchdown-SwiftUI E-commerce app built in SwiftUI. Built in the course SwiftUI Masterclass in Udemy. Main components and concepts used: @EnvironmentOb

Jorge Martinez 5 Aug 18, 2022
Simple iOS app written with SwiftUI (and, of course, Swift) to begin exploring it.

WishList Tracking: An exploration with SwiftUI Simple iOS app written with SwiftUI (and, of course, Swift) to begin exploring it. Goal: Get used to Vi

null 0 Dec 26, 2021
Create a weather app from scratch with this SwiftUI Crash Course

"Create a weather app from scratch with this SwiftUI Crash Course" https://youtu

Alexey Saechnikov 0 Dec 17, 2021