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...
CardGameEngine - Prototyping a game engine for the Bang card game
CardGameEngine - Prototyping a game engine for the Bang card game

CardGameEngine Prototyping a game engine for the Bang card game. Features Engine is open source Powerful scripting language using JSON Card design is

Tic Tac Toe game developed in SwiftUI
Tic Tac Toe game developed in SwiftUI

TicTacToe Tic Tac Toe game developed in SwiftUI Requirements macOS 11.1 Big Sur Xcode 12.3 iOS 14 Getting Started Clone the Repository Royalty free au

2D ECS game engine in 100% Swift + SwiftUI for iOS, macOS, tvOS
2D ECS game engine in 100% Swift + SwiftUI for iOS, macOS, tvOS

OctopusKit A 2D game engine based on ECS and written in 100% Swift for iOS, macOS and tvOS. If you've tried making a game in Swift while sticking to t

A Simple iOS Game App - Designed in SwiftUI 🚀

A Simple iOS Game App - Designed in SwiftUI 🚀 The game's aim is to make a cap to fill the color among them. On tapping any shapes, it will rotate 90

The Classic game TicTacToe made using SwiftUI and MVVM architecture

The Classic game TicTacToe made using SwiftUI and MVVM architecture

Simple SwiftUI War Game

swiftui_war Simple SwiftUI War Game My implementation of: https://codewithchris.

A basic Connect Four game built with SwiftUI
A basic Connect Four game built with SwiftUI

ConnectFour About A simple Connect Four game built entirely with SwiftUI. Through working on this project, I have learned that the upsides of using Sw

BabySortingToyGame - Build a little game for babies to sort shapes in the correct location. This is made in SwiftUI using drag gestures.
BabySortingToyGame - Build a little game for babies to sort shapes in the correct location. This is made in SwiftUI using drag gestures.

This is a demo to build a little mini-game "for babies". It's inspired in this kind of games:

DarnWordle - A SwiftUI retro for Wordle, the W* game
DarnWordle - A SwiftUI retro for Wordle, the W* game

DarnWordle A SwiftUI retro of Wordle, the W* game Motivation Well, the game look

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
2048 for Swift

swift-2048 A working port of iOS-2048 to Apple's new Swift language. Like the original Objective-C version, swift-2048 does not rely upon SpriteKit. S

Austin Zheng 3.1k Dec 27, 2022
The iOS version of 2048, made using SpriteKit

2048 This is a derivative and the iOS version of the game 2048. In the very unlikely case that you don't know what it is, you can check it out here. M

Danqing Liu 1.1k Dec 31, 2022
ShellSlide - Play 2048 in your shell 🎮

ShellSlide - Play 2048 in your shell ?? Features Keep track of your overall highscore Easily save and resume your games Installation (macOS only) Down

Carl 1 Mar 28, 2022
A little arcade game that uses SwiftUI as a game engine.

SwiftUI Game A little arcade game that uses SwiftUI as a game engine :) Just copy the code into the Blank playgroundbook in Swift Playgrounds app on i

Roman Gaditskiy 10 Sep 30, 2022
IOS Spin Game - A simple spin game using SwiftUI

IOS_Spin_Game A simple spin game using Swift UI.

Md. Masum Musfique 4 Mar 23, 2022
The one and only open source 4X MMO mid-core strategy game for iOS. Similar to Game of War and Mobile Strike

4X MMO Strategy Game for iOS I have spent 4 years of my life and a significant amount of money into completing this game and I hope you enjoy it. For

shankqr 69 Nov 16, 2022
🦁 🃏 📱 An animal matching puzzle card game– built with turn-based game engine boardgame.io and React-Native + React-Native-Web

Matchimals.fun an animal matching puzzle card game ?? ?? ?? Download for iOS from the App Store ?? Download for Android from the Google Play Store ??

iGravity Studios 137 Nov 24, 2022
Switshot is a game media manager helps you transfer your game media from Nintendo Switch to your phone, and manage your media just few taps.

Switshot is a game media manager helps you transfer your game media from Nintendo Switch to your phone, and manage your media just few taps.

Astrian Zheng 55 Jun 28, 2022
Gravity Switch - A dynamic game that integrates swiping and tapping to create a fun interactive game

GravitySwitch Gravity Switch is a dynamic game that integrates swiping and tappi

null 3 Nov 19, 2022
FlagGuess-Game - A game to collect points by guessing flags

Flag Guess Game A game to collect points by guessing flags! Wrong Choice

Ahmet Onur Sahin 3 Apr 18, 2022