View on GitHub

rock-paper-scissors

Real-time multiplayer Rock Paper Scissors game using PHP, JavaScript, and WebSockets

0 0 0 Open issues: 0 Closed issues: 0 Open PRs: 0 Branches: 5 Default: main Updated: 4 weeks ago
CSS (31.4%) JavaScript (31%) PHP (36.6%) Dockerfile (0.9%)

README

Real-Time Multiplayer Rock Paper Scissors

A real-time multiplayer Rock Paper Scissors game built with PHP, JavaScript and Pusher. Players can create or join a private room using a shareable link and play with live updates.


Overview

This project implements a lightweight real-time game system where two players interact in a shared room. Game state is synchronized across clients using event-driven updates.


Features

  • Create or join private game rooms
  • Real-time synchronization between players
  • Instant move updates and result calculation
  • Room-based game state management
  • Automatic room cleanup via script
  • Modular backend structure (Controllers and Services)

Tech Stack

  • PHP
  • JavaScript
  • Pusher (WebSocket-based communication)
  • Docker
  • Composer

Architecture

The backend is structured using a simple separation of concerns:

  • Controllers handle incoming requests
  • Services contain business logic (room management, real-time events)
  • Scripts handle maintenance tasks such as cleaning inactive rooms
  • Public serves frontend assets and entry point

Game state is stored per room and updated through API calls. Changes are broadcast to connected clients using Pusher.


Project Structure

  • public/ – frontend entry point and assets
  • src/Controllers/ – request handling
  • src/Services/ – business logic and integrations
  • scripts/ – maintenance scripts
  • includes/ – environment and bootstrap logic

Running Locally

Using Docker

docker build -t rock-paper-scissors .
docker run -p 8080:80 rock-paper-scissors

Then open: http://localhost:8080


Environment Configuration

Create a .env file with the following variables:

PUSHER_APP_ID=your_app_id
PUSHER_KEY=your_key
PUSHER_SECRET=your_secret
PUSHER_CLUSTER=your_cluster

Future Improvements

  • Add authentication
  • Persist game state in a database
  • Add rematch functionality
  • Improve frontend responsiveness
  • Add automated testing

Branches (5)

  • main 8054e84
  • fix/realtime-multiplayer-sync e55febc
  • feature/rps-result-ui 300cf09
  • feature/rps-refactor-ui 7e1c5e5
  • chore/docker-setup e2165fc

Recent Commits (15)

Show older commits