A slots game built with TypeScript, PixiJS, and Webpack. Has horizontal reel spinning, sound effects, and Spine animations.
- Horizontal reel spinning with smooth animations
- Sound effects using Howler.js
- Spine animations for wins and decorations
- Responsive design that works on different screen sizes
- TypeScript for type safety
- Unit tests with Jest
- Node.js (v16 or higher)
- npm (v8 or higher)
-
Clone the repo
git clone https://github.com/touridev/slots-game cd slots-game -
Install dependencies
npm install
-
Start the dev server
npm start
-
Open your browser to
http://localhost:9000
npm run buildFiles will be in the dist/ folder.
- Click the spin button to start the reels
- Watch the reels spin horizontally
- Win detection happens automatically when reels stop
- Enjoy the sound and visual effects
npm start- Start dev servernpm run build- Build for productionnpm test- Run testsnpm run test:watch- Run tests in watch modenpm run test:coverage- Get test coveragenpm run lint- Run linter
src/
├── assets/ # Game assets
│ ├── images/ # Symbol textures and UI
│ ├── sounds/ # Audio files
│ └── spines/ # Spine animations
├── slots/ # Game logic
│ ├── SlotMachine.ts
│ ├── Reel.ts
│ └── __tests__/
├── ui/ # UI components
│ └── UI.ts
├── utils/ # Utilities
│ ├── AssetLoader.ts
│ ├── sound.ts
│ ├── constants.ts
│ └── __tests__/
├── Game.ts
├── index.ts
└── index.html
- Controls multiple reels and game state
- Handles win detection and animations
- Manages spin timing
- Handles horizontal spinning
- Smooth deceleration and snapping
- Symbol positioning
- Loads and caches assets
- Manages textures and animations
- Error handling
- Uses Howler.js for audio
- Preloads sounds
- Handles errors
Edit src/utils/constants.ts to change game settings:
export const REEL_CONFIG = {
COUNT: 5,
SYMBOLS_PER_REEL: 8,
SYMBOL_SIZE: 130,
SPIN_SPEED: 400,
SLOWDOWN_RATE: 0.95,
};npm test
npm run test:coverage
npm run test:watchTests cover:
- Reel logic and positioning
- Sound system
- Asset loading
- Add images to
src/assets/images/ - Update
REEL_CONFIG.SYMBOL_TEXTURESinconstants.ts - Rebuild
- Replace Spine files in
src/assets/spines/ - Update animation names in
SlotMachine.ts - Adjust timing in
ANIMATION_CONFIG
- Add audio files to
src/assets/sounds/ - Update the
SOUNDSarray inAssetLoader.ts - Use
sound.play('filename')in code
- Object pooling for sprites
- Efficient rendering
- Asset caching
- Delta time for smooth animation
- Memory management
Game won't start
- Check browser console for errors
- Make sure assets are loaded
- Check Node.js version
Audio not working
- Check browser audio permissions
- Verify sound file format
- Try different browsers
Performance issues
- Reduce symbol count in
REEL_CONFIG - Lower animation quality
- Check for memory leaks
- Chrome 80+
- Firefox 75+
- Safari 13+
- Edge 80+
MIT License
- Fork the repo
- Create a branch (
git checkout -b feature/new-feature) - Commit changes (
git commit -m 'Add new feature') - Push to branch (
git push origin feature/new-feature) - Open a Pull Request
For issues:
- Check troubleshooting section
- Look at existing GitHub issues
- Create a new issue with details