A 3D Godot game in one HTML file, with the code on the page
Last Light is a 3D game in one HTML file. You sail a small boat through a storm at night and relight five dark lighthouses, and each one you light calms the sea and moves the sky toward sunrise. The file is about 1,330 lines and 62 KB. It holds the game's GDScript and five shaders as plain text, loads the Shiny Gen engine from one script tag, and uses no image, model or sound files. Its page has three buttons: View plays the game full screen, Code opens an editor with the whole file beside the game, and How to explains how to make your own. Change the code, press Run, and the game restarts with your change.

Play it
Open shinygen.ai/godot_html/lighthouse_storm.html.
- Keyboard: arrow keys or WASD.
- Touch or mouse: hold and drag left or right. On a phone the on-screen arrows also steer.
- Goal: sail to each red lamp. A marker shows the distance to the nearest dark lighthouse.
A desktop browser with WebGPU gets the WebGPU renderer, with bloom and light beams in fog. Phones and browsers without WebGPU get the WebGL renderer. The game plays the same on both, and the picture is a little flatter on WebGL.

What is in the file
The whole game is text inside the page:
| Part | What it does |
|---|---|
One text/gdscript block | The game: boat, camera, lighthouses, islands, the sky clock, input, the heads-up text and the sound |
sky shader | Clouds, stars, moon, sun and forked lightning on a dome around the camera |
water shader | Waves, sky reflection, sun and moon glitter, foam, the boat's wake and surf on the rocks |
beam shader | The lighthouse beams |
rain shader | Thousands of rain streaks in a box that follows the camera, so near drops pass close and far ones hang behind |
frame shader | The dark corners of the picture and the white of a lightning flash |
| One script tag | Loads the engine from the shinygen npm package |
Nothing else is downloaded for the game itself. The boat hull, the sails, the rocks and the lighthouses are meshes built in GDScript when the page loads. The storm, the thunder and the chime you hear when a lighthouse lights are sound samples computed in GDScript too.
The engine is the download: about 12 MB for the WebGPU engine or about 11 MB for the WebGL engine, compressed, from the npm CDN. The page pins an exact version, shinygen@4.6.9, so it keeps working the same way.

How the page is put together
The pattern is three pieces. This is the smallest version of it:
<canvas id="canvas"></canvas>
<script src="https://cdn.jsdelivr.net/npm/shinygen@4.6.9/shinygen.js"></script>
<script type="text/gdscript" name="Main">
extends Node3D
func _ready():
var light = DirectionalLight3D.new()
light.rotation_degrees = Vector3(-45, 30, 0)
add_child(light)
</script>
<script>
ShinyGen.start({ canvas: "#canvas" });
</script>
The engine reads every text/gdscript script on the page and runs it. Shaders go in text/gdshader scripts with a name, and the GDScript asks for them by that name. Last Light uses exactly this, with a longer script and one extra option, autoFit: false, so the game fills the window at any shape. The embed guide has the full reference.
A few things in the game that are worth reading in the Code panel:
- The boat rides the same waves you see. The wave shape is written twice, once in the water shader and once in GDScript, with the same numbers. GDScript samples the height under the bow, stern and sides each frame and sets the boat's height, pitch and roll from them.
- One number drives the whole mood. A value from 0 to 1 counts how many lighthouses are lit. The sky colors, cloud cover, stars, moon, sun height, wave size, rain, fog, foam and storm volume are all read from it, across four set points: storm, clear night, first light and sunrise.
- The water reflects a sky it never renders. The water shader works out the sky color in the mirror direction from the same colors the sky dome uses, then adds glitter toward the moon or the sun.
- Meshes from code. The hull is a row of cross sections joined into triangles. The sails are a grid of points pushed sideways to give them belly. The rocks are spheres with random bumps.
Change it and run it
Press Code and the file opens in an editor beside the game. Three easy edits to try:
- Find
L A S T L I G H Tand type your own title. - Find
LIGHT_RANGE := 32.0and make it60.0to light a lighthouse from further away. - Find
st.y * 16.0and raise16.0for a faster boat.
Press Run, or Ctrl + Enter (Cmd + Enter on a Mac). If the code has an error, the message and its line show under the editor. Reset brings the original back, and Download saves your version as one HTML file.
You can also hand the file to an AI assistant such as Claude or ChatGPT. Press Copy, paste the file into the assistant, say what you want changed and ask for the whole file back, then paste the answer into the editor and press Run.
To make a new game instead, the How to button on the page has a request you can copy. It tells the assistant what the engine is and includes a complete blank page, a spinning cube, to start from. Paste the file the assistant gives you into the editor and press Run to play it there.
How it was made
The game was written by Claude Code, an AI coding assistant, working in our repository from a short request: a single HTML page, all GDScript, on the shinygen npm package. It did not use the Shiny Gen app or its built-in agent. It wrote the file, loaded it in a real Chrome window, took screenshots, looked at them and changed the code, many times over.
The first version took about 20 minutes and looked rough: a boat made of boxes, a flat sky and cloudy water. We asked for a much better looking one, and the second pass rewrote the sky, the water, the boat and the lighthouses. That is the version on the page.
Two bugs from that pass, because they are the kind you only find by looking:
- The lighthouse beams were invisible. The sky dome was being drawn after them and covered them. One render setting on the sky shader fixed it.
- The first frame took seconds. The game built everything before drawing anything, so the screen stayed blank while the shaders compiled. It now starts in steps, one per frame: the title on a dark screen first, then sky, sea and rain, then the boat and the lighthouses. Sharing one set of material features across every solid object also cut the number of shaders to compile.
- The first lighthouse stuttered. Its beam and spotlight were drawn for the first time at the moment you lit it, so their shaders compiled mid-game. The game now draws one beam during loading, behind the loading picture.
- Foam followed the camera. The first foam rule faded with distance from the camera, so a patch of foam followed the boat even in calm water. Foam now depends on the storm, and calm water is clear.

What was tested, and what was not
- Tested: the game boots with no script errors on WebGPU and on WebGL in desktop Chrome on a Mac, at 61 frames per second at 1280 by 720 on that Mac. Sailing to a lighthouse lights it. Keyboard and hold-and-drag steering work. Every stage of the night was looked at on both renderers. On the page, editing the title and pressing Run showed the new title, a broken line showed its error under the editor, and Reset brought the original back.
- Not tested: real phones and tablets. The phone-sized test ran in desktop Chrome.
- The ending: with all five lit, the camera circles the boat, every beam swings up into the sky, and R or a tap starts the night again. This was run with a test key that lights the lighthouses in turn, not by sailing to all five.
Questions
Is this the real Godot engine?
It is the Shiny Gen engine, which is our fork of the Godot engine, version 4.6, with a WebGPU renderer and a WebGL fallback. The code in the file is GDScript and Godot shader language, using Godot's own node and class names.
Can I copy the file and change it?
Yes. Press Code, change it and press Run to try your change on the page. Copy or Download gives you the file, which you can serve from any web server. It needs to be served over http or https, because the engine is fetched from the npm CDN. The engine's license is in the shinygen package.
Do I need to write GDScript by hand to make a game like this?
No. In the Shiny Gen app you can start a Godot game and describe it, and the AI agent writes the GDScript, runs the game and fixes what it finds. Writing a single page by hand, or with your own AI assistant, is the other way to use the same engine.
Why one file?
It is easy to read, share and host. There is no build step and nothing to keep in sync, and the editor can show you everything because everything is in the file.
