## Inspiration
We wanted to explore what it means to build a truly *communal* gaming experience. Most mobile or web games are

isolated single-player experiences, or highly competitive multiplayer lobbies. We wanted to build something where an entire community works together asynchronously. "The Last Kings" was inspired by the idea of transforming a standard Reddit post into a persistent, massively multiplayer battlefield where every user's small contribution ripples across the entire subreddit.

## What it does
"The Last Kings" is an asynchronous, massively multiplayer tower defense game built natively into a Reddit post

via Devvit. The entire subreddit shares one persistent, global battlefield. - Global State: The central Keep's health and the daily boss's health are synced for everyone viewing the post. It's not per-player; it's per-community. - Action Point Economy: Players get a strict Action Point (AP) allowance per day, forcing daily return visits and careful strategic choices. - Tactical Deployment: Players spend AP to drop units (Swordmasters, Flame Casters, Brutes, etc.) onto a shared grid. Each class deals collective damage to the daily boss, defending the central Keep.

## How we built it
The project pushes the boundaries of the Reddit Devvit ecosystem.
- **Frontend:** We built a custom 2D rendering engine using **Phaser 3** and **Vite**, heavily optimized for

mobile-first responsive design. We implemented a forced-perspective 2.5D camera, glassmorphism UI overlays, and code-based VFX layers. - Backend: We utilized the Devvit serverless Node.js environment, wrapping our API in Hono. - Communication: To ensure absolute type safety between the Phaser frontend and the Devvit backend, we implemented tRPC (v11). - State Management: The global game state, AP economies, and grid data are persisted using Devvit's Redis datastore, with daily resets driven by the Devvit Scheduler.

## Challenges we ran into
Building a complex WebGL game engine inside an iframe on a social media feed is incredibly difficult.
- **Mobile Responsiveness:** Initially, the game canvas didn't scale well on mobile devices. We had to

completely rewrite the scaling logic to use a full-bleed CSS architecture with dynamic camera auto-zooming and touch-to-pan controls. - Asset Rendering: Getting the depth-sorting right on a 2.5D isometric-style grid required us to write dynamic Y-sorting algorithms so units properly overlapped each other. - State Syncing: Ensuring that the global Keep health didn't desync when hundreds of players might be interacting with the post simultaneously required careful Redis key management.

## Accomplishments that we're proud of
We are incredibly proud of the visual polish. By combining high-quality anti-aliased assets, drop shadows,

dynamic scaling, and ambient lighting, we made an HTML5 canvas game feel like a premium mobile app native to the Reddit feed. We're also proud of the fully typed end-to-end architecture (tRPC + Devvit) which made iterating on gameplay mechanics incredibly fast.

## What we learned
We learned a massive amount about responsive WebGL design and how to optimize Phaser 3 for constrained

environments (like an iframe in a social media app). We also learned how to leverage serverless architectures for real-time game state synchronization.

## What's next for The Last Kings
We plan to introduce dynamic wave scaling based on the subreddit's active user count, specialized boss

encounters, and an expanded unit loadout system where players can earn packs to unlock rarer units!

Built With

Share this project:

Updates

Submission history