{"id":20484030,"url":"https://github.com/nuxy/slot-machine-gen","last_synced_at":"2026-03-14T05:17:38.661Z","repository":{"id":43381356,"uuid":"232040953","full_name":"nuxy/slot-machine-gen","owner":"nuxy","description":":slot_machine: Create an extremely biased, web-based slot machine game.","archived":false,"fork":false,"pushed_at":"2024-07-13T18:50:18.000Z","size":4359,"stargazers_count":33,"open_issues_count":0,"forks_count":21,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-07T17:14:11.716Z","etag":null,"topics":["3d-cylinder","animations","games","javascript","modules","plugins","slots"],"latest_commit_sha":null,"homepage":"https://slot-machine-gen.nuxy.dev","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuxy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-06T06:44:51.000Z","updated_at":"2025-01-03T20:16:50.000Z","dependencies_parsed_at":"2023-02-01T04:33:13.270Z","dependency_job_id":"97c62903-56df-4f46-a36e-a2538671087b","html_url":"https://github.com/nuxy/slot-machine-gen","commit_stats":{"total_commits":105,"total_committers":1,"mean_commits":105.0,"dds":0.0,"last_synced_commit":"8b6d0a08ab3280d3d91925ce73622711217dfc54"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxy%2Fslot-machine-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxy%2Fslot-machine-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxy%2Fslot-machine-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxy%2Fslot-machine-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuxy","download_url":"https://codeload.github.com/nuxy/slot-machine-gen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233940698,"owners_count":18754577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-cylinder","animations","games","javascript","modules","plugins","slots"],"created_at":"2024-11-15T16:19:37.529Z","updated_at":"2026-03-14T05:17:38.641Z","avatar_url":"https://github.com/nuxy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slot Machine Generator\n\n[![npm version](https://badge.fury.io/js/slot-machine-gen.svg)](https://badge.fury.io/js/slot-machine-gen) [![](https://img.shields.io/npm/dm/slot-machine-gen)](https://www.npmjs.com/package/slot-machine-gen) [![Install size](https://packagephobia.com/badge?p=slot-machine-gen)](https://packagephobia.com/result?p=slot-machine-gen) [![](https://img.shields.io/github/v/release/nuxy/slot-machine-gen)](https://github.com/nuxy/slot-machine-gen/releases) [![NO AI](https://raw.githubusercontent.com/nuxy/no-ai-badge/master/badge.svg)](https://github.com/nuxy/no-ai-badge)\n\nCreate an extremely biased, web-based slot machine game.\n\n![Preview](https://raw.githubusercontent.com/nuxy/slot-machine-gen/master/package.gif)\n\n## Features\n\n- Faux-panoramic reel animations (**3D cylinder**, without `\u003ccanvas\u003e`)\n- Support for single/multi-line reels and pay-lines.\n- Pseudo-random selections by configured weight.\n- Configurable RNG (to make it less biased)\n- Configurable sound clips for reel animations.\n- Easy to set-up and customize. **No dependencies**.\n\nCheckout the [demo](https://nuxy.github.io/slot-machine-gen) for examples of use.\n\n## Dependencies\n\n- [Node.js](https://nodejs.org)\n\n## Installation\n\nInstall the package into your project using [NPM](https://npmjs.com), or download the [sources](https://github.com/nuxy/slot-machine-gen/archive/master.zip).\n\n    $ npm install slot-machine-gen\n\n### Alternative\n\nTo add to an existing [React](https://reactjs.org) or [Vue](https://vuejs.org) project you can install this package using [YARN](https://yarnpkg.com).\n\n#### React\n\n    $ yarn add react-slot-machine-gen\n\n#### Vue\n\n    $ yarn add vue-slot-machine-gen\n\n## Usage\n\nThere are two ways you can use this package.  One is by including the JavaScript/CSS sources directly.  The other is by importing the module into your component.\n\n### Script include\n\nAfter you [build the distribution sources](#cli-options) the set-up is fairly simple..\n\n```html\n\u003cscript type=\"text/javascript\" src=\"path/to/slot-machine.min.js\"\u003e\u003c/script\u003e\n\u003clink rel=\"stylesheet\" href=\"path/to/slot-machine.min.css\" media=\"all\" /\u003e\n\n\u003cscript type=\"text/javascript\"\u003e\n  slotMachine(container, reels, callback, options);\n\u003c/script\u003e\n```\n\n### Module import\n\nIf your using a modern framework like [Aurelia](https://aurelia.io), [Angular](https://angular.io), [React](https://reactjs.org), or [Vue](https://vuejs.org)\n\n```javascript\nimport SlotMachine from 'slot-machine-gen';\nimport 'slot-machine-gen/dist/slot-machine.css';\n\nconst slotMachine = new SlotMachine(container, reels, callback, options);\n```\n\n### HTML markup\n\n```html\n\u003cdiv id=\"slot-machine\" class=\"slot-machine\"\u003e\u003c/div\u003e\n```\n\n## Reels configuration\n\nOutside of a reel image source, `symbols` must contain the following:\n\n| Key      | Description                                             | Type   |\n|----------|---------------------------------------------------------|--------|\n| title    | Name of the strip symbol                                | String |\n| position | Symbol center (in pixels) calculated from the strip top | Number |\n| weight   | Selection weight (\u003e1 increases odds)                    | Number |\n\n### Example\n\n```javascript\nconst reels = [\n  {\n    imageSrc: 'path/to/image.png',\n    symbols: [\n      {\n        title: 'cherry',\n        position: 100,\n        weight: 2\n      },\n      {\n        title: 'plum',\n        position: 300,\n        weight: 6\n      },\n      {\n        title: 'orange',\n        position: 500,\n        weight: 5\n      },\n      {\n        title: 'bell',\n        position: 700,\n        weight: 1\n      },\n      {\n        title: 'cherry',\n        position: 900,\n        weight: 3\n      },\n      {\n        title: 'plum',\n        position: 1100,\n        weight: 5\n      }\n    }\n  },\n\n  // add more reels ...\n]\n```\n\n## Methods\n\n```javascript\nslotMachine.play();\n```\n\n## Game options\n\nCustomization and overriding defaults can be done using the following options:\n\n| Option     | Description                                        | Type      | Default       |\n|------------|----------------------------------------------------|-----------|---------------|\n| reelHeight | Reel background image height (in pixels)           | Number    | 1320          |\n| reelWidth  | Reel background image width.                       | Number    | 200           |\n| reelOffset | Reel background image vertical offset.             | Number    | 20            |\n| slotYAxis  | Slot vertical axis rotation (in degrees).          | Number    | 0             |\n| animSpeed  | Slot animation speed (in milliseconds)             | Number    | 1000          |\n| click2Spin | Add event to display to spin reels                 | Boolean   | true          |\n| rngFunc    | Custom RNG between 0 (inclusive) and 1 (exclusive) | Function  | `Math.random()` |\n| sounds     | Audio clip URLs for reels animation events         | Object    | `{reelsBegin, reelsEnd}` |\n\n## Callback\n\nThis method returns an array of selected [reel symbols](#reels-configuration) that can be used to compute scoring, show animations, handle client interactions, etc..\n\n```javascript\nconst callback = function(symbols) {\n  if (symbols[0].title === 'cherry' \u0026\u0026 symbols[1].title === 'cherry' \u0026\u0026 symbols[2].title === 'cherry') {\n    window.alert(\"You're a winner!\");\n  }\n};\n```\n\n## Customizing symbols\n\nCreating a custom strip is fairly easy. What is most important is that each symbol, whether an image or blank space, contains a vertical `position` that can be measured by calculating the symbol center (in pixels) from the strip top. A [Photoshop example](https://raw.githubusercontent.com/nuxy/slot-machine-gen/master/images/reel-strip.psd) has been provided with this package for reference.\n\n## Developers\n\n### CLI options\n\nRun [ESLint](https://eslint.org) on project sources:\n\n    $ npm run lint\n\nTranspile ES6 sources (using [Babel](https://babeljs.io)) and minify to a distribution:\n\n    $ npm run build\n\n## Contributions\n\nIf you fix a bug, or have a code you want to contribute, please send a pull-request with your changes. (Note: Before committing your code please ensure that you are following the [Node.js style guide](https://github.com/felixge/node-style-guide))\n\n## Versioning\n\nThis package is maintained under the [Semantic Versioning](https://semver.org) guidelines.\n\n## License and Warranty\n\nThis package is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.\n\n_slot-machine-gen_ is provided under the terms of the [MIT license](http://www.opensource.org/licenses/mit-license.php)\n\n## Author\n\n[Marc S. Brooks](https://github.com/nuxy)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxy%2Fslot-machine-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuxy%2Fslot-machine-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxy%2Fslot-machine-gen/lists"}