A web-based Plinko gambling game with animated ball drops, Firebase authentication, and persistent user balances.
Before you begin, make sure you have the following installed:
- Node.js (v14 or higher) - Download here
- npm (comes with Node.js)
- A code editor (VS Code recommended)
- A web browser (Chrome, Firefox, Safari, etc.)
your-project-folder/
├── server.js # Backend server
├── package.json # Node.js dependencies
├── .env.example # Environment variable examples
├── public/ # Frontend files
│ ├── index.html # Main HTML file
│ ├── script.js # Game logic and animations
│ ├── style.css # Styling
│ └── firebase.js # Firebase configuration
└── data/ # User balance data (auto-created)
└── balances.json # Stored user balances
Open your terminal in the project folder and run:
npm installThis will install all required packages:
express- Web server frameworkcors- Cross-origin resource sharingfirebase-admin- Firebase authentication (optional)dotenv- Environment variable management
Run the following command:
node server.jsYou should see:
Plinko game server running on http://localhost:3000
Running in development mode without Firebase authentication
Open your web browser and go to:
http://localhost:3000
You should see the Plinko game interface!
- Login - In development mode, you can use any email/password (authentication is disabled)
- Place a Bet - Enter an amount in the bet input field
- Drop Ball - Click the "Drop Ball" button to watch the animation
- View Results - The ball will land in a slot, and your balance updates accordingly
- Reset Balance - Click "Reset Balance" to go back to $1000.00
- Starting balance: $1000.00
- Multipliers vary based on slot position (center = low, edges = high)
- The ball randomly drops through pegs to land in a slot
- Your payout = bet amount × slot multiplier
- Balance updates after the ball animation completes
To stop the server, press:
Ctrl + C(On Mac: Cmd + C)
If you make changes to the code:
- Stop the server:
Ctrl + Corpkill -9 node - Restart the server:
node server.js - Hard refresh browser:
Cmd + Shift + R(Mac) orCtrl + Shift + R(Windows/Linux)
If you see EADDRINUSE: address already in use :::3000:
Solution 1 - Kill the process:
lsof -i :3000
# Note the PID number, then:
kill -9 [PID]Solution 2 - Kill all Node processes:
pkill -9 nodeSolution 3 - Use a different port:
Edit server.js and change:
const PORT = process.env.PORT || 3001; // Changed from 3000 to 3001If your changes aren't showing up:
- Hard refresh:
Cmd + Shift + R(Mac) orCtrl + Shift + R(Windows/Linux) - Clear cache:
- Open DevTools (F12)
- Network tab → Check "Disable cache"
- Keep DevTools open and refresh
- Clear all site data:
- DevTools (F12) → Application tab
- Storage → Clear site data
Make sure you're in the correct directory:
# Check current directory
pwd
# List files - you should see server.js and public/
lsIf you want to enable real Firebase authentication:
- Create a Firebase project at Firebase Console
- Download service account key:
- Go to Project Settings → Service Accounts
- Click "Generate new private key"
- Save as
firebase-service-account.jsonin project root
- Update Firebase config:
- Edit
public/firebase.jswith your Firebase config
- Edit
- Restart the server
The app will now use real Firebase authentication instead of dev mode.
- No Firebase setup required
- Any email/password works for login
- Perfect for local testing
- Single shared balance for all "users"
- Real user authentication
- Individual user balances
- Secure token verification
- Requires Firebase project setup
Install nodemon globally:
npm install -g nodemonRun with nodemon:
nodemon server.jsNow the server automatically restarts when you save server files!
Press F12 (or Cmd + Option + I on Mac) to open DevTools:
- Console - See JavaScript errors and debug logs
- Network - Check if files are loading correctly
- Sources - Debug JavaScript code
- Application - Clear cache and storage
# Install dependencies
npm install
# Start server
node server.js
# Start with auto-restart
nodemon server.js
# Stop server
Ctrl + C (or Cmd + C on Mac)
# Kill all Node processes
pkill -9 node
# Check what's using port 3000
lsof -i :3000
# Kill specific process
kill -9 [PID]If you run into problems:
- Make sure all dependencies are installed:
npm install - Check that the server is running: Look for "Plinko game server running" message
- Verify you're accessing the correct URL:
http://localhost:3000 - Clear browser cache if changes aren't showing up
- Check the browser console (F12) for JavaScript errors
Enjoy playing Plinko!