Coder Social home page Coder Social logo

tris3d-canvas's Introduction

tris3d-canvas

is a canvas to play tic tac toe in 3d

Installation | API | License

NPM version JavaScript Style Guide

Installation

With npm do

npm install three tris3d-canvas

Note that three.js is required as a peer dependency.

API

See online example or do the following to run example.js

npm install
npm start

const tris3dCanvas = new Tris3dCanvas(canvasId, opts)

Constructor to create an instance of Tris3dCanvas.

Create a canvas with attribute id, inside a div container with display: block style

<div style="display: block">
  <canvas id="demo"></canvas>
</div>

Then create a Tris3dCanvas object

const tris3dCanvas = new Tris3dCanvas('demo')

Optional parameters are accepted after canvasId, constructor signature is the following:

  • @param {String} id of canvas element
  • @param {Object} [opt] optional parameters
  • @param {Array} [opt.playerColors] are three colors, like 0xff0000
  • @param {Array} [opt.backgroundColor] defaults to 0xffffff

tris3dCanvas.localPlayerIndex

Can be 0, 1, 2. Defaults to 0, which means the local player moves first.

tris3dCanvas.on('localPlayerTurnEnds', () => {})

Listen to localPlayerTurnEnds event.

tris3dCanvas.on('localPlayerTurnStarts', () => {})

Listen to localPlayerTurnStarts event.

tris3dCanvas.on('nextPlayer', (playerIndex) => {})

Listen to nextPlayer event.

tris3dCanvas.on('nobodyWins', () => {})

Listen to nobodyWins event.

tris3dCanvas.on('setChoice', (cubeIndex) => {})

Listen to setChoice event.

tris3dCanvas.on('tris3d!', (winnerPlayerIndex, winningCombinations) => {})

Listen to tris3d! event.

tris3dCanvas.render()

Start rendering the 3d scene.

tris3dCanvas.setChoice(playerIndex, cubeIndex)

Set player choice.

tris3dCanvas.resetPlayground()

Reset playground without start playing a new match.

tris3dCanvas.startNewMatch()

Start a brand new match

License

MIT

tris3d-canvas's People

Contributors

dependabot[bot] avatar fibo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lucacolonnello

tris3d-canvas's Issues

try with 2 players

It could be implemented a version of the game with 2 players, but, the center should be removed.

Fix website

Website has many things to be fixed. On mobile layout overflows, hamburger icon does not work, etc.

Resize

Handle window resize eventuali, otherwise camera Can move and playground Is not usable

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.