✊✋✌️ Rock Paper Scissors Game

A React Learning Project - Interactive Game with State Management

🎯 Try the Game

Click on rock, paper, or scissors to play against the computer!

📖 About This Project

This is a simple but educational React application that demonstrates fundamental concepts in modern web development. The app features an interactive Rock Paper Scissors game with state management, event handling, and dynamic UI updates based on game logic.

🏗️ Project Structure

rpsgame/ ├── src/ │ ├── main.jsx # Entry point - renders the app │ ├── App.jsx # Main App component │ ├── Game.jsx # Game logic and UI component │ └── Game.module.css # Game styling ├── index.html # HTML template ├── package.json # Dependencies and scripts ├── vite.config.js # Vite configuration └── dist/ # Production build

💻 Code Explanation

Game Component (Game.jsx)

function Game() { const [playerChoice, setPlayerChoice] = useState(null); const [codeyChoice, setCodeyChoice] = useState(null); const [result, setResult] = useState(null); function handlePlayerChoice(choice) { const codeyChoice = CHOICES[Math.floor(Math.random() * CHOICES.length)]; setPlayerChoice(choice); setCodeyChoice(codeyChoice); // Game logic for determining winner } return ( <div className={styles.container}> <h1>Rock Paper Scissors</h1> <div className={styles.choices}> {CHOICES.map((choice) => ( <button onClick={() => handlePlayerChoice(choice)}> {choice.emoji} </button> ))} </div> {/* Results display */} </div> ); }

A complete game component that manages game state, handles user interactions, and implements the Rock Paper Scissors game logic. Demonstrates useState hook, event handling, and conditional rendering.

App Component (App.jsx)

function App() { return ( <Game /> ); }

The root component that renders the Game component. Demonstrates simple component composition and the single responsibility principle.

🛠️ Tech Stack

React 19.1.1
Vite 7.1.2
JSX
ES6 Modules
CSS Modules
Cloudflare Pages

🎓 Key Learning Points

🚀 Deployment to Cloudflare Pages

This project is deployed using Cloudflare Pages, a fast and reliable hosting platform for static sites.

Deployment Steps:

  1. Build the project: npm run build
  2. Install Wrangler CLI: npm install -g wrangler
  3. Deploy to Cloudflare Pages: wrangler pages deploy dist --project-name rps-game
  4. Your site is live automatically!

Build Configuration

// vite.config.js import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], })

🔧 Development Commands

📚 Next Steps

🌎 View Live Demo