Shiny Gen / Blog

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.

Last Light: a small sailboat with lit cabin windows on a dark stormy sea, a fork of lightning hitting the horizon, a striped lighthouse on rocks with a red lamp, and rain across the frame.
The storm at the start. The lightning, clouds, rain, waves, boat and lighthouse are all drawn from code in the page.

Play it

Open shinygen.ai/godot_html/lighthouse_storm.html.

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.

Last Light at night: the first lighthouse is lit, with a bright lamp and two long beams sweeping across a dark cloudy sky, a second lighthouse with a red lamp behind it, and the sailboat in the foreground.
One lighthouse lit. The rain thins and the first stars show.

What is in the file

The whole game is text inside the page:

PartWhat it does
One text/gdscript blockThe game: boat, camera, lighthouses, islands, the sky clock, input, the heads-up text and the sound
sky shaderClouds, stars, moon, sun and forked lightning on a dome around the camera
water shaderWaves, sky reflection, sun and moon glitter, foam, the boat's wake and surf on the rocks
beam shaderThe lighthouse beams
rain shaderThousands of rain streaks in a box that follows the camera, so near drops pass close and far ones hang behind
frame shaderThe dark corners of the picture and the white of a lightning flash
One script tagLoads 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.

The Last Light page with the Code panel open: the game on the left with its title and the sailboat, and on the right an editor with line numbers showing the top of the HTML file, and Run, Reset, Copy and Download buttons.
The Code button slides in an editor with the whole file. Run restarts the game with your changes.

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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:

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:

Last Light at sunrise: the sailboat on calm teal water, two lit red and white lighthouses on a rocky island, a warm pale sky and the words THE COAST IS LIT with the time 0:13.
The ending. With all five lit, the storm is gone and the sun comes up.

What was tested, and what was not

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.

Last updated: November 30, 2026

Start makingDownload on the App StoreGet it on Google Play