3d Platformer 2
@Stage\n\n@Blank\n\n@Sprite1\n\ndefine Tri fill (ax) (ay) (bx) (by) (cx) (cy) resolution: (res)\npen up\nset [lena v] to ([sqrt v] of ((((bx) - (cx)) * ((bx) - (cx))) + (((by) - (cy)) * ((by) - (cy)))) )\nset [lenb v] to ([sqrt v] of ((((ax) - (cx)) * ((ax) - (cx))) + (((ay) - (cy)) * ((ay) - (cy)))) )\nset [lenc v] to ([sqrt v] of ((((ax) - (bx)) * ((ax) - (bx))) + (((ay) - (by)) * ((ay) - (by)))) )\nset [peri v] to ((1) / (((lena) + (lenb)) + (lenc)))\nset [incx v] to (((((lena) * (ax)) + ((lenb) * (bx))) + ((lenc) * (cx))) * (peri))\nset [incy v] to (((((lena) * (ay)) + ((lenb) * (by))) + ((lenc) * (cy))) * (peri))\nset [ind v] to ([sqrt v] of ((((((lenb) + (lenc)) - (lena)) * (((lenc) + (lena)) - (lenb))) * (((lena) + (lenb)) - (lenc))) * (peri)) )\nset [aox v] to ((incx) - (ax))\nset [aoy v] to ((incy) - (ay))\nset [box v] to ((incx) - (bx))\nset [boy v] to ((incy) - (by))\nset [cox v] to ((incx) - (cx))\nset [coy v] to ((incy) - (cy))\nif <<(lena) < (lenb)> and <(lena) < (lenc)>> then\n    set [td v] to ([sqrt v] of (((Aox) * (Aox)) + ((Aoy) * (Aoy))) )\nelse\n    if <<(lenb) > (lena)> or <(lenb) > (lenc)>> then\n        set [td v] to ([sqrt v] of (((Cox) * (Cox)) + ((Coy) * (Coy))) )\n    else\n        set [td v] to ([sqrt v] of (((Box) * (Box)) + ((Boy) * (Boy))) )\n    end\nend\nset [rate v] to ((((td) * (2)) - (ind)) / ((td) * (4)))\nset [td v] to [1]\ngo to x: (round (incx)) y: (round (incy))\nset pen size to (ind)\npen down\nrepeat ([ceiling v] of (([log v] of ((res) / (ind)) ) / ([log v] of (rate) )) )\n    set [td v] to ((td) * (rate))\n    set pen size to ((ind) * (td))\n    go to x: (((Aox) * (td)) + (ax)) y: (((Aoy) * (td)) + (ay))\n    go to x: (((Box) * (td)) + (bx)) y: (((Boy) * (td)) + (by))\n    go to x: (((Cox) * (td)) + (cx)) y: (((Coy) * (td)) + (cy))\n    go to x: (((Aox) * (td)) + (ax)) y: (((Aoy) * (td)) + (ay))\nend\npen up\n\ndefine 3d tri fill (x1) (y1) (z1) (x2) (y2) (z2) (x3) (y3) (z3)\nSet Point 1: ((x1) - (Player X)) ((y1) - (Player Y)) ((z1) - (Player Z))\nSet Point 2: ((x2) - (Player X)) ((y2) - (Player Y)) ((z2) - (Player Z))\nSet Point 3: ((x3) - (Player X)) ((y3) - (Player Y)) ((z3) - (Player Z))\nSet Point 1: (((z1) * (sin Y)) + ((x1) * (cos Y))) (y1) (((z1) * (cos Y)) - ((x1) * (sin Y)))\nSet Point 2: (((z2) * (sin Y)) + ((x2) * (cos Y))) (y2) (((z2) * (cos Y)) - ((x2) * (sin Y)))\nSet Point 3: (((z3) * (sin Y)) + ((x3) * (cos Y))) (y3) (((z3) * (cos Y)) - ((x3) * (sin Y)))\nSet Point 1: (x1) (((y1) * (cos X)) - ((z1) * (sin X))) (((y1) * (sin X)) + ((z1) * (cos X)))\nSet Point 2: (x2) (((y2) * (cos X)) - ((z2) * (sin X))) (((y2) * (sin X)) + ((z2) * (cos X)))\nSet Point 3: (x3) (((y3) * (cos X)) - ((z3) * (sin X))) (((y3) * (sin X)) + ((z3) * (cos X)))\nif <not <<<(z1) < (near plane)> and <(z2) < (near plane)>> and <(z3) < (near plane)>>> then\n    if <(z1) < (near plane)> then\n        set [z1 v] to (near plane)\n    end\n    if <(z2) < (near plane)> then\n        set [z2 v] to (near plane)\n    end\n    if <(z3) < (near plane)> then\n        set [z3 v] to (near plane)\n    end\n    Set Screen Point 1: ((view factor) * ((x1) / (z1))) ((view factor) * ((y1) / (z1)))\n    Set Screen Point 2: ((view factor) * ((x2) / (z2))) ((view factor) * ((y2) / (z2)))\n    Set Screen Point 3: ((view factor) * ((x3) / (z3))) ((view factor) * ((y3) / (z3)))\n    Tri fill (x1) (y1) (x2) (y2) (x3) (y3) resolution: (.5)\nend\n\ndefine Set Point 3: (x3) (y3) (z3)\nset [x3 v] to (x3)\nset [y3 v] to (y3)\nset [z3 v] to (z3)\n\ndefine Set Screen Point 3: (x3) (y3)\nset [x3 v] to (x3)\nset [y3 v] to (y3)\n\ndefine Sort Lists\nset [passes v] to [0]\nset [switches v] to [0]\nrepeat until <<(Passes) > [0]> and <(Switches) = [0]>>\n    set [list_item v] to [0]\n    change [passes v] by (1)\n    set [switches v] to [0]\n    repeat ((length of [block distances v]) - (1))\n        change [list_item v] by (1)\n        if <(item ((List_Item) + (1)) of [block distances v]) > (item (List_Item) of [block distances v])> then\n            set [value v] to (item ((List_Item) + (1)) of [block distances v])\n            replace item ((List_Item) + (1)) of [block distances v] with (item (List_Item) of [block distances v])\n            replace item (List_Item) of [block distances v] with (value)\n            set [value v] to (item ((List_Item) + (1)) of [cube y pos v])\n            replace item ((List_Item) + (1)) of [cube y pos v] with (item (List_Item) of [cube y pos v])\n            replace item (List_Item) of [cube y pos v] with (value)\n            set [value v] to (item ((List_Item) + (1)) of [cube x pos v])\n            replace item ((List_Item) + (1)) of [cube x pos v] with (item (List_Item) of [cube x pos v])\n            replace item (List_Item) of [cube x pos v] with (value)\n            set [value v] to (item ((List_Item) + (1)) of [cube z pos v])\n            replace item ((List_Item) + (1)) of [cube z pos v] with (item (List_Item) of [cube z pos v])\n            replace item (List_Item) of [cube z pos v] with (value)\n            set [value v] to (item ((List_Item) + (1)) of [platform type v])\n            replace item ((List_Item) + (1)) of [platform type v] with (item (List_Item) of [platform type v])\n            replace item (List_Item) of [platform type v] with (value)\n            change [switches v] by (1)\n        end\n    end\nend\n\ndefine Distance\ndelete all of [block distances v]\nset [iii v] to [0]\nrepeat (length of [cube x pos v])\n    change [iii v] by (1)\n    add (round ([sqrt v] of ((((Player Z) - (item (iii) of [cube z pos v])) * ((Player Z) - (item (iii) of [cube z pos v]))) + ((((Player Y) - (item (iii) of [cube y pos v])) * ((Player Y) - (item (iii) of [cube y pos v]))) + (((Player X) - (item (iii) of [cube x pos v])) * ((Player X) - (item (iii) of [cube x pos v]))))) )) to [block distances v]\nend\n\ndefine Set Point 1: (x1) (y1) (z1)\nset [x1 v] to (x1)\nset [y1 v] to (y1)\nset [z1 v] to (z1)\n\ndefine Set Point 2: (x2) (y2) (z2)\nset [x2 v] to (x2)\nset [y2 v] to (y2)\nset [z2 v] to (z2)\n\ndefine Set Screen Point 1: (x1) (y1)\nset [x1 v] to (x1)\nset [y1 v] to (y1)\n\ndefine Set Screen Point 2: (x2) (y2)\nset [x2 v] to (x2)\nset [y2 v] to (y2)\n\ndefine Cube  at (x) (y) (z) (platform type)\npen up\nCalculate Trig Values\nSelect color (platform type)\nset pen (brightness v) to (100)\nif <(item (ii) of [block distances v]) > [200]> then\n    change pen (brightness v) by ((() - ((item (ii) of [block distances v]) - (200))) / (8))\nend\nif <(Player X) > ((x) + (50))> then\n    3d tri fill ((x) + (50)) ((y) + (50)) ((z) + (50)) ((x) + (50)) ((y) + (50)) ((z) + (-50)) ((x) + (50)) ((y) + (-50)) ((z) + (-50))\n    3d tri fill ((x) + (50)) ((y) + (-50)) ((z) + (-50)) ((x) + (50)) ((y) + (-50)) ((z) + (50)) ((x) + (50)) ((y) + (50)) ((z) + (50))\nend\nif <(Player Z) < ((z) - (50))> then\n    3d tri fill ((x) + (-50)) ((y) + (-50)) ((z) + (-50)) ((x) + (50)) ((y) + (-50)) ((z) + (-50)) ((x) + (50)) ((y) + (50)) ((z) + (-50))\n    3d tri fill ((x) + (50)) ((y) + (50)) ((z) + (-50)) ((x) + (-50)) ((y) + (50)) ((z) + (-50)) ((x) + (-50)) ((y) + (-50)) ((z) + (-50))\nend\nif <(Player Z) > ((z) + (50))> then\n    3d tri fill ((x) + (-50)) ((y) + (-50)) ((z) + (50)) ((x) + (50)) ((y) + (-50)) ((z) + (50)) ((x) + (50)) ((y) + (50)) ((z) + (50))\n    3d tri fill ((x) + (50)) ((y) + (50)) ((z) + (50)) ((x) + (-50)) ((y) + (50)) ((z) + (50)) ((x) + (-50)) ((y) + (-50)) ((z) + (50))\nend\nif <(Player Y) < ((y) - (50))> then\n    3d tri fill ((x) + (50)) ((y) + (-50)) ((z) + (-50)) ((x) + (-50)) ((y) + (-50)) ((z) + (-50)) ((x) + (-50)) ((y) + (-50)) ((z) + (50))\n    3d tri fill ((x) + (-50)) ((y) + (-50)) ((z) + (50)) ((x) + (50)) ((y) + (-50)) ((z) + (50)) ((x) + (50)) ((y) + (-50)) ((z) + (-50))\nend\nif <((y) - (-50)) < (Player Y)> then\n    3d tri fill ((x) + (50)) ((y) + (50)) ((z) + (-50)) ((x) + (-50)) ((y) + (50)) ((z) + (-50)) ((x) + (-50)) ((y) + (50)) ((z) + (50))\n    3d tri fill ((x) + (-50)) ((y) + (50)) ((z) + (50)) ((x) + (50)) ((y) + (50)) ((z) + (50)) ((x) + (50)) ((y) + (50)) ((z) + (-50))\nend\nif <(Player X) < ((x) - (50))> then\n    3d tri fill ((x) + (-50)) ((y) + (50)) ((z) + (50)) ((x) + (-50)) ((y) + (50)) ((z) + (-50)) ((x) + (-50)) ((y) + (-50)) ((z) + (-50))\n    3d tri fill ((x) + (-50)) ((y) + (-50)) ((z) + (-50)) ((x) + (-50)) ((y) + (-50)) ((z) + (50)) ((x) + (-50)) ((y) + (50)) ((z) + (50))\nend\n\ndefine Calculate Trig Values\nset [sin x v] to ([sin v] of (rot Y) )\nset [cos x v] to ([cos v] of (rot Y) )\nset [sin y v] to ([sin v] of (rot X) )\nset [cos y v] to ([cos v] of (rot X) )\n\ndefine Turn and Move\nif <key (up arrow v) pressed?> then\n    change [ryv v] by (1.7)\nend\nif <key (left arrow v) pressed?> then\n    change [rxv v] by (1.7)\nend\nif <key (right arrow v) pressed?> then\n    change [rxv v] by (-1.7)\nend\nif <key (down arrow v) pressed?> then\n    change [ryv v] by (-1.7)\nend\nif <key (w v) pressed?> then\n    change [zvel v] by ((2) * (cos Y))\n    change [xvel v] by ((-2) * (sin Y))\nend\nif <key (s v) pressed?> then\n    change [zvel v] by ((-2) * (cos Y))\n    change [xvel v] by ((2) * (sin Y))\nend\nif <key (a v) pressed?> then\n    change [zvel v] by ((-2) * (sin Y))\n    change [xvel v] by ((-2) * (cos Y))\nend\nif <key (d v) pressed?> then\n    change [zvel v] by ((2) * (sin Y))\n    change [xvel v] by ((2) * (cos Y))\nend\nchange [rot x v] by (rxv)\nchange [rot y v] by (ryv)\nif <(rot Y) < [-90]> then\n    set [rot y v] to [-90]\nend\nif <[90] < (rot Y)> then\n    set [rot y v] to [90]\nend\nset [rxv v] to ((rxv) * (.7))\nset [ryv v] to ((ryv) * (.7))\nPhysics\n\ndefine Collisions!\nset [touching platform? v] to [no]\nset [i v] to [0]\nrepeat (length of [cube x pos v])\n    change [i v] by (1)\n    if <<<not <(Player Y) < ((item (i) of [cube y pos v]) - (90))>> and <not <(Player Y) > ((item (i) of [cube y pos v]) + (130))>>> and <<<not <(Player Z) < ((item (i) of [cube z pos v]) - (60))>> and <not <(Player Z) > ((item (i) of [cube z pos v]) + (60))>>> and <<not <(Player X) < ((item (i) of [cube x pos v]) - (60))>> and <not <(Player X) > ((item (i) of [cube x pos v]) + (60))>>>>> then\n        if <(item (i) of [platform type v]) = [platform]> then\n            set [touching platform? v] to [yes]\n        else\n            if <(item (i) of [platform type v]) = [lava]> then\n                Reset\n            else\n                if <(item (i) of [platform type v]) = [trampoline]> then\n                    set [yvel v] to [30]\n                else\n                    if <(item (i) of [platform type v]) = [end]> then\n                        change [level v] by (1)\n                        Reset\n                    end\n                end\n            end\n        end\n        stop [this script v]\n    end\nend\n\ndefine Physics\nchange [falling? v] by (1)\nchange [yvel v] by (-1)\nchange [player y v] by (Yvel)\nCollisions!\nif <(Touching platform?) = [yes]> then\n    Y collision (Yvel)\nend\nchange [player z v] by (Zvel)\nCollisions!\nif <(Touching platform?) = [yes]> then\n    Z Collision (Zvel)\nend\nchange [player x v] by (Xvel)\nCollisions!\nif <(Touching platform?) = [yes]> then\n    X Collisions (Xvel)\nend\nset [zvel v] to ((Zvel) * (0.7))\nset [xvel v] to ((Xvel) * (0.7))\nif <<key (space v) pressed?> and <(Falling?) < [5]>> then\n    set [yvel v] to [14]\nend\nif <(Player Y) < [-500]> then\n    Reset\nend\nRender\n\ndefine Y collision (y)\nrepeat until <not <(Touching platform?) = [yes]>>\n    if <(y) > [0]> then\n        change [player y v] by (-1)\n    else\n        change [player y v] by (1)\n        set [falling? v] to [0]\n    end\n    set [yvel v] to [0]\n    Collisions!\nend\n\ndefine Z Collision (z)\nrepeat until <not <(Touching platform?) = [yes]>>\n    if <(z) > [0]> then\n        change [player z v] by (-1)\n    else\n        change [player z v] by (1)\n    end\n    set [zvel v] to [0]\n    Collisions!\nend\n\ndefine X Collisions (x)\nrepeat until <not <(Touching platform?) = [yes]>>\n    if <(x) > [0]> then\n        change [player x v] by (-1)\n    else\n        change [player x v] by (1)\n    end\n    set [xvel v] to [0]\n    Collisions!\nend\n\ndefine Reset\nset [view factor v] to [200]\nset [player x v] to [0]\nset [player y v] to [300]\nset [player z v] to [0]\nset [near plane v] to [.1]\nset [falling? v] to [50]\nset [yvel v] to [0]\nset [rot y v] to [0]\nset [rot x v] to [0]\nset [rxv v] to [0]\nset [ryv v] to [0]\npen up\nLevel\n\nwhen flag clicked\nset [level v] to [1]\nerase all\nReset\nforever\n    Broadcast\nend\n\ndefine Level\ndelete all of [cube y pos v]\ndelete all of [cube x pos v]\ndelete all of [cube z pos v]\ndelete all of [platform type v]\nif <(level) = [1]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [0] [0] [350] [end]\nend\nif <(level) = [2]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [100] [0] [100] [lava]\n    Cube at: X, Y, Z, TYPE [0] [0] [200] [end]\nend\nif <(level) = [3]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [50] [0] [200] [trampoline]\n    Cube at: X, Y, Z, TYPE [500] [150] [500] [trampoline]\n    Cube at: X, Y, Z, TYPE [1000] [-100] [800] [trampoline]\n    Cube at: X, Y, Z, TYPE [1000] [-100] [1200] [platform]\n    Cube at: X, Y, Z, TYPE [900] [-100] [1300] [end]\nend\nif <(level) = [4]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [-200] [200] [0] [trampoline]\n    Cube at: X, Y, Z, TYPE [400] [200] [0] [trampoline]\n    Cube at: X, Y, Z, TYPE [400] [300] [0] [lava]\n    Cube at: X, Y, Z, TYPE [400] [100] [0] [lava]\n    Cube at: X, Y, Z, TYPE [400] [200] [-100] [lava]\n    Cube at: X, Y, Z, TYPE [400] [200] [100] [lava]\n    Cube at: X, Y, Z, TYPE [800] [300] [100] [end]\nend\nif <(level) = [5]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [0] [0] [100] [platform]\n    Cube at: X, Y, Z, TYPE [100] [0] [200] [lava]\n    Cube at: X, Y, Z, TYPE [0] [0] [300] [platform]\n    Cube at: X, Y, Z, TYPE [0] [0] [200] [end]\nend\nif <(level) = [6]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [140] [100] [100] [platform]\n    Cube at: X, Y, Z, TYPE [280] [0] [200] [platform]\n    Cube at: X, Y, Z, TYPE [423] [-100] [100] [platform]\n    Cube at: X, Y, Z, TYPE [600] [-100] [-50] [end]\nend\nif <(level) = [7]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [100] [0] [100] [trampoline]\n    Cube at: X, Y, Z, TYPE [500] [0] [100] [lava]\n    Cube at: X, Y, Z, TYPE [600] [0] [90] [end]\nend\nif <(level) = [8]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [150] [150] [150] [trampoline]\n    Cube at: X, Y, Z, TYPE [380] [400] [400] [platform]\n    Cube at: X, Y, Z, TYPE [580] [600] [600] [end]\nend\nif <(level) = [9]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [0] [0] [200] [lava]\n    Cube at: X, Y, Z, TYPE [0] [0] [300] [platform]\n    Cube at: X, Y, Z, TYPE [0] [100] [500] [lava]\n    Cube at: X, Y, Z, TYPE [0] [100] [600] [platform]\n    Cube at: X, Y, Z, TYPE [0] [200] [900] [end]\nend\nif <(level) = [10]> then\n    Cube at: X, Y, Z, TYPE [0] [0] [0] [platform]\n    Cube at: X, Y, Z, TYPE [0] [0] [100] [trampoline]\n    Cube at: X, Y, Z, TYPE [234] [134] [45] [trampoline]\n    Cube at: X, Y, Z, TYPE [-40] [-40] [220] [trampoline]\n    Cube at: X, Y, Z, TYPE [-120] [80] [-100] [trampoline]\n    Cube at: X, Y, Z, TYPE [80] [-120] [80] [trampoline]\nend\n\ndefine Render\nbackground\nDistance\nSort Lists\npen up\nset pen size to (2)\nset [ii v] to [0]\nrepeat (length of [cube x pos v])\n    change [ii v] by (1)\n    if <(item (ii) of [block distances v]) < [2000]> then\n        Cube  at (item (ii) of [cube x pos v]) (item (ii) of [cube y pos v]) (item (ii) of [cube z pos v]) (item (ii) of [platform type v])\n    end\nend\n\ndefine Select color (current platform type)\nif <(current platform type) = [platform]> then\n    set pen color to (#1c5dff)\nelse\n    if <(current platform type) = [lava]> then\n        set pen color to (#ff1c1c)\n    else\n        if <(current platform type) = [trampoline]> then\n            set pen color to (#fff71c)\n        else\n            if <(current platform type) = [end]> then\n                set pen color to (#1cff45)\n            end\n        end\n    end\nend\n\ndefine Cube at: X, Y, Z, TYPE (y) (x) (z) (type)\nadd (y) to [cube y pos v]\nadd (x) to [cube x pos v]\nadd (z) to [cube z pos v]\nadd (type) to [platform type v]\n\ndefine background\npen up\ngo to x: (0) y: (0)\nset pen color to (#000000)\nset pen size to (700)\npen down\npen up\n\ndefine Broadcast\nbroadcast (Tick v)\nbroadcast (Tick v)\n\nwhen I receive [tick v]\nBroadcast\nTick\nBroadcast\n\ndefine Tick\nBroadcast\nerase all\npen up\nset pen size to (2)\nTurn and Move\nset [fps v] to (round ((1) / ((timer) - (prev. timer))))\nset [prev. timer v] to (timer)\nBroadcast\n\nwhen flag clicked\nforever\n    if <key (r v) pressed?> then\n        Reset\n        wait until <not <key (r v) pressed?>>\n    end\nend\n\nwhen flag clicked\nforever\n    if <key (z v) pressed?> then\n        change [level v] by (1)\n        Reset\n        wait until <not <key (z v) pressed?>>\n    end\nend\n\nwhen flag clicked\nforever\n    play sound [Summit v] until done\nend\n\nwhen flag clicked\nset size to (Infinity) %\n\n@TB\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\n
Play on https://forkphorus.github.io/#407397897 for no lag\n\nInstructions\n   -Use WASD to move\n   -Use arrow keys to turn\n   -Use space to jump\n   -Hold space to jump higher\n   -Z to skip\n   -R to retry