feat: CS 枪火对决 —— Rust 权威服务端 + 手写 WebGL 前端的第一人称 1v1 对枪
- 服务端 60Hz 固定步长模拟:重力/摩擦/轴分离碰撞/上台阶,客户端预测回滚 - 命中裁决:射线打墙打人(身体 + 头部盒),射速/弹匣/换弹/伤害/比分全在服务端 - 回合制:3 秒准备、先到 8 分、100 秒平局;观战自由视角 - 机器人陪练:视线检测 + 反应延迟 + 点射偏差,能单人开练 - 前端零依赖:手写 WebGL(程序化贴图、地图合批、粒子、曳光弹、假投影、黄昏天空) - 2D Canvas 枪模 + WebAudio 合成音效,无任何图片/音频/CDN 资源 - 地图 level.json 前后端同源,tools/gen_level.py 四分镜像生成,绝对对称 - 测试:14 组规则单测 + 6 组联机 e2e
This commit is contained in:
commit
00d63ba736
32 files changed
+8599
No files matched your search
@@ -0,0 +1,59 @@
|
||||
// 本地验证:用系统 Chrome 无头打开页面,截图 + 打印控制台错误 + 游戏状态
|
||||
const puppeteer = require("puppeteer-core");
|
||||
|
||||
(async () => {
|
||||
const url = process.argv[2] || "http://localhost:3210/";
|
||||
const out = process.argv[3] || "/tmp/cs-shot.png";
|
||||
const wait = Number(process.argv[4] || 6000);
|
||||
const browser = await puppeteer.launch({
|
||||
executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||
headless: "new",
|
||||
args: [
|
||||
"--no-sandbox",
|
||||
"--enable-unsafe-swiftshader",
|
||||
"--use-gl=angle",
|
||||
"--use-angle=swiftshader",
|
||||
"--disable-dev-shm-usage",
|
||||
"--window-size=1280,760",
|
||||
],
|
||||
defaultViewport: { width: 1280, height: 720 },
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
const logs = [];
|
||||
page.on("console", (m) => logs.push(`[${m.type()}] ${m.text()}`));
|
||||
page.on("pageerror", (e) => logs.push(`[pageerror] ${e.message}`));
|
||||
page.on("requestfailed", (r) => logs.push(`[reqfail] ${r.url()} ${r.failure() && r.failure().errorText}`));
|
||||
await page.goto(url, { waitUntil: "networkidle2" });
|
||||
await new Promise((r) => setTimeout(r, wait));
|
||||
await page.screenshot({ path: out });
|
||||
const info = await page.evaluate(() => {
|
||||
const S = window.__CS;
|
||||
if (!S) return { ok: false, why: "no __CS" };
|
||||
const r = {
|
||||
scene: S.scene,
|
||||
phase: S.phase,
|
||||
you: S.you,
|
||||
code: S.code,
|
||||
spectating: S.spectating,
|
||||
players: S.players.map((p) => ({
|
||||
slot: p.slot,
|
||||
name: p.name,
|
||||
hp: p.hp,
|
||||
alive: p.alive,
|
||||
pos: p.pos.map((v) => +v.toFixed(2)),
|
||||
})),
|
||||
score: S.score,
|
||||
hp: S.hp,
|
||||
mag: S.mag,
|
||||
alive: S.alive,
|
||||
fps: S.fps,
|
||||
pos: S.body ? S.body.pos : null,
|
||||
particles: S.particles.length,
|
||||
canvas: [document.getElementById("gl").width, document.getElementById("gl").height],
|
||||
};
|
||||
return r;
|
||||
});
|
||||
console.log(JSON.stringify(info, null, 2));
|
||||
if (logs.length) console.log("--- console ---\n" + logs.join("\n"));
|
||||
await browser.close();
|
||||
})();
|
||||
Reference in new issue
Block a user