soul-symphony-ling
↓ 0 downloadsSoul Symphony — Ling Edition. A spiritual 3D adventure in the soul realm: collect the letters of the world-song, clear the monster lattice, and duel in the arcade arena. Wind Waker-style toon renderer with volumetric light pools, SSAO, bloom and oil-slick tilt-shift — all ling-lang vectors.
Keywords game, 3d, toon, music, soul-symphony
lingfu install soul-symphony-lingCode / Files (1947)
game/grid.ling
# ════════════════════════════════════════════════════════════════════════════
# grid.ling — ตัวสร้างเลเวลแบบกริด (low-poly, สไตล์ต่อบล็อก/RCT)
# สนามเป็นกริดเซลล์; แต่ละเซลล์เป็น "แพลตฟอร์ม" (เรียบที่ระดับ L) หรือ "ทางลาด"
# (ลาดจากระดับ L → L+1 ไปทางเพื่อนบ้านที่สูงกว่า) → ทางลาดเชื่อมแพลตฟอร์มต่อกัน
# ขึ้นได้หลายชั้น (0→1→2→3) แบบเชื่อมต่อ. เดต. ต่อ seed (ไม่ต้องเก็บสถานะ).
# ใช้ ARENA_FLOOR จาก arena.ling (+y ลง → ระดับสูง = y น้อย)
# ════════════════════════════════════════════════════════════════════════════
bind GRID_S = 16.0 # ขนาดเซลล์ (หน่วยโลก)
bind GRID_H = 7.0 # ความสูงต่อระดับ
bind GRID_MAXL = 3.0 # ระดับสูงสุด
bind GRID_VIEW = 8 # รัศมีวาด (เซลล์รอบผู้เล่น)
# ระดับเทอเรซของเซลล์ (สนามเรียบ → ต่างกัน 0/1 เป็นส่วนใหญ่)
ฟังก์ชัน กริดเลเวล(c, r, seed) {
bind hf = ไซน์(c*0.45 + seed) * 1.25 + ไซน์(r*0.40 + seed*1.7) * 1.25 + ไซน์((c+r)*0.25 + seed*0.5) * 0.8
bind L = ปัดลง(hf*0.6 + 2.0)
ถ้า L < 0.0 { bind L = 0.0 }
ถ้า L > GRID_MAXL { bind L = GRID_MAXL }
คืน L
}
# เซลล์ → [type, level, dir] type: 0=แพลตฟอร์ม 1=ทางลาด; dir: 0=ตอ.(+x) 1=ตต. 2=ใต้(+z) 3=เหนือ
# ทางลาดเกิดเมื่อเพื่อนบ้านสูงกว่า 1 ระดับ → ลาดขึ้นไปทางนั้น (ขอบสูง = L+1 เชื่อมแพลตฟอร์มนั้น)
ฟังก์ชัน กริดเซลล์(c, r, seed) {
bind L = กริดเลเวล(c, r, seed)
bind dir = 0.0 - 1.0
ถ้า กริดเลเวล(c+1, r, seed) == L + 1.0 { bind dir = 0.0 }
มิฉะนั้น { ถ้า กริดเลเวล(c-1, r, seed) == L + 1.0 { bind dir = 1.0 }
มิฉะนั้น { ถ้า กริดเลเวล(c, r+1, seed) == L + 1.0 { bind dir = 2.0 }
มิฉะนั้น { ถ้า กริดเลเวล(c, r-1, seed) == L + 1.0 { bind dir = 3.0 } } } }
ถ้า dir < 0.0 { คืน [0.0, L, 0.0] }
คืน [1.0, L, dir]
}
ฟังก์ชัน กริดY(L) { คืน ARENA_FLOOR - L * GRID_H } # พื้นผิว y ของระดับ L (+y ลง)
# ความสูงพื้นผิวเดินได้ที่ (x,z) — interp ทางลาดในเซลล์
ฟังก์ชัน ความสูงกริด(x, z, seed) {
bind c = ปัดลง(x / GRID_S); bind r = ปัดลง(z / GRID_S)
bind fx = x/GRID_S - c; bind fz = z/GRID_S - r
bind cell = กริดเซลล์(c, r, seed)
bind typ = list_get(cell,0); bind L = list_get(cell,1); bind dir = list_get(cell,2)
bind h = L
ถ้า typ == 1.0 {
ถ้า dir == 0.0 { bind h = L + fx }
ถ้า dir == 1.0 { bind h = L + (1.0 - fx) }
ถ้า dir == 2.0 { bind h = L + fz }
ถ้า dir == 3.0 { bind h = L + (1.0 - fz) }
}
คืน กริดY(h)
}
ฟังก์ชัน สีเลเวล(L, k) {
bind h = L * 1.15 + 0.6 + k
คืน [floor((ไซน์(h)*0.5+0.5)*120+45), floor((ไซน์(h+2.094)*0.5+0.5)*120+45), floor((ไซน์(h+4.189)*0.5+0.5)*120+45)]
}
# ── วาดกริด: หน้าบน (2 ต.) + ผนังขั้น (เฉพาะขอบที่เพื่อนบ้านต่ำกว่า) รอบผู้เล่น ──
ฟังก์ชัน วาดกริด(cx, cz, seed, t) {
bind pc = ปัดลง(cx / GRID_S); bind pr = ปัดลง(cz / GRID_S)
bind i = 0 - GRID_VIEW
ขณะที่ i <= GRID_VIEW {
bind j = 0 - GRID_VIEW
ขณะที่ j <= GRID_VIEW {
bind c = pc + i; bind r = pr + j
bind cell = กริดเซลล์(c, r, seed)
bind typ = list_get(cell,0); bind L = list_get(cell,1); bind dir = list_get(cell,2)
bind l00 = L; bind l10 = L; bind l11 = L; bind l01 = L
ถ้า typ == 1.0 {
ถ้า dir == 0.0 { bind l10 = L+1.0; bind l11 = L+1.0 }
ถ้า dir == 1.0 { bind l00 = L+1.0; bind l01 = L+1.0 }
ถ้า dir == 2.0 { bind l11 = L+1.0; bind l01 = L+1.0 }
ถ้า dir == 3.0 { bind l00 = L+1.0; bind l10 = L+1.0 }
}
bind x0 = c*GRID_S; bind x1 = x0+GRID_S; bind z0 = r*GRID_S; bind z1 = z0+GRID_S
bind y00 = กริดY(l00); bind y10 = กริดY(l10); bind y11 = กริดY(l11); bind y01 = กริดY(l01)
# หน้าบน (1 quad แทน 2 triangles)
bind ct = สีเลเวล(L, 0.0)
สีดินสอ(list_get(ct,0), list_get(ct,1), list_get(ct,2))
draw_quad_3d(x0,y00,z0, x1,y10,z0, x1,y11,z1, x0,y01,z1)
# ผนังขั้น (สีเข้มกว่า) เฉพาะขอบที่เพื่อนบ้านระดับต่ำกว่า (1 quad ต่อขอบ)
bind cw = สีเลเวล(L, 0.0 - 0.4)
สีดินสอ(list_get(cw,0), list_get(cw,1), list_get(cw,2))
bind NLe = กริดเลเวล(c+1, r, seed)
ถ้า NLe < L { bind yb = กริดY(NLe); draw_quad_3d(x1,y10,z0, x1,y11,z1, x1,yb,z1, x1,yb,z0) }
bind NLw = กริดเลเวล(c-1, r, seed)
ถ้า NLw < L { bind yb = กริดY(NLw); draw_quad_3d(x0,y00,z0, x0,y01,z1, x0,yb,z1, x0,yb,z0) }
bind NLs = กริดเลเวล(c, r+1, seed)
ถ้า NLs < L { bind yb = กริดY(NLs); draw_quad_3d(x0,y01,z1, x1,y11,z1, x1,yb,z1, x0,yb,z1) }
bind NLn = กริดเลเวล(c, r-1, seed)
ถ้า NLn < L { bind yb = กริดY(NLn); draw_quad_3d(x0,y00,z0, x1,y10,z0, x1,yb,z0, x0,yb,z0) }
bind j = j + 1
}
bind i = i + 1
}
}