纯手写 Wolfenstein 风格光线投射小游戏:DDA 贴图墙、程序化素材、精灵遮挡、触摸摇杆
由 dsh-go 自动上传 · 2026/11/17 14:30:03
This commit is contained in:
1 parent
79ad1f38d7
commit
9a709f13d5
5 files changed
+13
-1
No files matched your search
@@ -251,6 +251,18 @@
|
||||
player.y = 1.5
|
||||
player.dirX = 1
|
||||
player.dirY = 0
|
||||
// 朝向最开阔的一个方向,开局就能看到走廊
|
||||
let best = { dx: 1, dy: 0, len: -1 }
|
||||
for (const [dx, dy] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) {
|
||||
let len = 0
|
||||
for (let k = 1; k <= 5; k++) {
|
||||
if (!open(Math.floor(player.x + dx * k), Math.floor(player.y + dy * k))) break
|
||||
len++
|
||||
}
|
||||
if (len > best.len) best = { dx, dy, len }
|
||||
}
|
||||
player.dirX = best.dx
|
||||
player.dirY = best.dy
|
||||
setFov(PLANE)
|
||||
|
||||
const dist = bfsFrom(1, 1)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 197 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 204 KiB After Width: | Height: | Size: 204 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 220 KiB After Width: | Height: | Size: 244 KiB |
@@ -53,7 +53,7 @@ html, body {
|
||||
}
|
||||
#overlay {
|
||||
position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
|
||||
background: radial-gradient(circle at 50% 40%, rgba(12, 34, 68, .82), rgba(3, 8, 15, .94));
|
||||
background: radial-gradient(circle at 50% 42%, rgba(10, 26, 52, .55), rgba(3, 8, 15, .88));
|
||||
backdrop-filter: blur(4px); z-index: 5;
|
||||
}
|
||||
#overlay[hidden] { display: none; }
|
||||
|
||||
Reference in new issue
Block a user