3D Platformer

Instructions: --Instructions in the game--\nMy 1st 3D platformer!\n\nLike and Star for a message! :)\n1000+ blocks!\n\nComment your time in the comments!\nMy fastest time is 22\n\nPlay this game on TurboWarp for less lag. (If you want)\nhttps://turbowarp.org/629424549?hqpen\n\nThanks to @k0stya for the engine\nEnjoy!\n\nLet's get this on trending!

@Stage\n\nwhen flag clicked\nreset timer\nset [level v] to [0]\nset [time v] to [0]\nerase all\nswitch backdrop to (backdrop2 v)\nset volume to (60) %\nrepeat until <key (2 v) pressed?>\n    play sound [Treenan v] until done\nend\n\nwhen [1 v] key pressed\nset volume to (60) %\nstop all sounds\nplay sound [Treenan v] until done\n\nwhen [2 v] key pressed\nset volume to (40) %\nstop all sounds\nplay sound [Elektronomia_JJD_Free_NCS_Release_ v] until done\n\n@Blank\n\n@3D Genarating//3D\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 ((((cam z) - (item (iii) of [cube z pos v])) * ((cam z) - (item (iii) of [cube z pos v]))) + ((((cam y) - (item (iii) of [cube y pos v])) * ((cam y) - (item (iii) of [cube y pos v]))) + (((cam x) - (item (iii) of [cube x pos v])) * ((cam 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 Draw Line (x1) (y1) (z1) to (x2) (y2) (z2)\nSet Point 1: ((x1) - (cam x)) ((y1) - (cam y)) ((z1) - (cam z))\nSet Point 2: ((x2) - (cam x)) ((y2) - (cam y)) ((z2) - (cam 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 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)))\nif <not <<(z1) < (near plane)> and <(z2) < (near plane)>>> then\n    Z Clipping\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    go to x: (x1) y: (y1)\n    pen down\n    go to x: (x2) y: (y2)\n    pen up\nend\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 Put Cube at (x) (y) (z) (platform type)\nCalculate Trig Values\nSelect color (platform type)\nset pen (brightness v) to (((1000) - (item (ii) of [block distances v])) / (6))\nDraw Square (x) (y) ((50) + (z))\nDraw Line ((50) + (x)) ((50) + (y)) ((50) + (z)) to ((50) + (x)) ((50) + (y)) ((-50) + (z))\nDraw Line ((50) + (x)) ((-50) + (y)) ((50) + (z)) to ((50) + (x)) ((-50) + (y)) ((-50) + (z))\nDraw Line ((-50) + (x)) ((-50) + (y)) ((50) + (z)) to ((-50) + (x)) ((-50) + (y)) ((-50) + (z))\nDraw Line ((-50) + (x)) ((50) + (y)) ((50) + (z)) to ((-50) + (x)) ((50) + (y)) ((-50) + (z))\nDraw Square (x) (y) ((-50) + (z))\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 Z Clipping\nif <<(z1) < (near plane)> or <(z2) < (near plane)>> then\n    set [percent v] to (((near plane) - (z1)) / ((z2) - (z1)))\n    if <(z1) < (near plane)> then\n        Set Point 1: ((x1) + (((x2) - (x1)) * (percent))) ((y1) + (((y2) - (y1)) * (percent))) (near plane)\n    else\n        if <(z2) < (near plane)> then\n            Set Point 2: ((x1) + (((x2) - (x1)) * (percent))) ((y1) + (((y2) - (y1)) * (percent))) (near plane)\n        end\n    end\nend\n\ndefine Turn and Move\nif <key (up arrow v) pressed?> then\n    change [rot y v] by (4)\nend\nif <key (left arrow v) pressed?> then\n    change [rot x v] by (4)\nend\nif <key (right arrow v) pressed?> then\n    change [rot x v] by (-4)\nend\nif <key (down arrow v) pressed?> then\n    change [rot y v] by (-4)\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\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\nPhysics\n\ndefine Collisions!\nset [touching platform? v] to [no]\nset [touching end v] to [no]\nset [i v] to [0]\nrepeat (length of [cube x pos v])\n    change [i v] by (1)\n    if <<<not <(cam y) < ((item (i) of [cube y pos v]) - (90))>> and <not <(cam y) > ((item (i) of [cube y pos v]) + (130))>>> and <<<not <(cam z) < ((item (i) of [cube z pos v]) - (60))>> and <not <(cam z) > ((item (i) of [cube z pos v]) + (60))>>> and <<not <(cam x) < ((item (i) of [cube x pos v]) - (60))>> and <not <(cam 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 [y vel v] to [34]\n                else\n                    set [touching end v] to [yes]\n                end\n            end\n        end\n        stop [this script v]\n    end\nend\n\ndefine Physics\nchange [falling? v] by (1)\nchange [y vel v] by (-1)\nchange [cam y v] by (Y vel)\nCollisions!\nif <(Touching platform?) = [yes]> then\n    Y collision (Y vel)\nend\nchange [cam z v] by (Zvel)\nCollisions!\nif <(Touching platform?) = [yes]> then\n    Z Collision (Zvel)\nend\nchange [cam 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 [y vel v] to [14]\nend\nif <(cam 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 [cam y v] by (-1)\n    else\n        change [cam y v] by (1)\n        set [falling? v] to [0]\n    end\n    set [y vel v] to [0]\n    Collisions!\nend\n\ndefine Z Collision (z)\nrepeat until <not <(Touching platform?) = [yes]>>\n    if <(z) > [0]> then\n        change [cam z v] by (-1)\n    else\n        change [cam 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 [cam x v] by (-1)\n    else\n        change [cam x v] by (1)\n    end\n    set [xvel v] to [0]\n    Collisions!\nend\n\ndefine Reset\nset [view factor v] to [150]\nset [cam speed v] to [6]\nset [cam x v] to [0]\nset [cam y v] to [150]\nset [cam z v] to [0]\nset [near plane v] to [1]\nset [y vel v] to [0]\nset [rot y v] to [0]\nset [rot x v] to [0]\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    Level design [0] [0] [0] [Platform]\n    Level design [0] [0] [1] [Lava]\n    Level design [0] [0] [2] [Platform]\n    Level design [0] [0] [3] [Lava]\n    Level design [0] [0] [4] [Platform]\n    Level design [0] [0] [5] [Lava]\n    Level design [0] [0] [6] [End]\nend\nif <(Level) = [2]> then\n    Level design [0] [0] [0] [Platform]\n    Level design [0] [1] [1] [Platform]\n    Level design [0] [2] [2] [Platform]\n    Level design [0] [3] [3] [Lava]\n    Level design [2] [3] [3] [Platform]\n    Level design [1] [4] [4] [Lava]\n    Level design [0] [4] [4] [End]\n    Level design [1] [4] [4] [Lava]\nend\nif <(Level) = [3]> then\n    Level design [0] [0] [0] [Platform]\n    Level design [0] [0] [1] [Trampoline]\n    Level design [0] [4] [2] [Platform]\n    Level design [1] [4] [4] [Platform]\n    Level design [0] [4] [4] [Lava]\n    Level design [-1] [4] [6] [Platform]\n    Level design [-1] [4] [7] [Lava]\n    Level design [-1] [4] [8] [Platform]\n    Level design [-1] [5] [9] [Platform]\n    Level design [-1] [3] [10] [End]\nend\nif <(Level) = [4]> then\n    Level design [0] [0] [0] [Platform]\n    Level design [0] [0] [1] [Platform]\n    Level design [0] [-1] [3] [Trampoline]\n    Level design [0] [3] [4] [Platform]\n    Level design [0] [3] [5] [Platform]\n    Level design [0] [4] [5] [Platform]\n    Level design [0] [5] [5] [Platform]\n    Level design [0] [6] [5] [Lava]\n    Level design [0] [3] [6] [Platform]\n    Level design [0] [3] [7] [End]\nend\nif <(Level) = [5]> then\n    Level design [0] [0] [0] [Platform]\n    Level design [0] [0] [2] [Lava]\n    Level design [0] [0] [1] [Lava]\n    Level design [0] [0] [3] [Platform]\n    Level design [0] [0] [5] [Lava]\n    Level design [0] [1] [5] [Lava]\n    Level design [0] [2] [5] [Lava]\n    Level design [-1] [0] [5] [Platform]\n    Level design [-1] [1] [6] [Platform]\n    Level design [0] [0] [6] [End]\nend\n\ndefine Render\nDistance\nSort Lists\nset pen size to (8)\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]) < [1100]> then\n        Put 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 (#33f7db)\nelse\n    if <(current platform type) = [Lava]> then\n        set pen color to (#ff3333)\n    else\n        if <(current platform type) = [Trampoline]> then\n            set pen color to (#fff830)\n        else\n            set pen color to (#33ff30)\n        end\n    end\nend\n\ndefine Level design (x) (y) (z) (type)\nadd ((x) * (100)) to [cube x pos v]\nadd ((y) * (100)) to [cube y pos v]\nadd ((z) * (100)) to [cube z pos v]\nadd (type) to [platform type v]\n\ndefine Draw Square (x) (y) (z)\nDraw Line ((50) + (x)) ((50) + (y)) (z) to ((50) + (x)) ((-50) + (y)) (z)\nDraw Line ((50) + (x)) ((-50) + (y)) (z) to ((-50) + (x)) ((-50) + (y)) (z)\nDraw Line ((-50) + (x)) ((-50) + (y)) (z) to ((-50) + (x)) ((50) + (y)) (z)\nDraw Line ((-50) + (x)) ((50) + (y)) (z) to ((50) + (x)) ((50) + (y)) (z)\n\nwhen I receive [start v]\nswitch backdrop to (backdrop1 v)\nswitch costume to (costume2 v)\nset size to (9999999999999999999) %\nswitch costume to (costume1 v)\nreset timer\nset [level v] to [1]\nLevel\nReset\nforever\n    erase all\n    Turn and Move\n    if <<(Touching end) = [yes]> or <key (p v) pressed?>> then\n        wait until <not <key (p v) pressed?>>\n        change [level v] by (1)\n        Level\n        Reset\n    end\n    if <key (o v) pressed?> then\n        if <(Level) > [1]> then\n            wait until <not <key (o v) pressed?>>\n            change [level v] by (-1)\n            Level\n            Reset\n        end\n    end\nend\n\nset pen color to (#ffffff)\nset pen size to (5)\ngo to x: (-10) y: (0)\npen down\ngo to x: (10) y: (0)\npen up\ngo to x: (0) y: (-10)\npen down\ngo to x: (0) y: (10)\npen up\n\n@Start Menu//Start Menu\n\ndefine Build (num) Start (start)\nset [clonenum v] to (start)\nrepeat (num)\n    change [clonenum v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\ngo to [front v] layer\nshow\nif <(CloneNum) = [1]> then\n    switch costume to (background v)\n    forever\n        if <<key (up arrow v) pressed?> or <key (right arrow v) pressed?>> then\n            start sound [Action v]\n            if <(ButtonSelected) = [1]> then\n                set [buttonselected v] to [2]\n            else\n                change [buttonselected v] by (-1)\n            end\n            wait (0.1) seconds\n        end\n        if <<key (down arrow v) pressed?> or <key (left arrow v) pressed?>> then\n            start sound [Action v]\n            if <(ButtonSelected) = [2]> then\n                set [buttonselected v] to [1]\n            else\n                change [buttonselected v] by (1)\n            end\n            wait (0.1) seconds\n        end\n    end\nend\nif <(CloneNum) = [2]> then\n    switch costume to (playbutton v)\n    forever\n        if <(ButtonSelected) = [1]> then\n            if <key (space v) pressed?> then\n                broadcast (Start v)\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    end\nend\nif <(CloneNum) = [3]> then\n    switch costume to (controlsbutton v)\n    forever\n        if <(ButtonSelected) = [2]> then\n            if <key (space v) pressed?> then\n                broadcast (Controls v)\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    end\nend\nif <(CloneNum) = [5]> then\n    switch costume to (arrow v)\n    go to x: (-150) y: (-50)\n    forever\n        go to x: (-225) y: ((-50) * ((ButtonSelected) - (1)))\n    end\nend\n\nwhen I start as a clone\nforever\n    if <(DeleteAllClones?) = [1]> then\n        delete this clone\n    end\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nBuild [5] Start [0]\n\nwhen I receive [start v]\nset [deleteallclones? v] to [1]\nwait (0.1) seconds\nset [deleteallclones? v] to [0]\nforever\n    wait (1) seconds\n    change [time v] by (1)\n    if <(Level) = [6]> then\n        stop [this script v]\n    end\nend\n\nwhen I receive [controls v]\nset [ghost v] effect to (100)\nrepeat until <key (q v) pressed?>\n    set volume to (0) %\nend\nif <key (q v) pressed?> then\n    set volume to (100) %\nend\n\nwhen [q v] key pressed\nwait (0.5) seconds\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\n\n@Start Menu//Controls\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to [back v] layer\n\nwhen I receive [controls v]\nrepeat (25)\n    change [ghost v] effect by (-4)\nend\n\nwhen [q v] key pressed\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\n@TB\n\nwhen flag clicked\nset [ghost v] effect to (100)\n\n@Detector\n\nwhen flag clicked\ngo to [front v] layer\nhide\nset [faved___ v] to [0]\nset [loved__ v] to [0]\nset [clone id v] to [0]\ncreate clone of (_myself_ v)\nwait (0.2) seconds\nset [clone id v] to [1]\ncreate clone of (_myself_ v)\nwait until <<(LOVED__) = [1]> and <(FAVED___) = [1]>>\nwait (1) seconds\nshow\ngo to x: (0) y: (50)\nreset timer\nswitch costume to (pick random (1) to (4))\nset [ghost v] effect to (100)\nrepeat until <(timer) > [3.5]>\n    change y by ((y position) / (-15))\n    change [ghost v] effect by (-3)\nend\nreset timer\nrepeat until <(timer) > [3.5]>\n    change y by (((y position) - (-100)) / (-15))\n    change [ghost v] effect by (10)\nend\n\nwhen I start as a clone\nif <(clone id) = [0]> then\n    go to x: (-15) y: (0)\n    set [loved__ v] to [0]\n    switch costume to (love v)\n    forever\n        set [love? v] to <touching (mouse-pointer v)?>\n        if <touching (mouse-pointer v)?> then\n            set [loved__ v] to [1]\n        end\n    end\nend\nif <(clone id) = [1]> then\n    go to x: (0) y: (0)\n    switch costume to (fave v)\n    set [faved___ v] to [0]\n    forever\n        set [fav v] to <touching (mouse-pointer v)?>\n        if <touching (mouse-pointer v)?> then\n            set [faved___ v] to [1]\n        end\n    end\nend\n\n@Win\n\nwhen flag clicked\nhide\ngo to [back v] layer\nforever\n    if <(Level) = [6]> then\n        show\n        set [x v] to (pick random (-10) to (10))\n        set [y v] to (pick random (-10) to (10))\n        set [size v] to (pick random (90) to (120))\n        repeat (10)\n            change x by (((x) - (x position)) / (pick random (3) to (10)))\n            change y by (((y) - (y position)) / (pick random (3) to (10)))\n            change size by (((size) - (size)) / (pick random (3) to (10)))\n        end\n    else\n        hide\n    end\nend\n\n@TIME\n\nwhen I receive [start v]\ngo to [front v] layer\nshow\nforever\n    cloneCostume costume: (Time) xPos: [-210] yPos: [146] lineSpace: [0.124]\n    set [oldscore v] to (Time)\n    wait until <not <(oldScore) = (Time)>>\nend\n\nwhen flag clicked\nhide\n\ndefine cloneCostume costume: (costume) xPos: (xpos) yPos: (ypos) lineSpace: (linespace)\nbroadcast (deleteClones v)\ngo to x: (xpos) y: (ypos)\nset [# v] to [1]\nrepeat (length of (costume))\n    look color: [-20] brightness: [10] size: [250]\n    switch costume to (letter (#) of (costume))\n    create clone of (_myself_ v)\n    change x by ((linespace) * (size))\n    change [# v] by (1)\nend\nhide\n\ndefine look color: (color) brightness: (brightness) size: (size)\nclear graphic effects\nset [color v] effect to (color)\nset [brightness v] effect to (brightness)\nset size to ((size) + (10)) %\n\nwhen I receive [deleteclones v]\ndelete this clone\n\nwhen I start as a clone\nforever\n    show\nend\n\nwhen [p v] key pressed\nhide\nstop [other scripts in sprite v]\nshow\ngo to x: (-195) y: (160)\nswitch costume to (. v)\nset size to (240) %\n\n