Inspiration We wanted to take a game everyone already knows and loves, and ask — what if it actually fought back? Classic Snake is a solo experience with predictable rules. We were inspired by the idea of adding a living opponent, dynamic consequences, and a power-up that gives you power but also gives you rope to hang yourself with. The goal was to make every run feel different.What It Does Snake v2.0 is a browser-based Snake game with a twist. An NPC snake shares the board with you, moving independently and blocking your path. Food items affect more than just your length — red apples speed you up, blue apples slow you down and cost you points, candies give small score boosts, and coloured dots change your snake's colour. The umbrella power-up grants 5 seconds of full protection — including the ability to pass through walls — but if you're still out of bounds when the timer expires, you lose instantly. How We Built It Built entirely in vanilla HTML, CSS, and JavaScript — no frameworks, no libraries. The game runs on a single setInterval game loop with a hand-rolled NPC AI, a rejection-sampling food spawner, and a two-pass canvas renderer for smooth snake visuals. The start screen features an animated demo snake and a pixel-art logo rendered programmatically on a element. Everything from collision detection to speed management is handled in pure JS logic. Challenges We Ran Into The NPC was the biggest early challenge. A naive random-direction approach looked terrible — the snake would vibrate, reverse into itself, and die in corners immediately. We solved this with a layered decision system: ahead-checking, safe-direction filtering, and a turn cooldown integer to prevent jitter.Speed management was another hurdle. JavaScript's setInterval can't change its interval mid-flight, so every speed change required tearing down and rebuilding the game loop entirely — a simple but slightly imperfect solution.We also hit a subtle direction bug early on where pressing two keys rapidly within a single frame could reverse the snake into itself. The fix was committing nextDir to dir only at tick time, not on keypress — one line that eliminated an entire class of insta-deaths. Accomplishments That We're Proud Of The umbrella mechanic is something we're genuinely proud of. The idea that protection doesn't mean safety — that you can pass through walls but the clock never stops — created emergent tactical gameplay we didn't fully anticipate when designing it. Players instinctively start using the wall as a tool rather than fearing it.We're also proud of how clean the codebase stayed despite the feature complexity. The NPC, speed system, protection mechanic, and renderer all operate in isolation. Adding new food types or behaviours requires touching almost nothing else.

Log in or sign up for Devpost to join the conversation.