網頁遊戲
語言、國家與幣別: ZH · 價格

儲存在這台裝置的 Cookie 中。其他幣別的價格為約略值;每則刊登也會顯示賣家原本的價格。匯率由 Exchange Rate API 提供,每日更新。

網頁遊戲

為 Sofala 製作瀏覽器遊戲

Players start your game right on play.sofala.market, with nothing to install: free games at once, paid ones after one payment. The easy way is to let an AI agent build and upload it; doing it by hand comes after.

和你的 AI 代理一起

You do not need to know how to program. A coding agent writes the game with you, uploads it to Sofala, writes the listing and publishes it when you say it’s done. Any agent that works with MCP servers can do this; these steps use Claude Code on Windows, and we recommend it with the model Opus 5.5 or newer.

  1. Get a Claude accountGo to claude.ai, create an account and choose a paid plan (Pro or higher). Claude Code is not part of the free plan.
  2. Open PowerShellPowerShell is a window where you type commands. Press the Windows key, type powershell and press Enter. A window opens with a line that starts with PS C:\Users\ and your name. That is where the next lines go.
  3. Install Claude CodeCopy this line, paste it into PowerShell (right-click pastes) and press Enter. Nothing seems to happen while it downloads; wait until it says it is done.
    irm https://claude.ai/install.ps1 | iex
    Now close PowerShell and open it again. This matters: the window you installed from does not know the new program yet.
  4. Check that it worksIn the new PowerShell window, this prints a version number:
    claude --version
    Does it say that claude is not recognized? Then Windows has not been told where Claude Code is. Paste these two lines, one after the other, close PowerShell, open it again and try once more:
    $currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
    [Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User')
    Still stuck? Claude Code’s page for installation problems lists the other causes.
  5. Add Sofala, before you start Claude CodeThis tells Claude Code where Sofala is, so it can upload and publish for you. Paste it and press Enter:
    claude mcp add --transport http Sofala https://sofala.market/mcp
  6. Start Claude CodeType this and press Enter:
    claude
    The first time, your browser opens and asks you to sign in with your Claude account. Do that and come back to the PowerShell window.
    Does it stop to ask permission too often? Start it with this line instead, with no checks at all. It then does everything without asking, also when it gets something wrong, so use it only if you accept that; Anthropic advises it only on a computer with nothing on it that you would miss.
    claude --dangerously-skip-permissions
  7. Connect it to your Sofala accountInside Claude Code, type the line below and press Enter, pick Sofala and choose to sign in. Your browser opens sofala.market: type your email address, then the code Sofala emails you. That also makes your Sofala account if you have none; it is free and has no password. Then press Allow. Back in Claude Code, Sofala now shows as connected.
    /mcp
  8. Pick the modelType the line below, press Enter and choose Opus 5.5 or newer. A game is a lot of code, and smaller models make more mistakes.
    /model
  9. Ask for your gameNow say what you want, in your own words and in any language. For example:
    Make a simple online multiplayer snake game that runs in the browser, for Sofala. Use Sofala’s multiplayer rooms so friends can join. Let me test it, and when I say it’s done, put it on Sofala as a free game.
  • When the game is ready to try, your agent gives you a link to play it on Sofala before anyone else can see it. Say what to change, as often as you like: “make the snakes faster”, “add a score board”.
  • Happy with it? Say “publish it”. A person at Sofala plays each new game before it goes up; you get an email when it is live.
  • To change a live game later, open PowerShell, start Claude Code again and ask. The new build replaces the old one at the same address.
  • On a Mac or on Linux, open Terminal instead of PowerShell and install with the line on Claude Code’s setup page; the other steps are the same. Using another agent? Add a remote MCP server with the address https://sofala.market/mcp.

For manual game devs

Building or packaging the game yourself? This is what Sofala expects. An AI agent follows the same rules; it reads them from Sofala.

ZIP

  • index.html 用來啟動遊戲。把它放在 ZIP 的最上層,或 ZIP 唯一的資料夾裡。
  • 遊戲載入的所有內容都在 ZIP 裡,用相對路徑連結:Build/game.wasm,絕不用 /Build/game.wasm,也不用你自己網站的完整網址。
  • 壓縮後最多 1 GB,10 000 個檔案,解壓縮後最多 2 GB。

引擎和檔案類型

  • 任何能在瀏覽器裡執行的遊戲都可以:HTML5 canvas、WebGL 和 WebGPU(three.js、Babylon.js、PixiJS、Phaser、PlayCanvas)、WebAssembly(Emscripten、Rust、Bevy、Go)、Godot 3 和 4、GameMaker、Construct、Defold、PICO-8、RPG Maker,以及透過 love.js 的 LÖVE。
  • Unity WebGL:任何壓縮方式都可以。Brotli 和 gzip 檔案會帶著正確的標頭傳送,所以不需要 decompression fallback。
  • JavaScript 模組、import map、.mjs 檔案、glTF 和 GLB 模型、KTX2 材質以及 WAV、OGG、Opus 和 MP3 聲音,都會以正確的類型傳送。

多執行緒遊戲

  • 使用執行緒(SharedArrayBuffer)的版本,例如開啟執行緒的 Godot 4、帶 -pthread 的 Emscripten,以及多執行緒的 Unity 或 love.js 版本,需要跨來源隔離的頁面。上傳 ZIP 時 Sofala 會辨識出來並以這種方式執行。只用 Brotli 壓縮的 Unity 版本,請在刊登裡勾選「需要 SharedArrayBuffer」。
  • 隔離執行的遊戲無法從其他網站載入腳本、圖片或聲音,除非對方傳送 CORS 或 Cross-Origin-Resource-Policy 標頭,所以請把所有內容放進 ZIP。不使用執行緒的遊戲可以從其他網站載入。

遊戲內部

  • 儲存在 localStorage 或 IndexedDB 裡的進度留在玩家的瀏覽器裡,每款遊戲分開儲存。
  • 遊戲可以使用全螢幕、滑鼠指標、手把、聲音和 WebXR。Sofala 的頁面上也有全螢幕按鈕。
  • 遊戲在自己的網址上、在沙盒框架裡執行:不能開啟彈出視窗、離開頁面,也看不到玩家的 Sofala 帳號。不要讓玩家在遊戲裡登入或付款;遊戲由 Sofala 銷售。
  • 多人遊戲不需要你自己的伺服器:Sofala 負責經營房間(見下方)。遊戲也可以和你自己的伺服器溝通。

手機與平板

  • 請在遊戲的某個元素上監聽觸控,例如它的 canvas,而不是 window 或 document:在框架內,iPhone 不一定會把觸控傳給 window。
  • 給這個元素設定 CSS touch-action: none,並在它的 touchstart 和 touchmove 監聽器中呼叫 preventDefault(),這些監聽器要用 { passive: false } 加入。否則手機會把滑動當成捲動頁面,幾個像素之後就不再通知你的遊戲。
  • 手機上也會收到 pointer 事件(pointerdown、pointermove)。遊戲可以同時監聽兩種,只要一根手指只算一次。
  • Snake Party 做到了這一切,它的滑動在 iPhone 上也能用;它的原始碼展示了做法。
  • 如果你的遊戲是用引擎做的,觸控輸入由引擎負責。不管用什麼做的,發佈前都請在手機上試一試。
const area = document.querySelector('canvas');   // an element of the game, not window
area.style.touchAction = 'none';
let from = null;
area.addEventListener('touchstart', e => {
  e.preventDefault();
  from = [e.touches[0].clientX, e.touches[0].clientY];
}, { passive: false });
area.addEventListener('touchmove', e => {
  e.preventDefault();
  if (!from) return;
  const x = e.touches[0].clientX, y = e.touches[0].clientY, dx = x - from[0], dy = y - from[1];
  if (Math.abs(dx) < 20 && Math.abs(dy) < 20) return;
  from = [x, y];
  swipe(Math.abs(dx) > Math.abs(dy) ? (dx > 0 ? 'right' : 'left') : (dy > 0 ? 'down' : 'up'));
}, { passive: false });

多人遊戲

  • Sofala 負責經營房間,所以你的遊戲不需要伺服器。把 sofala-game-1.1.js 放進 ZIP,和 index.html 放在一起,在你自己的指令碼之前載入,一行程式碼就能讓玩家和其他人進入同一個房間。
  • 一位玩家傳送的內容會依傳送順序到達房間裡的其他人。一個房間最多 32 位玩家,每人每秒可傳送 60 則訊息,每則最多 16 KB:適合回合制、派對和輕鬆的即時遊戲。快節奏的射擊遊戲仍然需要自己的伺服器。
  • Sofala 不執行你的任何程式碼。在房間裡待最久的玩家是房主:讓房主執行遊戲,並把變化告訴其他人。房主離開後,下一位玩家成為房主。
  • 快速遊戲會填滿公開房間。私人房間有一組代碼,朋友可以用它加入。
  • 遊戲透過一個在你的遊戲中始終不變的 id 和玩家名稱來辨識每位玩家,絕不會用電子郵件地址或帳號。玩家名稱就是他在 Sofala 上的名字,除非他在帳號頁面選了別的名字;你的遊戲也可以讓玩家在加入時輸入名字。沒有登入就玩免費遊戲的人是訪客。
  • 在你自己的電腦上也一樣:從 localhost 開啟遊戲,房間就是你專屬的測試空間。
  • 如果你確實有執行伺服器,Sofala.token() 會給它一個簽章過的 token,說明玩家是誰。請用 https://sofala.market/game-api/keys 上的公開金鑰驗證。
<script src="sofala-game-1.1.js"></script>
<script type="module">
  const room = await Sofala.rooms.quick({ max: 4 });   // a room with other players, or a new one

  room.on('message', (data, from) => { /* from.name did something */ });
  room.on('enter', peer => { });
  room.on('exit', peer => { });

  room.send({ move: 'e2e4' });                         // to everyone else in the room
</script>

房間能做的一切都列在 sofala-game-1.1.js 的開頭。一款可以照著學的完整遊戲,只有一個檔案:Snake Party(它的原始碼)。

銷售

  • 可以免費,也可以定一個含營業稅的價格,最低 €0.50。你透過 Stripe 收到不含營業稅的價格,扣除 Sofala 的 5% 佣金和 Stripe 的手續費:請先在「銷售」頁面設定收款。
  • 刊登的第一張封面照片就是遊戲在 play.sofala.market 上的圖塊;寬幅 16:9 的截圖效果最好。可在刊登編輯頁加入更多截圖和預覽影片。
  • 每款新遊戲上架前,Sofala 都會有人親自試玩;上架後你會收到電子郵件。
  • 要更新已上架的遊戲,請上傳新的 ZIP(代理:帶 replace 的 upload_files)。大約一分鐘後就會取代舊版本,不必重新審核,網址不變,玩家的存檔也會保留。

發佈你的遊戲