Table Tennis Game Source Code: Sunset Rally's Files, Physics and Campaign
A 3D ping pong game for the browser, opened file by file: where the physics, scoring, campaign and places live, and what to change first.

If you need table tennis game source code you can host and change, Sunset Rally is a finished 3D ping pong game for the browser with a nine-match campaign, three CPU rivals, a workshop and the full TypeScript project, for $39 at list price. The game folder is already built and unminified, so you can upload it first and read it later.
Sports games are harder to adapt than they look, because the fun sits in the physics and the controls, not in the menus. This guide shows where each of those lives in the Sunset Rally project, what you can change safely, and what this edition leaves out.
How the ping pong game plays
Matches go to seven points against a CPU rival. Players move the pointer or drag to control the paddle, and hits are automatic. Pushing up adds power, moving sideways places the ball, pulling down plays a drop shot, and a ball that sits up is there to be smashed.
An optional assist, which players can switch on and off during a match, helps the paddle find the ball's height. That matters for a public site: a first-time player on a phone can still return the ball.
There are three CPU rivals with their own styles: patient Capi, playful Nori and precise Miso, each on Easy, Normal or Hard. Training mode gives you a partner who returns every ball. After a match, a replay shows the decisive point again.
What the table tennis game source code package contains
- A ready-to-host game/ folder, already built and unminified.
- The TypeScript developer source with its Vite setup and the game assets, in source/.
- Illustrated manuals in English and Portuguese with real screenshots.
- Fonts and audio files bundled with the game.
- Third-party licence notices and a changelog.
The stack is TypeScript, Three.js r184, Vite and WebGL2. Files include HTML, CSS, JavaScript, TypeScript and JSON. The interface comes in 14 languages: English, Portuguese, Spanish, French, German, Italian, Dutch, Polish, Turkish, Russian, Indonesian, Japanese, Korean and Simplified Chinese. The manuals are in English and Portuguese only.
The content around the matches is part of the package too: a Sunset Circuit of nine matches in three stages, three places (the Sunset garden, the Sakura garden and the Seaside café) in morning, afternoon, night or rain, and a workshop where coins from wins buy paddle colours, rubbers, shapes, handles, woods, edge tape, stickers, and ball and table styles.
Where things live in the code
The manual maps each part of the game to a file. This is the list to keep open while you work:
- Campaign.ts: the nine campaign matches and their star goals.
- Places.ts: how each place looks.
- physics.ts: the ball and paddle physics.
- match.ts: scoring and match rules.
- i18n.ts: English and Portuguese interface text; the other languages are in the locales folder.
- styles.css: the styling of menus and screens.
Each campaign match has up to three stars: win, hit three corners and play a rally of ten. That makes 27 stars, and clearing each place earns a workshop prize. Because the star conditions sit in one campaign file, you can make a campaign easier or harder without searching the code.
What to change first in a ping pong template
We suggest this order, from low risk to high risk.
- Interface text and the game name, in i18n.ts and the locales folder.
- Colours and screens, in styles.css.
- Workshop styles for paddles, balls and tables, so the equipment carries your brand.
- Place visuals, in Places.ts.
- Campaign matches and star goals, in Campaign.ts.
- Physics and scoring, in physics.ts and match.ts, only if you need a different feel.
The manual adds three rules worth following. Keep unlock IDs, item IDs and save keys stable, or players lose what they earned. Back up before you start. Change one feature at a time, so you know which edit caused what.
White label is allowed: your name and logo, or your client's, can replace ours.
Rebuilding, hosting and embedding
To play, nothing needs to be built. Upload the contents of game/ to any HTTP(S) host that serves static files, keep the relative paths and open the address. No PHP, database or account is needed.
To change the source, you need Node.js (24 LTS is recommended) and npm. Edit the TypeScript, rebuild with Vite and replace the hosted game/ folder with the new output.
The browser needs JavaScript, ES modules and WebGL2. Touch and mouse controls are both supported, and the controls adapt to the screen size. Performance depends on the browser and the device, so test on the phones your players use.
- Upload game/ to a test folder on your host.
- Play one match on a desktop browser and one on a phone.
- Make your text and style changes in source/ and rebuild.
- Replace the whole test folder, then play again.
- Move it to the final address.
What this edition does not include
This edition is played against the CPU: campaign, free match and training. Online multiplayer, online rooms, online leaderboards and cloud accounts are not part of the package, and there is no two-player mode. There are no advertising SDKs or accounts, and native apps and hosting are not included.
Progress stays in the player's browser: campaign stars, results, statistics, replays and workshop items. No server or account is used, so there is nothing to maintain after launch.
If you need an online mode, a portal SDK, an app store version or installation on your server, that is a separate service, quoted per project.
Ask for a quote for custom work
Licence, support and price in one paragraph
One purchase gives a perpetual, non-exclusive licence for one end product, yours or one client's, which players may use free or with advertising monetisation. You may change the code, art and audio inside that product, but you may not resell or share the template, its source code or its assets on their own. Support lasts 6 months, or 12 with the extension at checkout, and covers installing and using the files and fixing reproducible defects; customisation, hosting and SDK or portal integration are quoted separately. The list price is $39; until 30 November 2026 a Black Friday promotion takes 15% off every template, so Sunset Rally costs $33.15, and from 1 December prices return to list.
FAQ
Do I need to build anything to use this ping pong game?
No. The game/ folder is already built. Upload its contents to a static web host and open the address. Node.js and npm are only needed if you change the TypeScript and rebuild.
Is there a two-player or online mode?
No. This edition is played against the CPU in the campaign, free matches and training.
Can I change the campaign and star goals?
Yes. Matches and star conditions are in Campaign.ts. Rebuild afterwards with Node.js.
Can I change how the ball behaves?
Yes. The physics is in physics.ts and the scoring rules in match.ts. Change one thing at a time and test against every rival.
Does it work on phones?
Yes, with touch controls that adapt to the screen. WebGL2 is required, and performance depends on the device, so test the phones you target.
Where is progress saved?
In the player's browser. No server or account is used.
Other sports templates to compare
If you are building a sports corner for a site, two other templates sit well next to Sunset Rally. Velvet Pool is an 8-ball billiards game with a CPU opponent and local two player, written in vanilla JavaScript with WebGL2, $39 at list price. Puttide is a 3D mini golf game with 30 holes, built on Three.js and Rapier, $39 at list price. Both have 14 interface languages.
Sunset Rally suits portals and sites that want a sports game with short matches, studios that deliver a branded game to one client, and developers who want a readable TypeScript and Three.js project to learn from or extend. If you need two players on the same device, Velvet Pool has that mode and Sunset Rally does not.
See Velvet Pool, the 8-ball game
See Puttide, the 3D mini golf game
Buying two or more templates in one order lowers each licence: 5% off for two, 10% for three, 15% for four and 20% for five or more.
