灵符lingfu

soul-symphony-ling

↓ 0 downloads

Soul 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-ling
AuthorsLing Lin <taellinglin@gmail.com>
READMECode / FilesVersionsDependency GraphDependentsSecurityBuildsSettings

Code / Files (1947)

game/boss.ling
# ════════════════════════════════════════════════════════════════════════════
# boss.ling — "THE JACK": ลูกบาศก์กลาง + 6 แขนทรงแปดเหลี่ยม (โซ่สะบัด) +
#   6 ทรงกลมปลายแขน (อิมิตเตอร์: ยิงคลื่นเวกเตอร์ "ต้นไม้แห่งชีวิต" เข้าหาผู้เล่น).
#   ทุบสเฟียร์ครบ 6 → ลูกบาศก์กลางเปิดเป็นจุดอ่อน. สี/อบิลิตี้เปลี่ยนทุกเลเวล.
#   AI = rule-based (สะบัดเข้าหาผู้เล่น + จังหวะยิง). ไม่มี LLM.
# ════════════════════════════════════════════════════════════════════════════

# สีบอสตามเลเวล (เปลี่ยนทุกด่าน)
ฟังก์ชัน สีบอส(lvl, k) {
    bind h = lvl * 1.7 + k
    คืน [floor((ไซน์(h)*0.5+0.5)*180+50), floor((ไซน์(h+2.094)*0.5+0.5)*180+50), floor((ไซน์(h+4.189)*0.5+0.5)*180+50)]
}

# ลูกบาศก์เติม (6 quads) ที่ (cx,cy,cz) ครึ่งขนาด h
# OPTIMIZED: Using draw_quad_3d instead of 12 triangles → 2× faster, shared edge dedup
ฟังก์ชัน วาดลูกบาศก์เติม(cx, cy, cz, h) {
    bind x0=cx-h; bind x1=cx+h; bind y0=cy-h; bind y1=cy+h; bind z0=cz-h; bind z1=cz+h
    # Front face (z0)
    draw_quad_3d(x0,y0,z0, x1,y0,z0, x1,y1,z0, x0,y1,z0)
    # Back face (z1)
    draw_quad_3d(x1,y0,z1, x0,y0,z1, x0,y1,z1, x1,y1,z1)
    # Left face (x0)
    draw_quad_3d(x0,y0,z1, x0,y0,z0, x0,y1,z0, x0,y1,z1)
    # Right face (x1)
    draw_quad_3d(x1,y0,z0, x1,y0,z1, x1,y1,z1, x1,y1,z0)
    # Top face (y1)
    draw_quad_3d(x0,y1,z0, x1,y1,z0, x1,y1,z1, x0,y1,z1)
    # Bottom face (y0)
    draw_quad_3d(x0,y0,z1, x1,y0,z1, x1,y0,z0, x0,y0,z0)
}

