Christophe Grädel

The Fortune Slot Machine

More Than Just Spinning Wheels

This project is a fully featured browser-based slot machine. Beyond just randomly displaying images, I engineered a complex set of background mechanics including betting systems, win streaks, and dynamic probability events to make the gameplay truly engaging.

Picture of Slot Machine

Encapsulation with Object Literals

Symbolic image of code

Before diving into ES6 Classes (like I did in the Memory project), this project was my first deep exploration into organizing code using JavaScript Objects. By grouping related functions and variables into dedicated objects like userStats and slotMachineStats, I avoided polluting the global scope and kept the game's state tightly managed and clean.

Complex Game State Logic

  • Dynamic Pity System: The game tracks losing streaks based on the bet amount (<= 10 or > 10 coins) and guarantees a win if the player is too unlucky.
  • Win Streaks: Successfully chaining 3 wins automatically doubles the payout of subsequent victories.
  • Probability Events: Using Math.random() algorithms, I implemented special "Score Events" (like Jackpots or Free Spins) based on cumulative probability tables.

CSS Animations & UX

To bring the slot machine to life, I utilized native CSS @keyframes for the spinning symbol animations, triggering them dynamically via JavaScript by manipulating DOM classes. I also implemented comprehensive keyboard shortcuts (using keydown event listeners) to ensure the game is fully playable without a mouse, improving accessibility and user experience.

Try Your Luck!

Play the game live on GitHub Pages!

Full view of the Slot Machine Game