Giter Club home page Giter Club logo

tictactoe's Introduction

TicTacToe

Swift 4.0 Platform license MIT

Tic-tac-toe for Apple platforms. Written in Swift with SpriteKit and GameplayKit.

Requirements

  • Xcode 9
  • Swift 4

Setup

Clone the repo and open the project in Xcode.

Design

The game is designed to run on iOS, tvOS, and macOS by using a shared codebase for the core logic and SpriteKit for the gameplay and mechanics. The platform specific pieces are written using UIKit and AppKit.

The game logic centers are three distinct types. A TTTPiece is an enum with two possible states, X and O. A TTTPosition is either empty or contains an associated piece. A TTTBoard is composed of 9 position, all initially empty. As the game played, the empty positions on the board are filled with pieces until one player wins or the game ends in draw.

Building on top of the core types, the game play model is defined using GameplayKit. This includes defining a player, what the game model looks like, and how the model changes using gameplay. The GKGameModelPlayer, GKGameModel, and GKGameModelUpdate protocols are all conformed to by various classes in order to model the game.

There are two state machines there are built using GameplayKit. The scene state machine manages transitions between the menu and gameplay states. The gameplay state machine manages the moves made during the course of the game. This includes making moves for player X and O, checking for wins, and deciding whose move is next.

Screenshot

screenshot

tictactoe's People

Contributors

andyshep avatar adamnemecek avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.