# แท่งแปดเหลี่ยมเติม A→B รัศมี rad (16 สามเหลี่ยมข้าง)
ฟังก์ชัน วาดแปดเหลี่ยม(ax,ay,az, bx,by,bz, rad) {
    bind ux=bx-ax; bind uy=by-ay; bind uz=bz-az
    bind ul=รากที่สอง(ux*ux+uy*uy+uz*uz);  ถ้า ul < 0.001 { คืน 0 }
    bind ux=ux/ul; bind uy=uy/ul; bind uz=uz/ul
    bind hx=0.0; bind hy=1.0; bind hz=0.0
    ถ้า uy > 0.9 { bind hx=1.0; bind hy=0.0 }
    ถ้า uy < 0.0-0.9 { bind hx=1.0; bind hy=0.0 }
    bind rx=uy*hz-uz*hy; bind ry=uz*hx-ux*hz; bind rz=ux*hy-uy*hx
    bind rl=รากที่สอง(rx*rx+ry*ry+rz*rz)+0.0001
    bind rx=rx/rl; bind ry=ry/rl; bind rz=rz/rl
    bind sx=uy*rz-uz*ry; bind sy=uz*rx-ux*rz; bind sz=ux*ry-uy*rx
    bind k=0
    ขณะที่ k < 8 {
        bind a0=k*0.7854; bind a1=(k+1)*0.7854
        bind c0=โคไซน์(a0); bind n0=ไซน์(a0); bind c1=โคไซน์(a1); bind n1=ไซน์(a1)
        bind A0x=ax+rad*(c0*rx+n0*sx); bind A0y=ay+rad*(c0*ry+n0*sy); bind A0z=az+rad*(c0*rz+n0*sz)
        bind A1x=ax+rad*(c1*rx+n1*sx); bind A1y=ay+rad*(c1*ry+n1*sy); bind A1z=az+rad*(c1*rz+n1*sz)
        bind B0x=bx+rad*(c0*rx+n0*sx); bind B0y=by+rad*(c0*ry+n0*sy); bind B0z=bz+rad*(c0*rz+n0*sz)
        bind B1x=bx+rad*(c1*rx+n1*sx); bind B1y=by+rad*(c1*ry+n1*sy); bind B1z=bz+rad*(c1*rz+n1*sz)
        วาดสามเหลี่ยม3มิติ(A0x,A0y,A0z, A1x,A1y,A1z, B1x,B1y,B1z)
        วาดสามเหลี่ยม3มิติ(A0x,A0y,A0z, B1x,B1y,B1z, B0x,B0y,B0z)
        bind k=k+1
    }
}

# ข้อต่อแขน f (0..5) แบบโซ่ 3 ท่อน สะบัดเข้าหาผู้เล่น → [p0..p3] (12 ตัวเลข)
ฟังก์ชัน ข้อแขนบอส(bx,by,bz, f, t, seed, px,pz) {
    bind dx=0.0; bind dy=0.0; bind dz=0.0
    ถ้า f==0 { bind dx=1.0 }      ถ้า f==1 { bind dx=0.0-1.0 }
    ถ้า f==2 { bind dy=0.0-1.0 }  ถ้า f==3 { bind dy=1.0 }
    ถ้า f==4 { bind dz=1.0 }      ถ้า f==5 { bind dz=0.0-1.0 }
    bind c=7.0; bind L=9.0
    bind p0x=bx+dx*c; bind p0y=by+dy*c; bind p0z=bz+dz*c
    bind tx=px-p0x; bind tz=pz-p0z; bind tl=รากที่สอง(tx*tx+tz*tz)+0.001
    bind tpx=tx/tl; bind tpz=tz/tl
    bind sway=ไซน์(t*2.6 + seed + f*1.1)
    bind reach=โคไซน์(t*1.3 + seed + f)*0.5+0.5    # หด/ยืด (whip)
    # ท่อน 1
    bind d1x=dx*0.65+tpx*0.35; bind d1y=dy*0.7+sway*0.5; bind d1z=dz*0.65+tpz*0.35
    bind l1=รากที่สอง(d1x*d1x+d1y*d1y+d1z*d1z)+0.001
    bind p1x=p0x+d1x/l1*L; bind p1y=p0y+d1y/l1*L; bind p1z=p0z+d1z/l1*L
    # ท่อน 2
    bind d2x=dx*0.35+tpx*0.65; bind d2y=dy*0.3+sway*0.8; bind d2z=dz*0.35+tpz*0.65
    bind l2=รากที่สอง(d2x*d2x+d2y*d2y+d2z*d2z)+0.001
    bind p2x=p1x+d2x/l2*L*(0.7+reach*0.5); bind p2y=p1y+d2y/l2*L*(0.7+reach*0.5); bind p2z=p1z+d2z/l2*L*(0.7+reach*0.5)
    # ท่อน 3 (ปลาย → สเฟียร์)
    bind d3x=tpx; bind d3y=sway*0.9; bind d3z=tpz
    bind l3=รากที่สอง(d3x*d3x+d3y*d3y+d3z*d3z)+0.001
    bind p3x=p2x+d3x/l3*L*(0.6+reach*0.6); bind p3y=p2y+d3y/l3*L*(0.6+reach*0.6); bind p3z=p2z+d3z/l3*L*(0.6+reach*0.6)
    คืน [p0x,p0y,p0z, p1x,p1y,p1z, p2x,p2y,p2z, p3x,p3y,p3z]
}

