ENTRY
[ESC]1h ago•W:3528 words
( ͡~ ͜ʖ ͡°)
In CyberOS 4.4.1 you can now read the source code of other users levels (<> button in the top right)
Here's an epic one I made as a test.
You can now also change the global gravity of your level, and set a name.
SUPPORT CYBERSPACE IF YOU CAN!
// ETEMENANKI
// A processional plain walled by mountains. You wake inside a ring of standing stones;
// an avenue of obelisks runs north through a ruined hall of columns to a seven-stepped
// ziggurat. Its stairs wind round the tiers; from the summit a spiral of floating stones
// climbs to an orrery hung in the sky, and from the orrery a single beam descends 300 m
// north to a garden, a still pool and a monolith of proportions 1 : 4 : 9.
// Elsewhere: a labyrinth with gold at its deepest cell (west), a theatre whose audience
// is entirely rubber ducks (east), an aqueduct you can walk along if you find the way up,
// a bowling lane by the stones, and a few half-buried spheres nobody has explained.
level({
label: 'Etemenanki', // , or the Foundation of Heaven and Earth
fog: 0.0018,
gravity: 0.5,
skyGrid: true,
cameraFar: 2500,
respawnBelowY: -40,
ground: { spacing: 5, moireFade: true, fadeStart: 300, fadeEnd: 1400, visualExtent: 2000 },
physics: { walkSpeed: 10, runMultiplier: 2, jumpVelocity: 15, airControl: 0.6 }
})
spawn([0, 0, 0], { yaw: 0 })
const R = rng(1189)
const rand = (a, b) => a + R() * (b - a)
const pick = arr => arr[Math.floor(R() * arr.length)]
const TAU = Math.PI * 2
// a slab whose centreline runs from a to b; width is horizontal, t is thickness
function beam(a, b, width, t) {
const dx = b[0] - a[0], dy = b[1] - a[1], dz = b[2] - a[2]
const h = Math.hypot(dx, dz)
const L = Math.hypot(h, dy)
box([(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2], [L, t, width],
{ rotation: [0, Math.atan2(-dz, dx), Math.atan2(dy, h)] })
}
// places the scatter must avoid
const keepOut = []
const rectOut = (x0, x1, z0, z1) => keepOut.push((x, z) => x > x0 && x < x1 && z > z0 && z < z1)
const circOut = (cx, cz, r) => keepOut.push((x, z) => (x - cx) ** 2 + (z - cz) ** 2 < r * r)
const free = (x, z) => !keepOut.some(f => f(x, z))
// ---------------------------------------------------------------- ground and horizon
// one solid slab under the visual grid; tiled slabs leave internal edges the player catches on
invisible([0, -1, 0], [1800, 2, 1800])
const W = 880
invisible([W, 200, 0], [2, 400, 2 * W])
invisible([-W, 200, 0], [2, 400, 2 * W])
invisible([0, 200, W], [2 * W, 400, 2])
invisible([0, 200, -W], [2 * W, 400, 2])
for (let i = 0; i < 40; i++) {
const a = (i / 40) * TAU + rand(-0.05, 0.05)
const r = rand(840, 920)
const w = rand(150, 260), d = rand(150, 260), h = rand(70, 210)
pyramid([Math.sin(a) * r, h / 2, Math.cos(a) * r], [w, h, d],
{ top: R() < 0.3 ? rand(0.05, 0.2) : 0, rotation: rand(0, TAU) })
}
keepOut.push((x, z) => Math.hypot(x, z) > 760)
// ---------------------------------------------------------------- the stones (spawn)
const HZ = 300
const NS = 30
const up = []
for (let i = 0; i < NS; i++) {
const a = (i + 0.5) / NS * TAU
const gate = i === 14 || i === 15 // the north gap, onto the avenue
const standing = !gate && R() > 0.12
up.push(standing)
const x = Math.sin(a) * 20, z = HZ + Math.cos(a) * 20
if (standing) box([x, 2.75, z], [2, 5.5, 1.1], { rotation: a })
else if (!gate && R() < 0.7) box([x * 1.15, 0.55, HZ + (z - HZ) * 1.15], [5.5, 1.1, 2], { rotation: a + rand(-0.6, 0.6) })
}
for (let i = 0; i < NS; i++) {
const j = (i + 1) % NS
if (up[i] && up[j] && R() > 0.2) {
const a = (i + 1) / NS * TAU
box([Math.sin(a) * 20, 5.9, HZ + Math.cos(a) * 20], [4.6, 0.8, 1.1], { rotation: a })
}
}
// inner horseshoe of trilithons, open to the north
;[[-100, 6], [-50, 7], [0, 8.5], [50, 7], [100, 6]].forEach(([d, H]) => {
const a = deg(d), px = Math.sin(a) * 9, pz = HZ + Math.cos(a) * 9
const tx = Math.cos(a), tz = -Math.sin(a)
for (const s of [-1, 1]) box([px + s * 1.4 * tx, H / 2, pz + s * 1.4 * tz], [1.8, H, 1.4], { rotation: a })
box([px, H + 0.45, pz], [4.8, 0.9, 1.4], { rotation: a })
})
box([0, 0.25, HZ + 5], [4.8, 0.5, 1]) // altar stone
circOut(0, HZ, 30)
// ---------------------------------------------------------------- bowling, by the stones
const BX = -60
box([BX, 0.1, 290], [3, 0.2, 26])
box([BX - 2, 0.05, 290], [1, 0.1, 26])
box([BX + 2, 0.05, 290], [1, 0.1, 26])
box([BX, 1, 276], [7, 2, 0.6]) // backstop
box([BX - 3.5, 0.5, 300], [1, 1, 8]) // ball rack
for (let r = 0; r < 4; r++) for (let k = 0; k <= r; k++)
prop('apoc/Traffic Cone', [BX + (k - r / 2) * 0.9, 0.2, 281 - r * 0.8], { throwable: true, mass: 1.5 })
for (let i = 0; i < 6; i++)
prop('household/Pumpkin', [BX - 3.5, 1, 297 + i * 1.2], { rotation: rand(0, TAU), throwable: true, mass: 5 })
rectOut(-70, -50, 270, 310)
// ---------------------------------------------------------------- the avenue
box([0, 0.15, 21.5], [10, 0.3, 517]) // causeway, z -237 .. 280
rectOut(-22, 22, -260, 285)
function obelisk(x, z, h, fallen) {
box([x, 0.5, z], [2.4, 1, 2.4])
if (!fallen) {
box([x, 1 + h / 2, z], [1.2, h, 1.2])
pyramid([x, 1 + h + 0.9, z], [1.2, 1.8, 1.2])
return
}
const s = Math.sign(x), b = rand(-0.4, 0.4)
const ux = s * Math.cos(b), uz = -s * Math.sin(b)
box([x + ux * (h / 2 + 1.6), 0.6, z + uz * (h / 2 + 1.6)], [h, 1.2, 1.2], { rotation: b })
pyramid([x + ux * (h + 2.6), 0.6, z + uz * (h + 2.6)], [1.2, 1.8, 1.2], { rotation: [0, b, -s * Math.PI / 2] })
}
const oz = []
for (let j = 0; j <= 10; j++) oz.push(255 - 18 * j)
for (let j = 0; j <= 9; j++) oz.push(-55 - 18 * j)
for (const z of oz) for (const x of [-11, 11]) obelisk(x, z, rand(10, 16), R() < 0.12)
// ---------------------------------------------------------------- hypostyle hall
const colX = [-24, -16, -8, 8, 16, 24]
const rows = [55, 45, 35, 25, 15, 5, -5, -15, -25, -35]
for (const z of rows) for (const x of colX) {
if (z !== 15 && z !== 5) {
cylinder([x, 6, z], [1.2, 12])
box([x, 12.4, z], [3, 0.8, 3])
} else if (R() < 0.7) {
const h = rand(1.5, 9)
cylinder([x, h / 2, z], [1.2, h])
} else {
const L = rand(4, 6)
cylinder([x, 1.2, z + rand(-2, 2)], [1.2, L], { rotation: [Math.PI / 2, 0, 0] }) // a drum on its side
}
}
for (const zc of [50, 30, -10, -30]) box([0, 13.3, zc], [56, 1, 20]) // the roof, fallen in at z 0..20
beam([12, 0, 1], [12, 13.55, 20.5], 5, 0.6) // two roof slabs leaning in the breach: the ways up
beam([-12, 0, 19], [-12, 13.55, -0.5], 5, 0.6)
prop('dungeon/Chest', [-14, 13.8, -28], { rotation: deg(90) })
prop('dungeon/Skull', [-12, 13.8, -27], { rotation: deg(200), throwable: true, mass: 1 })
rectOut(-36, 36, -48, 68)
// ---------------------------------------------------------------- the ziggurat
const ZC = -330
const S = [75, 65, 55, 45, 35, 25, 15]
const TH = 7
S.forEach((s, k) => box([0, TH * k + TH / 2, ZC], [2 * s, TH, 2 * s]))
// the great stair, south face
for (let i = 1; i <= 20; i++) {
const zb = ZC + S[0], zf = zb + 0.9 * (21 - i)
box([0, 0.175 * i, (zf + zb) / 2], [20, 0.35 * i, zf - zb])
}
for (const x of [-14, 14]) prop('dungeon/Horse Statue', [x, 0, -232], { rotation: 0 })
// one flight per terrace, each a face further round: E, N, W, S, E, N
const faces = [[1, 0], [0, -1], [-1, 0], [0, 1]]
for (let k = 0; k < 6; k++) {
const [nx, nz] = faces[k % 4]
const y0 = TH * (k + 1), wall = S[k + 1]
for (let i = 1; i <= 14; i++) {
const depth = 0.7 * (15 - i), c = wall + depth / 2, h = 0.5 * i
box([nx * c, y0 + h / 2, ZC + nz * c], nx !== 0 ? [depth, h, 8] : [8, h, depth])
}
}
// the summit: four posts, an axis to the sky, and an offering
const TOP = TH * 7
for (const x of [-11, 11]) for (const z of [-11, 11]) cylinder([x, TOP + 3, ZC + z], [0.8, 6])
cylinder([0, TOP + 25, ZC], [2.5, 50])
prop('dino/Vending Machine', [0, TOP, ZC - 6], { rotation: Math.PI, solid: true })
box([6, TOP + 0.6, ZC], [1.2, 1.2, 1.2])
prop('misc/crystal', [6, TOP + 1.2, ZC], { rotation: deg(30) })
rectOut(-85, 85, -415, -228)
// ---------------------------------------------------------------- spiral of floating stones
const SR = 19
const DA = 2 * Math.asin(5.5 / (2 * SR))
const A0 = deg(61.6)
const NP = 50
for (let n = 1; n <= NP; n++) {
const a = A0 + (n - 1) * DA
const s = n % 12 === 0 ? 5 : 3.5
box([Math.sin(a) * SR, TOP + n - 0.3, ZC + Math.cos(a) * SR], [s, 0.6, s], { rotation: a })
}
// ---------------------------------------------------------------- the orrery, 100 m up
const OY = TOP + NP + 1
cylinder([0, OY - 0.5, ZC], [16, 1])
cylinder([0, OY + 2, ZC], [0.5, 4])
sphere([0, OY + 7, ZC], 3)
const orbits = [4.5, 6.5, 8.5, 10.5, 12.5, 14.5]
const planetR = [0.4, 0.6, 0.7, 0.5, 1.5, 1.2]
orbits.forEach((r, j) => {
cylinder([0, OY + 0.02, ZC], [r, 0.04])
const a = deg(rand(210, 500)) // keep clear of the arrival and the beam
const px = Math.sin(a) * r, pz = ZC + Math.cos(a) * r
const ph = rand(2, 5.5), pr = planetR[j]
cylinder([px, OY + ph / 2, pz], [0.08, ph])
sphere([px, OY + ph + pr, pz], pr)
if (j === 5) cylinder([px, OY + ph + pr, pz], [pr * 2, 0.04], { rotation: [deg(22), 0, deg(12)] })
})
prop('household/Telescope', [Math.sin(deg(250)) * 13, OY, ZC + Math.cos(deg(250)) * 13], { rotation: deg(250) })
prop('household/Globe', [Math.sin(deg(280)) * 11, OY, ZC + Math.cos(deg(280)) * 11], { rotation: deg(10) })
const gems = ['dino/Gem Blue', 'dino/Gem Green', 'dino/Gem Pink']
for (let i = 0; i < 9; i++) {
const a = i / 9 * TAU
prop(gems[i % 3], [Math.sin(a) * 2.2, OY + 0.04, ZC + Math.cos(a) * 2.2], { rotation: a, throwable: true, mass: 0.4 })
}
// ---------------------------------------------------------------- the ladder down
const RUN = 306
beam([0, OY - 0.25, ZC - 14], [0, -0.25, ZC - 14 - RUN], 3, 0.5)
const fall = OY / RUN
for (let d = 80; d <= 280; d += 40) {
const h = OY - 0.25 - d * fall - 0.32
cylinder([0, h / 2, ZC - 14 - d], [0.45, h])
}
rectOut(-8, 8, -665, -400)
// ---------------------------------------------------------------- the garden at the end
const GZ = -720
cylinder([0, 0.02, GZ], [20, 0.04]) // still water
box([0, 9, GZ], [8, 18, 2]) // 1 : 4 : 9
prop('household/Rubber Duck', [0, 0.04, GZ + 2.5], { rotation: Math.PI, throwable: true, mass: 0.4 })
for (let i = 0; i < 12; i++) {
const a = (i + 0.5) / 12 * TAU, h = rand(2.2, 4)
box([Math.sin(a) * 34, h / 2, GZ + Math.cos(a) * 34], [1.6, h, 1], { rotation: a })
}
const twisted = ['nature/Twisted Tree', 'nature/Twisted Tree-7PDBpElkQr', 'nature/Twisted Tree-8oraKn9m0x', 'nature/Twisted Tree-9aWlx82xUf', 'nature/Twisted Tree-GVTsMmuzv7']
const blooms = ['nature/Flower Group', 'nature/Flower Group-LqTljN6Wg2', 'nature/Flower Single', 'nature/Fern']
const shrooms = ['nature/Mushroom', 'nature/Mushroom Laetiporus']
function garden(names, count, rMin, rMax, opts) {
let placed = 0, tries = 0
while (placed < count && tries++ < count * 40) {
const a = rand(0, TAU), r = rand(rMin, rMax)
const x = Math.sin(a) * r, z = GZ + Math.cos(a) * r
if (Math.abs(x) < 6 && z > GZ) continue
if (Math.abs(r - 34) < 2) continue
prop(pick(names), [x, 0, z], Object.assign({ rotation: rand(0, TAU) }, opts || {}))
placed++
}
}
garden(twisted, 18, 42, 110, { solid: true })
garden(blooms, 22, 22, 70)
garden(shrooms, 10, 24, 90)
garden(['nature/Grass Wispy', 'nature/Tall Grass'], 14, 22, 100)
circOut(0, GZ, 115)
// ---------------------------------------------------------------- the labyrinth (west)
const MX = 14, MZ = 14, CS = 6, mx0 = -302, mz0 = -110, DOOR = 8
const vW = [], hW = [], seen = []
for (let i = 0; i <= MX; i++) vW.push(new Array(MZ).fill(true))
for (let i = 0; i < MX; i++) hW.push(new Array(MZ + 1).fill(true))
for (let i = 0; i < MX; i++) seen.push(new Array(MZ).fill(false))
const start = [MX - 1, DOOR]
const stack = [start]
seen[start[0]][start[1]] = true
while (stack.length) {
const [ci, cj] = stack[stack.length - 1]
const nb = []
if (ci > 0 && !seen[ci - 1][cj]) nb.push([ci - 1, cj, 'W'])
if (ci < MX - 1 && !seen[ci + 1][cj]) nb.push([ci + 1, cj, 'E'])
if (cj > 0 && !seen[ci][cj - 1]) nb.push([ci, cj - 1, 'N'])
if (cj < MZ - 1 && !seen[ci][cj + 1]) nb.push([ci, cj + 1, 'S'])
if (!nb.length) { stack.pop(); continue }
const [ni, nj, dir] = nb[Math.floor(R() * nb.length)]
if (dir === 'W') vW[ci][cj] = false
if (dir === 'E') vW[ci + 1][cj] = false
if (dir === 'N') hW[ci][cj] = false
if (dir === 'S') hW[ci][cj + 1] = false
seen[ni][nj] = true
stack.push([ni, nj])
}
vW[MX][DOOR] = false
// how deep is each cell, counted from the door
const depth = seen.map(col => col.map(() => -1))
const queue = [start]
depth[start[0]][start[1]] = 0
let far = start
while (queue.length) {
const [i, j] = queue.shift()
if (depth[i][j] > depth[far[0]][far[1]]) far = [i, j]
const d = depth[i][j] + 1
const go = (a, b) => { if (depth[a][b] < 0) { depth[a][b] = d; queue.push([a, b]) } }
if (i > 0 && !vW[i][j]) go(i - 1, j)
if (i < MX - 1 && !vW[i + 1][j]) go(i + 1, j)
if (j > 0 && !hW[i][j]) go(i, j - 1)
if (j < MZ - 1 && !hW[i][j + 1]) go(i, j + 1)
}
const WT = 0.6, WH = 4
for (let i = 0; i <= MX; i++) {
let j = 0
while (j < MZ) {
if (!vW[i][j]) { j++; continue }
let k = j
while (k < MZ && vW[i][k]) k++
const z0 = mz0 + j * CS, z1 = mz0 + k * CS
box([mx0 + i * CS, WH / 2, (z0 + z1) / 2], [WT, WH, z1 - z0 + WT])
j = k
}
}
for (let j = 0; j <= MZ; j++) {
let i = 0
while (i < MX) {
if (!hW[i][j]) { i++; continue }
let k = i
while (k < MX && hW[k][j]) k++
const x0 = mx0 + i * CS, x1 = mx0 + k * CS
box([(x0 + x1) / 2, WH / 2, mz0 + j * CS], [x1 - x0 + WT, WH, WT])
i = k
}
}
const cell = (i, j) => [mx0 + i * CS + CS / 2, mz0 + j * CS + CS / 2]
// the heart
const [gx, gz] = cell(far[0], far[1])
prop('dungeon/Chest with Gold', [gx, 0, gz], { rotation: rand(0, TAU), solid: true })
prop('dungeon/Coin Piles', [gx + 1.6, 0, gz + 1.2], { rotation: rand(0, TAU) })
prop('dungeon/Coin Piles', [gx - 1.5, 0, gz - 1.4], { rotation: rand(0, TAU) })
prop('dungeon/Torch', [gx + 2.2, 0, gz - 2.2])
prop('dungeon/Torch', [gx - 2.2, 0, gz + 2.2])
// dead ends get bones, webs and the odd barrel
let skulls = 0, webs = 0, barrels = 0
for (let i = 0; i < MX; i++) for (let j = 0; j < MZ; j++) {
if ((i === far[0] && j === far[1]) || (i === start[0] && j === start[1])) continue
const walls = vW[i][j] + vW[i + 1][j] + hW[i][j] + hW[i][j + 1]
if (walls < 3) continue
const [cx, cz] = cell(i, j)
const roll = R()
if (roll < 0.3 && skulls < 8) { prop('dungeon/Skull', [cx, 0, cz], { rotation: rand(0, TAU), throwable: true, mass: 1 }); skulls++ }
else if (roll < 0.5 && webs < 6) { prop('dungeon/Cobweb', [cx, 0, cz], { rotation: rand(0, TAU) }); webs++ }
else if (roll < 0.6 && barrels < 3) { prop('dungeon/Barrel', [cx, 0, cz], { rotation: rand(0, TAU), solid: true }); barrels++ }
}
const doorZ = mz0 + DOOR * CS + CS / 2
prop('dungeon/Torch', [mx0 + MX * CS + 1.5, 0, doorZ - 3.6])
prop('dungeon/Torch', [mx0 + MX * CS + 1.5, 0, doorZ + 3.6])
const mazeEdge = mx0 + MX * CS
box([(mazeEdge - 5) / 2, 0.05, doorZ], [-5 - mazeEdge, 0.1, 3]) // the road from the avenue
log('The labyrinth is ' + depth[far[0]][far[1]] + ' cells deep.')
rectOut(-312, -208, -120, -16)
rectOut(-220, -4, doorZ - 5, doorZ + 5)
// ---------------------------------------------------------------- the theatre (east)
const AX = 230, AZ = 40
for (let i = 0; i < 10; i++) {
const r0 = 14 + 1.25 * i, rc = r0 + 0.625, h = 0.5 * (i + 1)
const n = 18, a0 = deg(-10), span = deg(200)
const chord = 2 * (r0 + 1.25) * Math.sin(span / n / 2) + 0.15
for (let k = 0; k < n; k++) {
const a = a0 + (k + 0.5) * span / n
box([AX + Math.sin(a) * rc, h / 2, AZ + Math.cos(a) * rc], [chord, h, 1.25], { rotation: a })
}
}
cylinder([AX, 0.05, AZ], [12, 0.1]) // orchestra
box([AX - 15, 0.6, AZ], [5, 1.2, 26]) // stage
box([AX - 12, 0.4, AZ], [1, 0.8, 6])
box([AX - 11, 0.2, AZ], [1, 0.4, 6])
const sx = AX - 18
for (const [a, b] of [[-15, -9.5], [-6.5, -1.5], [1.5, 6.5], [9.5, 15]]) box([sx, 4.5, AZ + (a + b) / 2], [1, 9, b - a])
for (const c of [-8, 0, 8]) box([sx, 7, AZ + c], [1, 4, 3])
prop('household/Rocking Chair', [AX - 15, 1.2, AZ], { rotation: deg(90) })
// a full house
for (let i = 0; i < 40; i++) {
const t = Math.floor(R() * 10)
const a = deg(rand(-4, 184))
const r = 14 + 1.25 * t + 0.45
prop('household/Rubber Duck', [AX + Math.sin(a) * r, 0.5 * (t + 1), AZ + Math.cos(a) * r], { rotation: a + Math.PI, throwable: true, mass: 0.4 })
}
circOut(AX, AZ, 34)
rectOut(AX - 22, AX, AZ - 17, AZ + 17)
// ---------------------------------------------------------------- the aqueduct
const QZ = 160, QY = 16
for (let x = -414; x <= 414; x += 12) {
if (x > 120 && x < 156) continue
box([x, (QY - 2) / 2, QZ], [2, QY - 2, 3])
}
;[[126, 0.6], [138, 5.5], [150, 9.5]].forEach(([x, h]) => box([x, h / 2, QZ], [2, h, 3])) // stumps in the breach
function deck(x0, x1) {
const cx = (x0 + x1) / 2, L = x1 - x0
box([cx, QY - 1, QZ], [L, 2, 4])
box([cx, QY + 0.4, QZ - 1.85], [L, 0.8, 0.3])
box([cx, QY + 0.4, QZ + 1.85], [L, 0.8, 0.3])
}
deck(-420, 120)
deck(156, 420)
wedge([-434, QY / 2, QZ], [28, QY, 4])
wedge([434, QY / 2, QZ], [28, QY, 4], { rotation: Math.PI })
beam([122, 0, QZ], [157, QY - 0.3, QZ], 3.4, 0.6) // a fallen span, leaning into the breach
rectOut(-460, 460, 152, 168)
// ---------------------------------------------------------------- the seeds
// const domes = [
// [330, 360, 22, 0.8], [470, 250, 14, 0.4], [190, 470, 16, 0.6], [560, 520, 26, 0.85],
// [-320, 400, 20, 0.8], [-480, 260, 12, 0.35], [-560, 560, 24, 0.7],
// [420, -300, 18, 0.75], [-460, -380, 16, 0.5], [520, -560, 22, 0.8]
// ]
// for (const [x, z, r, sink] of domes) { sphere([x, -r * sink, z], r); circOut(x, z, r + 4) }
// ---------------------------------------------------------------- what grows on the plain
function scatter(names, count, opts) {
let placed = 0, tries = 0
while (placed < count && tries++ < count * 60) {
const x = rand(-760, 760), z = rand(-760, 760)
if (!free(x, z)) continue
prop(pick(names), [x, 0, z], Object.assign({ rotation: rand(0, TAU) }, opts || {}))
placed++
}
}
scatter(['nature/Dead Tree', 'nature/Dead Tree-CD4edbPSGm', 'nature/Dead Tree-Mcd2zYqyww', 'nature/Dead Tree-MlmK5488ou', 'nature/Dead Tree-n8FhMgMldD'], 40, { solid: true })
scatter(['nature2/Rock_1', 'nature2/Rock_2', 'nature2/Rock_3', 'nature2/Rock_4', 'nature2/Rock_5'], 40, { solid: true })
scatter(['nature/Tall Grass', 'nature/Grass Wispy', 'nature/Bush', 'nature/Grass'], 40)
0 replies
Join the conversation