Browser-Based 3D Survival Game
A 3D survival game that runs in the browser, built with Babylon.js. The world is generated as you explore, and you gather resources, craft tools, fight animals and level up. I built it with an AI-assisted “vibe coding” workflow in Windsurf to see how far that approach could take a real game, and where it starts to need ordinary engineering.
What it does
- Procedural world. Terrain comes from Perlin noise and loads in chunks, so the map can keep going without designing it by hand. You spawn on a flat, clear area.
- Harvesting and crafting. Trees and rocks give resources, which you craft into tools and planks.
- Animals and combat. Animals spawn and move on their own. Fighting them earns experience, with health and level tracking.
- Day and night. Lighting changes as the day cycles.
- Flying. Double-tap jump to fly, a feature that started as an experiment and stayed.
How it’s built
The first version grew into a single JavaScript file of more than 1,000 lines, which is fine for a prototype and painful after that. I split it into modules for terrain, player, inventory, animals, combat and UI, coordinated by one central game class, so each system can change without breaking the others. Babylon.js loads from a CDN, and a web app manifest and service worker lay the groundwork for installing it as a Progressive Web App and playing offline.
Run it
The code is on GitHub. Clone it, start any local web server in the folder (for example python -m http.server 8000), and open it in a modern browser. Mouse to look, WASD to move, Space to jump.
Read the build story
Vibe Coding a Babylon.js Survival Game with Windsurf covers what AI-assisted coding got right, where it broke down, and how I would build it today.
Want something like this for your business? See full-stack and custom development, or book a call.
