Pool Game Source Code: Inside an 8-Ball HTML5 Package
Physics, rules, CPU and saves in separate files: what the Velvet Pool source contains and what a buyer changes first.

Pool game source code is worth buying when three things live in separate, readable files: the ball physics, the 8-ball rules and the computer opponent. If those are tangled together, every change to the cloth colour or the CPU difficulty turns into a debugging session. Velvet Pool, our 8-ball template, keeps them apart, and this guide walks through its package file by file.
We cover how the code is organised, what a buyer usually changes first, how to host it or wrap it as an app, what the licence allows and what the edition leaves out. Every file name below comes from the buyer guide that ships with the game.
The short version: Velvet Pool is plain JavaScript on WebGL2, with no 3D library and no build step. You edit a file, copy it to the game folder and reload the page.
What this pool game source code contains
Velvet Pool is a finished 8-ball game, not an engine or a starter kit. The download has four folders: game/ is the ready-to-upload build, source/ is the same game as a developer edition with a README, package.json and tests, documentation/ holds the illustrated guide in English and Portuguese, and THIRD-PARTY-LICENSES/ keeps the font licence texts.
The game itself plays 8-ball with fouls, ball-in-hand and solids or stripes. There are three CPU levels (Easy, Medium and Hard), a free practice table with undo, ball placement and re-rack, and two-player matches on one device. Players add follow, draw or side spin to the cue ball, and local achievements unlock five cloth colours and five cue styles. The interface comes in 14 languages.
- Stack: vanilla JavaScript, ES modules and WebGL2. No Three.js or other code library.
- Code: plain, formatted JavaScript in source/src and game/src. Nothing is minified or bundled.
- Tests: optional, with Node.js 20 or newer. They check physics, 8-ball rules, CPU matches and translation keys.
- Version at the time of writing: 1.1.0, updated on 22 October 2026.
See the Velvet Pool listing, demo and manual
How the files are organised
game/ and source/ share the same layout, so a path in one folder points to the same file in the other. The split that matters most for a pool game is between src/core/ (simulation and rules) and src/game/ (everything the player touches).
- src/core/physics.js: ball simulation, spin and cushion response.
- src/core/rules.js: 8-ball rules and foul decisions.
- src/core/ai.js: how the CPU picks its shot.
- src/game/controls.js: aiming, power and spin input.
- src/game/progress.js: achievements, cloths, cues and match scoring.
- src/game/i18n.js: the texts in 14 languages, listed in LANGS.
- src/game/localRecords.js: the local score history.
- src/game/audio.js: effects and music playback.
- css/style.css and css/fonts.css: theme, responsive layout and font declarations.
- assets/: art, audio and fonts, with the logo files in assets/logo/.
Because physics, rules and CPU are separate modules, you can make the CPU more forgiving without touching how the balls move, or change a foul rule without retuning the cushions. That separation is the main thing to look for in any billiards code you buy.
What a buyer changes first
Most projects follow the same order. Start with what players see, then move to what they feel, and leave the rules for last, because rules are the easiest place to introduce a bug.
- Branding: replace the logo files in assets/logo/ and adjust the matching sizes in the CSS. White label is allowed, so your name or your client's can replace ours.
- Look of the table: colours and fonts live in css/style.css. Cloth and cue definitions live in progress.js. Keep their IDs stable, or players lose the cosmetics they already unlocked.
- Texts and languages: every string is in i18n.js. Edit the wording you need; the list of languages is in LANGS.
- CPU difficulty: shot selection is in ai.js. Tune one level at a time and play a full match against it.
- Physics: friction, spin and cushion response are in physics.js. Small changes go a long way here, so run the tests after each one.
- Rules: house variations belong in rules.js. Test fouls and ball-in-hand by hand as well as with the suite.
The workflow is the same for all of them: edit the file in source/, copy it to the same path in game/, serve the folder over HTTP and reload. The buyer guide suggests changing one feature at a time and testing the menu, a match, pause, the result screen and a reload after each change.
Hosting it, embedding it or wrapping it as an app
Hosting is the simplest part. Upload everything inside game/ to a folder such as public_html/velvet-pool/, keep the subfolders, and open the address. There is no npm, terminal, PHP, database or account on the server side. A plan that serves static files over HTTPS is enough.
- Do not open index.html by double-clicking it: browsers block the game modules on file://. For a local test, run python -m http.server 8765 inside game/.
- If the screen stays blank, check that WebGL2 is enabled and that file names keep their upper and lower case.
- If the browser refuses a module, your server is sending .js with the wrong MIME type.
- Inside an iframe on a portal, allow fullscreen and autoplay.
Everything the game needs at run time sits inside game/, so nothing loads from a CDN or another site. A fresh page load still reaches your host, so this is not an installable offline app. It does run on touch screens: players aim on the table and pull the power control.
Native app projects are not part of the package. If you want the game on Google Play or the App Store, a wrapper such as Capacitor, which its makers describe as a cross-platform native runtime for building mobile apps with web code, is one common route. Building and maintaining the store project is your work, or a service we quote separately.
What the edition leaves out
Velvet Pool is the local browser edition. It has no online multiplayer or private rooms, no online ranking, no cloud accounts and no advertising SDK. Two people can play on one device, and personal scores from eligible CPU matches are saved in the browser. Practice and same-device matches do not save a score.
Online play needs your own server and development. That is a real project, so budget for it from the start rather than expecting the template to grow into it. If your catalogue needs more sports games, these two are also sold as ready-to-host browser editions.
Puttide: 3D mini golf with 30 holes, also in plain JavaScript
Golazo: tabletop football with 50 national teams
Licence and price in one paragraph
Velvet Pool lists at $39. Until 30 November 2026 a Black Friday promotion takes 15% off every template, so it costs $33.15, and orders of two or more templates get a further 5% to 20% off. Each purchase is a perpetual, non-exclusive licence for one end product, yours or one client's. You may change the code, art and audio inside that product and put your own brand on it. Players can reach it free or through ads. You may not resell the template or its code on its own. Six months of support are included, or 12 with the extension at checkout; custom work, hosting and SDK or portal integration are quoted separately.
Read the full licence and support terms
FAQ
Is the pool game source code readable or minified?
Readable. The JavaScript in source/src and game/src is plain and formatted, with no minified or bundled files.
Do I need Node.js or a build step?
No. You edit the files in source/ and copy them to game/. Node.js 20 or newer is only needed if you want to run the optional tests.
Can I make the CPU easier or harder?
Yes. CPU shot selection lives in src/core/ai.js, separate from the physics, so you can tune it without changing how the balls move.
Does it work on phones?
Yes. Touch input is supported and the controls adapt to the screen. WebGL2 is required, and performance depends on the device, so test the phones your players use.
Will players keep their progress if I move the game to a new domain?
No. Saves belong to the browser origin, so changing the domain starts players fresh. Pick the final address before launch.
Can I add online multiplayer?
Not with this edition alone. It needs your own server and development. We can quote it as custom work.
Who this pool code fits
It suits a portal or site that wants an 8-ball game in its catalogue, an agency delivering a branded billiards game to one client, and a developer who wants to read how pool physics and rules are written without a 3D library in the way. It fits less well if your plan depends on online matches or a shared leaderboard.
Play the demo on a phone and on a laptop before you buy, and open the manual's file map. If the split between physics, rules and CPU matches how you plan to work, the rest is a few afternoons of changes.
