Amr Elshabrawy
Elshabrawy
HomeAboutServicesWorkContact
Download CV
Amr Elshabrawy
Elshabrawy

© 2026 Amr Elshabrawy. All rights reserved.

Snake Game

Snake Game

Snake Game A classic Snake Game built with HTML, CSS, and JavaScript. Enjoy nostalgic gameplay in the browser while learning web development fundamentals.

View CodeLive Demo
0 stars
0 forks
Created Feb 9, 2025
49 KB

Technologies

JavaScriptcss3emailjshtml

Languages

JavaScript48%
CSS28%
HTML24%

README

🐍 Snake Game

🌐 View Live Demo | 📦 GitHub Repo

GitHub repo size GitHub stars GitHub forks

A modern implementation of the classic Snake game using vanilla JavaScript with a focus on code quality and maintainability.

✨ Features

  • Player Registration 📝: Players can register with their name and email to track their scores.
  • Score Tracking 🏆: The game tracks and displays the top scores.
  • Customizable Settings ⚙️: Players can customize the snake color, toggle between light and dark themes, and enable or disable random food colors.
  • Email Notifications 📧: Players receive email notifications with their scores.

🛠️ Core Technologies

  • HTML 🌐: Structure and layout of the game interface
  • CSS 🎨: Styling and responsive design
  • JavaScript 💻: Game logic and interactivity
  • EmailJS 📧: Email notification service
  • Local Storage 💾: Score and settings persistence

🚧 Challenges Faced

During the development of this Snake Game, several technical challenges were encountered and successfully addressed:

  • Collision Detection 💥: Implementing accurate collision detection between the snake and walls/itself required careful coordinate tracking and boundary checking.
  • Smooth Movement 🔄: Ensuring smooth snake movement while maintaining precise controls and preventing rapid reverse direction changes.
  • State Management 📊: Managing game state effectively, including pause/resume functionality and score tracking across sessions.
  • Mobile Responsiveness 📱: Adapting the game controls and display for various screen sizes and touch interfaces.
  • Performance Optimization ⚡: Optimizing rendering and update loops to maintain smooth gameplay, especially as the snake grows longer.
  • Email Integration 📨: Implementing secure and reliable email notifications without exposing sensitive credentials.

🚀 Setup Instructions

  1. Clone the Repository:

    git clone https://github.com/your-username/snake-game.git
    cd snake-game
    
  2. Open the Project:

    Open the index.html file in your web browser to start the game.

  3. Configure EmailJS:

    • Sign up for an account on EmailJS.
    • Create a new email service and template.
    • Update app.js with your EmailJS credentials:
    // Initialize EmailJS with your public key
    emailjs.init("YOUR_EMAILJS_PUBLIC_KEY");
    const EMaILJS_SERVICE_ID = "YOUR_SERVICE_ID";
    const EMaILJS_TEMPLATE_ID = "YOUR_TEMPLATE_ID";
    

🎮 Game Controls

Desktop Controls 🖥️

  • Start/Pause: Space key
  • Movement:
    • Arrow keys (↑, ↓, ←, →)
    • Or W, A, S, D keys
  • Restart: R key or click "Restart" button

Mobile Controls 📱

  • Start/Pause: Tap screen center
  • Movement: Swipe in desired direction
  • Restart: Double tap screen

Game Actions 🎯

  • Collect food 🍎 to grow longer
  • Avoid hitting walls and yourself
  • Track your high score
  • Access settings through ⚙️ menu

⚙️ Configuration

  • Theme Mode 🌓: Toggle between light and dark themes in the settings.
  • Snake Color 🎨: Choose a custom color for the snake in the settings.
  • Random Food Colors 🍎: Enable or disable random food colors in the settings.

📚 Acquired Knowledge

Through developing this Snake Game, I gained valuable experience in:

  • Game Development Logic 🎮: Understanding game loops, state management, and player interactions
  • DOM Manipulation 🔄: Dynamic updates of game elements and UI components
  • Event Handling ⌨️: Managing keyboard inputs and touch events for controls
  • Local Storage 💾: Implementing data persistence for game settings and scores
  • API Integration 🔌: Working with external services (EmailJS) for notifications
  • Responsive Design 📱: Creating adaptive layouts for different screen sizes
  • Performance Optimization ⚡: Techniques for smooth gameplay and efficient rendering
  • User Experience 👥: Designing intuitive controls and feedback mechanisms

🤝 Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes. Ensure your code follows the project's coding standards and includes appropriate tests.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.


🌐 Let's Connect

Portfolio WhatsApp GitHub LinkedIn Email Twitter


🌟 Created with 💚 by Amr Elshabrawy

Logo

© 2025 - All rights reserved