اصنع لعبة متصفح لـ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.
مع وكيل الذكاء الاصطناعي
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.
- 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.
- Open PowerShellPowerShell is a window where you type commands. Press the Windows key, type
powershelland press Enter. A window opens with a line that starts withPS C:\Users\and your name. That is where the next lines go. - 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. - Check that it worksIn the new PowerShell window, this prints a version number:
claude --version
Does it say thatclaudeis 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. - 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
- 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
- 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
- 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
- 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 ومربوط بمسارات نسبية: 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 وLÖVE عبر love.js.
- Unity WebGL: يعمل أي ضغط. تُرسَل ملفات Brotli وgzip بالترويسات الصحيحة، فلا تحتاج إلى decompression fallback.
- تُرسَل وحدات JavaScript وimport maps وملفات .mjs ونماذج glTF وGLB وخامات KTX2 وأصوات WAV وOGG وOpus وMP3 كلها بنوعها الصحيح.
الألعاب متعددة الخيوط
- الإصدارات التي تستخدم الخيوط (SharedArrayBuffer)، مثل Godot 4 مع تفعيل الخيوط وEmscripten مع -pthread وإصدارات Unity أو love.js متعددة الخيوط، تحتاج إلى صفحة معزولة عبر المصادر. تتعرّف Sofala عليها حين ترفع ملف ZIP وتشغّلها بهذه الطريقة. لإصدار Unity مضغوط بـBrotli فقط، ضع علامة على «يحتاج إلى SharedArrayBuffer» في الإعلان.
- لا تستطيع اللعبة المعزولة تحميل نصوص برمجية أو صور أو أصوات من مواقع أخرى ما لم ترسل تلك المواقع ترويسات CORS أو Cross-Origin-Resource-Policy، لذا ضع كل شيء في ملف ZIP. يمكن للألعاب التي لا تستخدم الخيوط التحميل من مواقع أخرى.
داخل اللعبة
- تبقى عمليات الحفظ في localStorage أو IndexedDB في متصفح اللاعب، منفصلة لكل لعبة.
- يمكن للعبة استخدام ملء الشاشة ومؤشر الفأرة وأذرع التحكم والصوت وWebXR. وفي صفحة Sofala زر لملء الشاشة أيضًا.
- تعمل اللعبة في إطار معزول على عنوانها الخاص: لا تستطيع فتح نوافذ منبثقة أو مغادرة الصفحة أو رؤية حساب اللاعب على Sofala. لا تطلب من اللاعبين تسجيل الدخول أو الدفع داخل اللعبة؛ فـSofala هي التي تبيعها.
- لا يحتاج اللعب الجماعي إلى خادم خاص بك: تدير Sofala الغرف (أدناه). ويمكن للعبة أيضًا أن تتواصل مع خادم خاص بك.
هواتف وأجهزة لوحية
- استمع إلى اللمسات على عنصر من لعبتك، مثل canvas الخاص بها، لا على window أو document: داخل الإطار لا يمرّر iPhone اللمسات إلى window دائمًا.
- أعطِ ذلك العنصر قاعدة CSS touch-action: none، واستدعِ preventDefault() في مستمعي touchstart وtouchmove الخاصين به، المضافين مع { passive: false }. وإلا يظن الهاتف أن السحب تمرير للصفحة ويتوقف عن إبلاغ لعبتك به بعد بضع بكسلات.
- أحداث المؤشر (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 كيلوبايت: مناسب لألعاب الأدوار والحفلات والألعاب الهادئة في الوقت الفعلي. أما ألعاب التصويب السريعة فما زالت تحتاج إلى خادم خاص.
- لا تشغّل Sofala أيًّا من شيفرتك. اللاعب الأقدم في الغرفة هو المضيف: دعه يدير اللعبة ويخبر الآخرين بما تغيّر. وحين يغادر المضيف، يصبح اللاعب التالي مضيفًا.
- اللعب السريع يملأ الغرف العامة. وللغرفة الخاصة رمز ينضم به الأصدقاء.
- تعرف اللعبة كل لاعب بمعرّف يبقى ثابتًا في لعبتك وباسم اللاعب، ولا تعرفه أبدًا ببريد إلكتروني أو حساب. اسم اللاعب هو اسمه على Sofala، ما لم يختر اسمًا آخر في صفحة حسابه؛ ويمكن للعبتك أيضًا أن تتيح له كتابة اسم عند الانضمام. ومن يلعب لعبة مجانية دون تسجيل الدخول فهو ضيف.
- على حاسوبك يعمل الأمر بالطريقة نفسها: افتح اللعبة من localhost فتصبح الغرف مساحة اختبار خاصة بك.
- وإن كنت تشغّل خادمًا رغم ذلك، فإن Sofala.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 €. تحصل على السعر دون الضريبة، مخصومًا منه رسم Sofala البالغ 5% ورسم Stripe، عبر Stripe: اضبط استلام الأموال أولًا في صفحة المبيعات.
- صورة الغلاف الأولى للإعلان هي بطاقة اللعبة على play.sofala.market؛ وأفضلها لقطة شاشة عريضة بنسبة 16:9. أضف مزيدًا من اللقطات وفيديو معاينة في صفحة تعديل الإعلان.
- يلعب شخص من Sofala كل لعبة جديدة قبل نشرها؛ وتصلك رسالة بريد إلكتروني حين تصبح متاحة.
- لتحديث لعبة منشورة، ارفع ملف ZIP الجديد (وكيلك: upload_files مع replace). يحل محل القديم خلال دقيقة تقريبًا، دون فحص جديد وعلى العنوان نفسه، فيحتفظ اللاعبون بتقدّمهم المحفوظ.