Code Monkey home page Code Monkey logo

project0's Introduction

Project0: Cats and Dogs (Tic Tac Toe)

Dogs and Cats is a simple tic-tac-toe game that follows the standard rules of play.

Created by Faith Sylvia - General Assembly Class Project.

Game Screenshot

Demo

Click here to test on the demo site.

Technology Used

  • HTML
  • CSS
  • JavaScript
  • jQuery

Rules

  • The game is played on a 3 x 3 game board.
  • Players select their spirit animal as their token during game play
  • The first player to get 3 of their tokens in a row (either down, across, or diagonally) wins the game.
  • If the board fills and there is no winner, it is a draw, or "Cat's Game," and the game is over.

Key Features

  1. Selection of token by button
  2. Automatic assignment of token for other player based on Player 1 Selection
  3. Current symbol follows cursor - serves as a mechanism of confirming whose turn it is
  4. Buttons and individual cells change color on hover - cell hover has a short transition applied to the change of color
  5. Animation on play again button
  6. Ability to detect a draw as well as a win where the final empty cell calls the win - reference code for a draw is below. Note the second if statement tests if the game is over, which prevents this code from running if there is a winner but the board is also full (last click win):
for ( let i = 1; i <= 9; i ++ ) {
  if ( $( `#${ i }` ).text() === '') {
    boardHasRemainingSpaces = true;
  }
}

if (boardHasRemainingSpaces === false && gameOver === false) {

  gameOver = true;
  $(' #cats-game' ).removeClass( 'invisible' );
  $( '#cats-game' ).addClass(' cats-game-over' );
  $( '#play-again' ).removeClass( 'invisible' );
  gameOver = true;
  $( '.play-again' ).on( 'click' , clearBoard );
  $( '#cursor-symbol' ).addClass( 'invisible' );
}

Future Developments

  • Vertically align center of side boards to center of main play board
  • Make key if-else statement in checkWinner DRYer / simpler
  • Allow input of player names instead of using "Player 1" and "Player 2"
  • Use of images as tokens instead of text / emojis

project0's People

Watchers

Faith Sylvia 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.