Inspiration

We wanted to flip a classic: instead of controlling the snake, you are the prey. That led to Reverse Snake—you play as the fruit, and an AI snake chases you. We liked the idea of a quick, skill-based game that fits Reddit’s feed and works on mobile and desktop.

What it does

Reverse Snake is a Reddit Devvit mini-game where you control the fruit with touch or mouse and try to survive as long as possible without being caught by the snake or hit by its projectiles. Story Mode: 30 levels with different rules (smaller arenas, projectiles, power food, modifiers like invisible snake or shrinking arena). You get 3 lives per day; beat a level to unlock the next. Survival Mode: Play any unlocked level for unlimited attempts and compete for high scores. Leaderboards track story progress and per-level survival times. Power food: After 30 seconds you can eat the same food the snake wants; doing so shrinks and slows the snake. In Survival, past 1 minute each food has a stronger effect so skilled players can last longer. Snake behavior: The snake uses distance-based pathfinding, prioritizes power food over you, and gets faster and longer over time (with caps). In Survival, if you shrink the snake, it no longer grows back to the original cap, so your plays have lasting impact.

How we built it

We used Reddit Devvit (serverless apps on Reddit) with a React 19 + Vite frontend and Tailwind CSS 4 for layout and styling. The game loop is tick-based and drawn on HTML5 Canvas with smooth pointer/touch input. Backend is Node.js on Devvit with Hono and tRPC for type-safe APIs. Redis (via Devvit) stores level progress, daily lives, and leaderboard data. Level configs live in TypeScript (grid size, speed, growth, projectiles, power food, modifiers). Collision and snake AI run on the client; score submission and leaderboards run on the server.

Challenges we ran into

Snake vs. fractional position: When the fruit was between grid cells, a purely grid-based snake could get stuck. We fixed it by having the snake target the fruit’s exact (fractional) position with distance-based pathfinding instead of cell-to-cell only. Lives UX: We had to make it clear that each game start costs one life (win or lose), and that hearts update everywhere (splash, menu, game over). We also guarded against double-clicks so one tap doesn’t consume multiple lives. Devvit config: Scheduler and permission formats in devvit.json were strict; we had to match the exact schema (and temporarily dropped the “lives restocked” notification feature until the right config is confirmed). Survival balance: We added an effective max length so when you shrink the snake with power food, it doesn’t grow back to the original cap, and we tuned the “after 1 minute” bonus so Survival doesn’t feel like a hard plateau. Accomplishments that we're proud of 30 distinct levels with clear rules (projectiles, power food, modifiers) and a full level guide in the README. Dual leaderboards (story progression + per-level survival) with automatic score submission and no manual “submit” step. 3 lives per day with clear heart feedback (❤️/🖤) on splash, menu, and game over, and protection against accidental multiple life consumption. Survival mode tuning: Speed and growth stay challenging, but power food after 1 minute and the shrinking cap give skilled players a way to push survival time without hitting a boring ceiling. Mobile-friendly: One codebase for touch and mouse, responsive layout, and a compact “How to Play” that works in Reddit’s UI.

What we learned

We learned how Devvit’s serverless + Redis model fits a real-time game (client for loop and input, server for persistence and leaderboards), and how important it is to design snake AI against continuous player position instead of grid cells only. We also saw how small UX details (when lives are spent, how hearts update, double-tap guards) really matter for a “3 lives per day” mechanic.

What's next for Reverse Snake

Scheduled “lives restocked” notifications once we lock in the correct Devvit scheduler/permissions config. More modifiers or level themes (e.g. maze walls, multiple snakes, or power-ups that affect projectiles). Optional sound and haptics for hits, power food, and level complete. Polish: Animations for power food and projectiles, and clearer in-game cues for the “after 30s / after 1 min” Survival rules.

Built With

Share this project:

Updates