OneCompanion

开发者

在 OneCompanion 上发布你的浏览器游戏。

阅读开发者指南

带来你的网页游戏,其余交给我们。

在线房间、玩家账户、进度保存、20 种语言的商店页面以及我们的桌面应用,全部免费。在这里发布不具排他性:你的游戏也可以在其他任何地方发行。

  • 无需服务器的多人游戏

    relay 和 lockstep 房间运行在我们这边。你的游戏只需发送字节;房间、邀请链接、指令顺序和中途加入都由我们处理。

  • 现成的玩家体系

    访客无需注册即可游玩,一个账户通用于所有游戏,进度由平台保存。由服务器运行的游戏可以计入排名,并有排行榜和锦标赛。

  • 20 种语言,浏览器与桌面端

    你的商店页面以 20 种语言触达玩家,包括从右到左的语言。游戏可在浏览器和我们的桌面应用中运行,按需提供指针锁定、全屏和手柄支持。

已在这里上线

独立开发者的游戏在这里运行,并由我们加入了在线玩法;我们自己的游戏也使用与你相同的接口约定。

你的工作室

登录后查看你的工作室。

登录

运作方式

你用 JavaScript 或 TypeScript 按照一个很小的约定来开发游戏:客户端提供一个 mount 函数,如有需要,再为服务器提供一个游戏模块。我们的命令行工具会构建、检查并上传游戏。

每个版本在玩家看到之前都会由我们的团队审核。OneCompanion 在沙盒框架中运行你的游戏:它永远看不到玩家的账号,只能通过所在房间访问网络,存档由平台保管。

多人游戏

none
仅单人,没有房间。
relay
房间在玩家之间转发消息。适合合作和聚会游戏。不计排名。
lockstep
房间按步骤排列每位玩家的指令,并为中途加入的玩家保存记录。你的模拟必须是确定性的。不计排名。
server
你自己的游戏模块在房间旁运行,决定所有结果。仅限受邀。

通过命令行发布

在工作室页面创建令牌,然后在游戏目录中运行以下命令:

使用 Bun

git clone https://github.com/onecompanion-net/sample-game
cd sample-game && bun install
bun run validate
export ONECOMPANION_API=https://onecompanion.net
export ONECOMPANION_TOKEN=oc_…
bun run publish:game

使用 npm

git clone https://github.com/onecompanion-net/sample-game
cd sample-game && npm install
npm run validate
export ONECOMPANION_API=https://onecompanion.net
export ONECOMPANION_TOKEN=oc_…
npm run publish:game

npm 负责安装依赖和运行脚本,但工具本身运行在 Bun 1.3 或更高版本上,所以无论如何都需要安装 Bun。

开始新游戏

还没有游戏?从一个可玩的小模板开始:solo、relay(玩家共享画面)或 lockstep(每位玩家指挥自己的单位)。生成后即可通过检查。

bunx github:onecompanion-net/game-cli init my-game --template relay
cd my-game && bun install && bun run dev

翻译:i18n 命令会把每种缺少的语言写成英文副本,并输出一段提示,让你的 AI 编程工具来翻译。未翻译的副本无法上传。

阅读开发者指南

用 AI 编程工具完成接入

在 Claude Code、Cursor、GitHub Copilot 或其他 AI 编程工具中打开你的游戏文件夹,然后给它这段提示词。它会阅读我们的指南,让你的游戏适配平台、完成检查,并在发布前停下。

I want to publish my browser game on OneCompanion (https://onecompanion.net), which hosts it, lists it in its catalog and runs its multiplayer rooms. Help me integrate this project with the platform and get it ready to upload.

1. Read the developer guide first: https://onecompanion.net/developers/guide.md. It is the contract; where my code disagrees with it, the guide wins. When unsure, compare with the sample game: https://github.com/onecompanion-net/sample-game.
   Use the OneCompanion integration skill as well: https://github.com/onecompanion-net/skills (the skill is skills/onecompanion-integration). If it is not installed in this tool, read its SKILL.md and the reference files it points to; use its templates (contract, client, relay, lockstep, dev host) instead of writing them from scratch.
2. Study this project and show me a short plan before you change anything: the engine, how the game starts and what it draws into, where its text lives, how it saves, any network code, and which room kind fits (none, relay or lockstep; server only if we were invited).
3. Integrate without breaking how the game runs today:
   - Add game.json with "studio": "<my-studio-handle>", an "id" I approve (it becomes the URL and can never be reused) and "version": "1.0.0".
   - Add a client entry that exports mount(host, options) and returns { onMessage, pause, resume, dispose }. Copy the types from the guide into src/contract.ts; import nothing from the platform. Draw only inside host, send onEvent({ type: 'ready' }) after the first frame, and make dispose() undo everything (animation loops, timers, listeners, DOM nodes, WebGL contexts, audio, workers).
   - Move every player-facing string into messages/en.json and show it through options.t (ICU plurals for counts). Lay out with CSS logical properties so right-to-left works.
   - Save with options.storage instead of localStorage, IndexedDB or cookies. Remove fetch and WebSocket calls to other hosts; load our own files with relative URLs.
   - For multiplayer, send with options.online.send and receive in onMessage, using the guide's byte formats exactly, and validate every message. For lockstep, keep the simulation deterministic (the room's seed, no Math.random() or clock).
   - Write listing/en.json (with "play" and "modes" lines if they fit the game); step 6 translates it. Prepare the art at the sizes in the guide, set the rating, and list every third-party asset and its licence under rights.
   - Keep the client entry and its static imports under 450 KB gzip; load the rest with dynamic import().
4. Add the CLI as a dev dependency from GitHub, never from the npm registry by name: "bun add -d github:onecompanion-net/game-cli" (or "npm install -D github:onecompanion-net/game-cli"). Add the scripts "validate": "onecompanion-game validate .", "i18n": "onecompanion-game i18n ." and "publish:game": "onecompanion-game publish .". The tools need Bun 1.3 or later even when I use npm.
5. Copy the sample's dev page (index.html and src/dev.ts) so I can test solo, with ?net=room in two tabs, and with &lang=vi and &dir=rtl.
6. Run the i18n script and translate every file it marks "$untranslated" (the 12 launch store locales are required; in-game languages are up to me), removing the marker from each file you finish. Then run the skill's preflight check (node <skill folder>/scripts/preflight.mjs ., from an installed or cloned copy of the skill), then the validate script, and fix every issue until both pass.
7. Then stop. Tell me what you changed, what you could not do and what I should check by hand. Do not publish: I will set ONECOMPANION_API=https://onecompanion.net and ONECOMPANION_TOKEN in my own terminal and run the publish:game script. Never ask for the token, print it, write it to a file or commit it.

把 <my-studio-handle> 换成你的工作室标识,或者到你的工作室页面复制已填好标识的提示词。

切勿把工作室令牌粘贴到 AI 对话中。发布时请在你自己的终端里设置它。

规则

  • 游戏中的一切都必须归你所有或已获授权,并列出你使用的他人内容。
  • 将商店介绍翻译成全部 12 种语言。游戏内文字须包含英文,并尽可能添加更多语言。
  • 不得伪造登录提示、平台对话框或游戏外链接。如实为游戏分级。