Muhammad Osama Aqleem orakzai Abdul Musavir S Tatheer Hussain® ABDULLAH . The Pig Game (Pure JS Edition) Thrilled to share my latest web development project! 🚀 What started as a simple dice game turned into a deep dive into DOM manipulation and Responsive Design. The "Switching" Headache The hardest part? Managing the Player Switching Logic. 🤯 I struggled with keeping the state consistent—resetting the current score, toggling the active player's background, and ensuring the logic didn't break when a player rolled a '1'. After several refactors, I mastered using State Variables and Class Toggling to create a seamless transition between players. It was a "Eureka" moment in my JavaScript journey! 📱 Truly Responsive (Side-by-Side Layout) Most mobile games stack elements vertically, but I wanted to keep the Desktop Aesthetic even on small screens. Implemented custom Media Queries to scale the entire UI. Used Fixed Pixel Units for the "Current Score" boxes to prevent text overflow on mobile. Ensured Touch Targets (buttons) are perfectly sized for mobile users. 🛠️ Key Features: Dynamic UI: Backgrounds and text colors change based on the active player and game state. Winning Logic: A dedicated "Winner State" where the winner's name highlights in white for a premium feel. Performance: Lightweight, fast, and built with zero external libraries—just HTML5, CSS3, and Vanilla JavaScript. Check out the live game here: https://lnkd.in/dcKWPjTh #WebDevelopment #JavaScript #CodingJourney #FrontendDeveloper #ResponsiveDesign #ProgrammingLife ab yeh check kar

To view or add a comment, sign in

Explore content categories