A 2048 game writing with SwiftUI.

Overview

2048 Game (SwiftUI app)

This is a simple game to demonstrate the new SwiftUI framework.

Note that the game algorithm may have issues, and this is still WIP.

Screenshot

Supported Platforms

  • iOS 13.0+
  • macOS 10.15+
  • macOS 11+ (macCatalyst version)

License

MIT

You might also like...
E-commerce app built in SwiftUI. Built in the course SwiftUI Masterclass in Udemy.
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

A multiplatform SwiftUI project demonstrating various SwiftUI features.

WikiDemo A multiplatform SwiftUI project demonstrating various SwiftUI features, including creating a master-detail interface. It's a multiplatform ve

SwiftUI Projects from Udemy SwiftUI Masterclass

SwiftUI Masterclass Repos: AsyncImage (N/A) Fructus (finished): an app for getting information about different fruits. Data comes from json files. Afr

Best architecture for SwiftUI + CombineBest architecture for SwiftUI + Combine

Best architecture for SwiftUI + Combine The content of the presentation: First of the proposed architectures - MVP + C Second of the proposed architec

Weather-swiftui - An example of using SwiftUI

weather-swiftui An example of using SwiftUI Installation Get openweather api key

Orbit-swiftui - Orbit design system implemented in SwiftUI for iOS

Orbit is a SwiftUI component library which provides developers the easiest possi

SwiftUI Resume - A simple resume writed by swiftUI + Combine
SwiftUI Resume - A simple resume writed by swiftUI + Combine

SwiftUI_Resume a simple "resume" writed by swiftUI + Combine

SwiftUI-MSALSample - Sample project to login with MSAL using SwiftUI
SwiftUI-MSALSample - Sample project to login with MSAL using SwiftUI

SwiftUI-MSALSample I could not find a good walkthrough on how to implement MSAL

100-Days-of-SwiftUI - Studying through Paul Hudson's 100 Days of SwiftUI
100-Days-of-SwiftUI - Studying through Paul Hudson's 100 Days of SwiftUI

Hacking with SwiftUI 100 Days of SwiftUI Studying through Paul Hudson's "100 Day

Comments
  • optimize rendering

    optimize rendering

    opened by dun198 1
  • Migrate to SwiftUI 2.0

    Migrate to SwiftUI 2.0

    Changes:

    • Adopted the renamed APIs
    • Removed AppKit access in the macCatalyst target
    • Supported keyboard event handling for macCatalyst
    • Some other minor fixes
    bug 
    opened by unixzii 0
  • It can be optimized here

    It can be optimized here

    https://github.com/unixzii/SwiftUI-2048/blob/34f315a4103527eac366403b9e4632326cc2f257/SwiftUI2048/Models/GameLogic.swift#L131

    This function can be optimized like this so that it can create any nums of blocks.

    @discardableResult fileprivate func generateNewBlock() -> Bool {
          var blankLocations = [BlockMatrixType.Index]()
          for rowIndex in 0..<4 {
              for colIndex in 0..<4 {
                  let index = (colIndex, rowIndex)
                  if _blockMatrix[index] == nil {
                      blankLocations.append(index)
                  }
              }
          }
          
          guard blankLocations.count >= 1 else {
              return false
          }
          
          // Don't forget to sync data.
          defer {
              objectWillChange.send(self)
          }
          
          _blockMatrix.place(IdentifiedBlock(id: newGlobalID, number: 2), to: blankLocations.randomElement()!)
          
          return true
      }
      
      @discardableResult fileprivate func generateNewBlocks(_ num: Int = 1) -> Bool {
          guard num > 0 else {
              return false
          }
          
          for _ in 0..<num {
              if !generateNewBlock() {
                  return false
              }
          }
          
          return true
      }
    
    opened by diamont1001 0
  • check is moved error here

    check is moved error here

    https://github.com/unixzii/SwiftUI-2048/blob/34f315a4103527eac366403b9e4632326cc2f257/SwiftUI2048/Models/GameLogic.swift#L74

    fixed:

    if let block = _blockMatrix[axis ? (col, row) : (row, col)] {
        rowSnapshot.append(block)
        compactRow.append(block)
    } else { // add else here
        rowSnapshot.append(nil)
    }
    
    opened by diamont1001 0
Owner
Cyandev
An initiate of programming.
Cyandev
SwiftUI implementation of Conway’s Game of Life — also known as “Life”.

Life Conway’s Game of Life SwiftUI implementation of Conway’s Game of Life — also known simply as “Life”. About I’m Martin, an indie dev from Berlin.

Martin Lexow 23 Jan 21, 2022
Open source game built in SwiftUI and the Composable Architecture.

isowords This repo contains the full source code for isowords, an iOS word search game played on a vanishing cube. Connect touching letters to form wo

Point-Free 2.1k Jan 1, 2023
The Conway's Game of Life that build with SwiftUI.

SwiftUI-LifeGame The Conway's Game of Life that build with SwiftUI. iOS iPad macOS Requirements Xcode 12.2 (beta 2) macOS Catalina macOS Big Sur (beta

Yusuke Hosonuma 52 Dec 15, 2022
Tic Tac Toe - Tic Tac Toe mobile application game developed with SwiftUI and AI technology

Hello, there! Welcome to The Tic_Tac_Toe IOS Applicaition The Aricah Cross platf

Travis Okonicha 2 Apr 27, 2022
Riddler is a riddle game built as a native iOS app in Swift using SwiftUI

Riddler is a riddle game built as a native iOS app in Swift using SwiftUI. It includes 50 challenging riddles with hints for when you get stuck. The game tracks your stats so you can compare your performance against your friends, and see who can answer all 50 riddles the quickest.

Oliver Stenning 3 Nov 23, 2022
iOS On-Device Game Cheat Creation/Sharing Platform and Software

CheatManager CheatManager is a mobile platform, used for installation/distribution/creation of mobile game cheats/hacks. This platform is completely d

Project Manticore 49 Jan 2, 2023
iOS App to display game lists and details with the ability to add games to your favorites list and see metacritic ratings.

Game Data System - GDS Author: Heitor Silveira ([email protected]) iOS App to view games from various platforms, their description, release

Heitor Ugarte Calvet da Silveira 0 Oct 6, 2021
TicTacToe - A Tic Tac Toe game built with swift

TicTacToe This is Tic Tac Toe game :) There are two players, Player X and Player

Jane Zhu 0 Jan 1, 2022
Tictactoe-ultimatum - iOS implementation of Ultimate Tic-Tac-Toe game

TicTacToe Ultimatum An iOS app in Swift implementing the classic game of Ultimat

Max Khrapov 1 Jan 21, 2022
A simple SwiftUI Application to demonstrate creation of UI using SwiftUI.

WatchShop_UI A simple SwiftUI Application to demonstrate creation of UI using SwiftUI. How to run the project ? Fork the project. Run the project usin

Shubham Kr. Singh 12 Apr 15, 2022