A real-time multiplayer game built with the Puter API, featuring player movement, chat, and emoji avatars.
- Real-time Multiplayer: Multiple players can join and interact simultaneously
- Player Movement: Use arrow keys to move around a 500x500 game grid
- Chat System: Real-time chat with other players
- Emoji Avatars: Choose from 8 different emoji characters
- Puter Authentication: Secure login using Puter accounts
- Serverless Backend: Powered by Puter Workers for scalable multiplayer
index.html- Main game with full Puter authenticationgame.js- Game logic and Puter API integrationmmo.js- Standalone worker file for serverless backenddemo.html- Demo version with simulated multiplayer (no authentication required)README.md- This documentation
- Open
index.htmlin a web browser - The game will automatically deploy the worker and start
- Login with your Puter account
- Choose an emoji avatar and start playing!
-
Deploy the Worker First:
// In Puter console or via Puter API await puter.workers.create('my-mmo-game', 'mmo.js');
-
Configure the Game: Edit
game.jsand update the configuration:const GAME_CONFIG = { workerUrl: 'https://my-mmo-game.puter.work', // Your worker URL autoDeployWorker: false // Disable auto-deploy };
-
Launch the Game: Open
index.htmland the game will use your pre-deployed worker.
Edit the GAME_CONFIG object in game.js:
const GAME_CONFIG = {
// Set your deployed worker URL here
workerUrl: 'https://your-worker-name.puter.work',
// Set to false if using a pre-deployed worker
autoDeployWorker: false
};-
workerUrl:null- Auto-deploy worker (default)'https://your-worker.puter.work'- Use specific worker URL
-
autoDeployWorker:true- Automatically deploy worker if needed (default)false- Only use pre-configured worker URL
The mmo.js worker provides the following API endpoints:
GET /api/players- Get all active playersPOST /api/player/position- Update player positionPOST /api/player/logout- Remove player from game
GET /api/chat- Get recent chat messagesPOST /api/chat- Send a chat message
POST /api/cleanup- Remove inactive playersGET /api/stats- Get game statisticsGET /health- Health check endpointGET /api- API documentation
- Arrow Keys: Move your player around the game grid
- Chat Input: Type messages to chat with other players
- Enter Key: Send chat message
- Logout Button: Sign out and return to splash screen
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Frontend โ โ Puter Workers โ โ Puter Cloud โ
โ (index.html) โโโโโบโ (mmo.js) โโโโโบโ (Auth & KV) โ
โ - Game UI โ โ - Player Data โ โ - User Data โ
โ - Movement โ โ - Chat System โ โ - File Storageโ
โ - Chat โ โ - Game State โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- Authentication Required: All API endpoints require Puter authentication
- Input Validation: Message length limits and sanitization
- Rate Limiting: Built-in cleanup of inactive players
- Error Handling: Comprehensive error responses
- Use auto-deploy feature for quick testing
- Demo mode available without authentication
- Pre-deploy worker for better performance
- Configure custom worker URL
- Monitor via
/api/statsendpoint
- Modify
mmo.jsto add new API endpoints - Update
game.jsto use new endpoints - Redeploy worker with changes
- Edit CSS in
index.htmlfor visual customization - Modify emoji options in the avatar selector
- Adjust game grid size and movement speed
Check game status via the stats endpoint:
// Get current game statistics
const response = await fetch('https://your-worker.puter.work/api/stats');
const stats = await response.json();
console.log(stats);-
Worker Connection Failed
- Check if worker URL is correct
- Verify worker is deployed and running
- Test with
/healthendpoint
-
Authentication Errors
- Ensure user is logged into Puter
- Check browser console for auth errors
-
Players Not Updating
- Check network connectivity
- Verify worker endpoints are responding
- Look for JavaScript errors in console
Enable debug logging by opening browser console and checking for:
- Worker connection status
- API response errors
- Game state updates
This project is open source and available under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Powered by Puter - The open-source cloud operating system