Dev Log: How We Bring Our Mobile Games to the Browser
Dev log · 6 min read
Most games on FreeFunGames also exist as Android apps on Google Play, and the browser version is not a cut-down port. It is the same game, built from the same source code. This dev log explains how that works, what we had to change to make the games feel right in a browser tab, and where the web still has real limits.
One game, written for the web first
Every game here starts life as an HTML5 web game. The tools vary from game to game:
- Honey Hex is written in TypeScript and draws its honeycomb on a plain HTML canvas, with no game engine at all.
- Bouncy Sky Stairs uses Phaser, a popular 2D web game framework.
- Abyss Dive uses PixiJS for its underwater scenes.
- Mallang Toy Island is a 3D game built on Three.js, written in plain JavaScript modules.
Most are bundled with Vite, a common web build tool. Whatever the engine, the output is an index.html plus scripts, images and sounds that any modern browser can run.
Starting on the web is simply the fastest way to iterate: a code change shows up in a browser in a second, and we can test on a laptop and a phone at the same time.
How the Android app wraps the web game
The Android version of a game is a thin native shell around that same web build. For Honey Hex, the app is a small React Native project whose main screen is a full-screen WebView, a browser view embedded inside the app.
For each app build, a script runs the web build and merges the result into a single self-contained HTML file, images included, which ships inside the app. The game loads from the phone, not the internet, so it starts quickly and the core game works offline.
The native shell handles the things a web page cannot do well on its own:
- Vibration for short haptic feedback on big moments.
- The Android back button, which the game should treat like "go back a screen", not "close the app".
- Pausing audio when the app goes to the background, and restoring it when you return.
- Ads and analytics through the platform's own SDKs.
The two sides talk through a small message bridge. The game sends a short message like "vibrate, medium" or "show a reward ad", and the app replies. The bridge first checks whether it is running inside the app; if not, it does nothing or uses a web alternative. That one check lets the exact same code run in both places.
How the same game runs on this site
On FreeFunGames, each game is built from its own source folder and served under its own path on this site. The game page then shows it in an embedded frame with a player bar underneath: report a bug, reload, fullscreen, and a link to the Google Play version where one exists.
A few things needed care here.
File paths. Some games referred to images and sounds with paths that assumed the game lived at the root of a website, which broke inside a subfolder. Rather than editing every game, the site's build step rewrites those paths, and the game's own source stays untouched.
Ads. The games already had optional "watch an ad for a reward" buttons in the app. On the web, the same buttons ask the site for a web ad instead. A reward is only given if the ad is watched to the end, rewarded ads only appear when you press one of those buttons, and full-screen ads are limited to natural breaks such as the end of a level, with a minimum gap between them. Game audio pauses while an ad plays.
Sound. Browsers block sound until the player interacts with a page, so the games unlock audio on your first tap or click. If a game seems silent at first, that is why. They also mute themselves when you switch tabs.
Saving progress in the browser
On a phone and in a browser, the games save the same way: in the browser's local storage, a small private storage area that belongs to the site on your device. No account is needed.
Honey Hex is a good example of how we try to make this robust:
- The save is a single structured record (your level, stars, honey, boosters, daily missions and even the level you are halfway through) with a version number.
- When a new update adds a field, the game fills it in from defaults when it loads an older save, so updates do not wipe your progress.
- The game saves whenever you leave the page, including when you switch tabs or when a phone browser puts the page to sleep. Mobile browsers can discard background tabs without warning, so saving only on a "quit" button would lose progress.
Some games go further. Mallang Toy Island can export your whole island as a backup file and load it again, and Abyss Dive keeps three separate save slots.
The honest limitation: local storage belongs to one browser on one device. Browser progress does not move to the Android app or another computer, and clearing site data or playing in a private window starts you fresh. If a game offers a backup export, use it.
What changes for controls
Phone games are designed for thumbs; desktop players expect a keyboard and mouse.
- Pointer events. Where we can, the games listen for pointer input, which covers mouse, touch and pen with the same code. Dragging a stack in Honey Hex works the same with a finger or a mouse.
- Keyboard shortcuts. Bouncy Sky Stairs accepts the arrow keys, A and D, or F and J for hopping, so you can play with two hands, and Space or Up for the rocket. There is also an option to swap the left and right buttons.
- Different schemes for different devices. Mallang Toy Island is the biggest change. On a computer it uses WASD to move and the mouse to look, locking the pointer after you click into the game. On a touch device it shows a joystick and action buttons instead. The game decides which to show based on whether the device has a touch screen or a narrow window.
What changes for screen sizes
A browser window can be any size, and players resize it mid-game.
- Canvases resize themselves when the window changes, and the layout is recalculated. Honey Hex, for example, sizes the honeycomb to fit the space between the top bar and the tray, whatever that space is.
- Sharp but not wasteful. High-density screens get a sharper canvas, but the resolution multiplier is capped. Without a cap, a large high-density display would push a huge number of pixels every frame for no visible gain.
- A frame that matches the game. Each game has an orientation setting, and the site's player shapes its frame to match, with a fullscreen button for a bigger view.
What we learned
Building for the web first and wrapping for mobile has worked well for a small team: a bug fixed for the web is fixed in the app too. The cost is a handful of easy-to-forget details, such as audio rules, save timing, absolute paths and very large or very small windows.
If something feels off in a browser version, please use the bug button under the game. We read those reports, and they shape what we fix next. And if you want to see the result, try Honey Hex on a phone and on a laptop: it is the same game in both places.