Code Monkey home page Code Monkey logo

slot's Introduction

slot

Web Slot Machine game library based on PixiJS.

Example

Include library

<script src="../dist/slot.js"></script>

You game container element

<div id="game-container"></div>

Create the game

var resources = [
  ['symbol-1', 'assets/space adventure/symbol-1.png'],
  ['symbol-2', 'assets/space adventure/symbol-2.png'],
  ['symbol-3', 'assets/space adventure/symbol-3.png'],
];

function init(game) {
  // create a reel
  var reel = game.reels.add(3); // with 3 positions

  // position reel
  reel.x = 100;
  reel.y = 100;

  // initial values
  reel.values = [1, 1, 2, 3];

  game.on('start', function() {
    // populate reel with random spin values
    var symbolsCount = 3;
    for (var i = 0; i < 14; i++) {
      reel.spinValues.push(parseInt(Math.random() * symbolsCount) + 1);
    }
    // stop (result) values
    reel.stopValues = [3, 3, 2, 1];
  });

  // play using Spacebar
  window.addEventListener('keydown', function(e) {
    if (e.keyCode == 32) {
      game.play();
    }
  });
}

// initialize game
var game = new Slot({
  container: '#game-container',
  resources,
  init,
}, 1500, 640);

More examples

Basic Example

A simple 3x3 offline game.

Network Example

Uses hypothetical network.

slot's People

Contributors

ktsalik avatar dependabot[bot] 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.