# ปลายแขน f (ตำแหน่งสเฟียร์) → [x,y,z]  (ใช้ hit-test ใน main)
ฟังก์ชัน ปลายแขนบอส(bx,by,bz, f, t, seed, px,pz) {
    bind j = ข้อแขนบอส(bx,by,bz, f, t, seed, px,pz)
    คืน [list_get(j,9), list_get(j,10), list_get(j,11)]
}

# ── วาดบอส: ลูกบาศก์ + 6 แขน + สเฟียร์มีชีวิต + คลื่นยิง + จุดอ่อน ───────────
#   sphHP = [hp×6]; vuln = 1 เมื่อทุบครบ (ลูกบาศก์เป็นจุดอ่อน)
ฟังก์ชัน วาดบอส(bx,by,bz, t, lvl, sphHP, px,pz, vuln) {
    bind seed = lvl * 1.3
    bind ccol = สีบอส(lvl, 0)
    โหมดผสม(0)
    # ลูกบาศก์กลาง (จุดอ่อนเมื่อ vuln)
    ถ้า vuln > 0.5 {
        bind pulse = ไซน์(t*6.0)*0.5+0.5
        สีดินสอ(floor(120+pulse*135), floor(30+pulse*40), 40)
    }
    มิฉะนั้น { สีดินสอ(floor(list_get(ccol,0)*0.6), floor(list_get(ccol,1)*0.6), floor(list_get(ccol,2)*0.6)) }
    วาดลูกบาศก์เติม(bx, by, bz, 6.0)
    # 6 แขน + สเฟียร์
    bind f = 0
    ขณะที่ f < 6 {
        bind j = ข้อแขนบอส(bx,by,bz, f, t, seed, px,pz)
        bind hp = list_get(sphHP, f)
        ถ้า hp > 0.0 {
            สีดินสอ(floor(list_get(ccol,0)*0.8), floor(list_get(ccol,1)*0.8), floor(list_get(ccol,2)*0.8))
            วาดแปดเหลี่ยม(list_get(j,0),list_get(j,1),list_get(j,2), list_get(j,3),list_get(j,4),list_get(j,5), 2.4)
            วาดแปดเหลี่ยม(list_get(j,3),list_get(j,4),list_get(j,5), list_get(j,6),list_get(j,7),list_get(j,8), 2.0)
            วาดแปดเหลี่ยม(list_get(j,6),list_get(j,7),list_get(j,8), list_get(j,9),list_get(j,10),list_get(j,11), 1.6)
            # สเฟียร์อิมิตเตอร์ (ทรงกลมเรืองแสง) + วงแหวนคลื่นยิงเข้าหาผู้เล่น
            bind ex=list_get(j,9); bind ey=list_get(j,10); bind ez=list_get(j,11)
            โหมดผสม(1)
            อนุภาคทรงกลม(ex,ey,ez, 3.0, 20, t*1.5+f, list_get(ccol,0), list_get(ccol,1), list_get(ccol,2))
            # คลื่น "ต้นไม้แห่งชีวิต": ดอกบัวที่เดินทางจากสเฟียร์ → ผู้เล่น
            bind wp = t*0.5 + f*0.37
            bind wf = wp - ปัดลง(wp)            # 0..1 เฟสคลื่น
            bind wx=ex+(px-ex)*wf; bind wz=ez+(pz-ez)*wf; bind wy=ey+(by-ey)*0.0
            สีดินสอ(floor(list_get(ccol,0)*0.5+120), list_get(ccol,1), list_get(ccol,2))
            ลายดอกบัว(wx, ey, wz, 1,0,0, 0,0,1, 1.0+wf*2.0, 3.0+wf*5.0, 8, t*0.6+f, lvl*0.3)
            โหมดผสม(0)
        }
        bind f = f + 1
    }
    โหมดผสม(0)
}

← Back to index