Skip to content

Simon Says - Real-Time Multiplayer Game used in my WebSockets presentations

Notifications You must be signed in to change notification settings

FuseDevelopments/com.fusedev.game

Repository files navigation

Simon Says - Real-Time Multiplayer Game

A real-time multiplayer implementation of the classic Simon Says memory game built with ColdFusion WebSockets. Two players compete head-to-head in this beautifully designed web-based version where timing, memory, and quick reflexes determine the winner.

🎮 Game Overview

Simon Says is a memory game where players must repeat increasingly complex sequences of colored button presses. In this multiplayer version:

  • 2 Player Maximum: Each game channel supports exactly 2 active players
  • Turn-Based Gameplay: Players alternate turns, with each turn adding a new color to the sequence
  • Real-Time Synchronization: All game state is synchronized in real-time using WebSockets
  • Score Tracking: Win/loss records are maintained throughout the session
  • Audio Feedback: Each color button has its own distinctive sound

🚀 Quick Start

Prerequisites: CommandBox and modern web browser

  1. Clone this repository
  2. Install dependencies:
    box install
  3. Start server:
    box server start
  4. Play at http://localhost:{port}/

🎯 How to Play

Starting a Game

  1. Navigate to the home page and click "Play a Game"
  2. Enter your username and create/join a game channel
  3. Wait for a second player to join the same channel
  4. Game starts automatically when both players are connected

Gameplay Rules

  1. Watch the Sequence: The game begins with a random colored button lighting up
  2. Repeat the Pattern: Click the buttons in the exact same order
  3. Add Your Move: After successfully repeating the sequence, add one new color
  4. Pass the Turn: Your opponent must now repeat your extended sequence
  5. Continue Growing: The sequence gets longer with each successful turn
  6. Make No Mistakes: First player to make an error loses the round

Game Controls

  • Colored Buttons: Click to select colors (Green, Red, Yellow, Blue)
  • Restart Button: Appears for the winner to start a new round
  • Channel Management: Each game session is isolated to its subchannel

🏗️ Technical Architecture

WebSocket Implementation

// Channel Configuration (Application.cfc)
this.wschannels = [
    { name:"game", cfclistener:"GameListener" }
];

Key Components

Component Purpose
Application.cfc WebSocket channel configuration and app lifecycle
GameListener.cfc Server-side WebSocket message handling and game logic
index.cfm Landing page with navigation
play.cfm Main game interface
subscriptions.cfm Active game monitoring for admins
assets/js/game.js Client-side game logic and UI management
assets/css/ui.css Game styling and responsive design

Game State Management

  • Channel-Based Isolation: Each game uses a unique channel (game.{channel-name})
  • Real-Time Synchronization: All player actions broadcast to channel subscribers
  • Automatic Cleanup: Handles player disconnection gracefully
  • Spectator Support: Console can monitor games without participating

🔧 Advanced Features

Channel Monitoring

Access http://localhost:{port}/subscriptions/ to view:

  • Active game channels
  • Connected players per channel
  • Real-time subscription data

Console Integration

The included console application allows:

  • Game Monitoring: Watch live games without participating
  • Debug Information: View WebSocket message traffic
  • Channel Inspection: Monitor multiple channels simultaneously

To monitor a specific game:

  1. Open the console at /console/
  2. Subscribe to channel: game.{channel-name}
  3. Leave username blank for spectator mode

🏆 Credits

This project was inspired by a presentation I saw ages ago at cf.objective by Mark Mandel. If I remember correctly, the original concept included physical controls alongside a web interface, demonstrating the power of real-time web technologies. After seeing this, I thought, what a great idea to try and mimic using WebSockets in ColdFusion.


Ready to test your memory? Challenge a friend and see who has the better recall in this fast-paced game of Simon Says! 🧠⚡

About

Simon Says - Real-Time Multiplayer Game used in my WebSockets presentations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published