Physics Platformer + Editor

Instructions: This is not a normal platformer. This platformer has real physics. You can't move around when you're in the air, only on the ground.\n\n !! Please try the editor, it gives you full customization over music, background, physics, style, and so much more !!\n\nArrow Keys to move and to scroll in the editor.\n\nThe best levels people make will be added to the game.\n\nGreen is ground\nBrown is Mud\nBlue is Ice\nYellow is an accelerator\nPurple is a bounce pad\nRed is lava\n\nShare your levels here:\nhttps://scratch.mit.edu/discuss/topic/376811/\n\nMusic from Megaman 7

@Stage\n\nwhen flag clicked\nerase all\nbroadcast (menu v)\n\nwhen I receive [game v]\nswitch backdrop to (backdrop1 v)\n\nwhen I receive [menu v]\nset [music v] to [2]\nerase all\nset [brightness v] effect to (10)\nswitch backdrop to (backdrop2 v)\nrepeat (10)\n    change [brightness v] effect by (-1)\nend\n\nwhen I receive [editor v]\nswitch backdrop to (backdrop1 v)\n\nwhen flag clicked\nset [music v] to [2]\nforever\n    play sound (Music) until done\nend\n\nwhen flag clicked\nset [music v] to [2]\nforever\n    set volume to (100) %\n    set [current soundtrack v] to (Music)\n    wait until <not <(Music) = (Current Soundtrack)>>\n    repeat (10)\n        change volume by (-10)\n    end\n    stop all sounds\n    repeat (10)\n        change volume by (10)\n    end\nend\n\nwhen I receive [get load code v]\nask [Enter a Save Code \(leave blank to cancel\):] and wait\nset [save code v] to (answer)\n\nswitch backdrop to (thumbnail v)\n\n@pen\n\nwhen flag clicked\nhide\n\ndefine Generate Level\nset [ending goal v] to [1700]\ndelete all of [level v]\nAdd Block [1] from [-100] [-100] to [100] [-50] w/ friction [0.9] and w/ bounce [0]\nAdd Block [1] from [100] [-100] to [200] [0] w/ friction [0.9] and w/ bounce [0]\nAdd Block [4] from [205] [-100] to [345] [-50] w/ friction [0.5] and w/ bounce [0]\nAdd Block [1] from [350] [-100] to [450] [0] w/ friction [0.9] and w/ bounce [0]\nAdd Block [5] from [455] [-25] to [795] [0] w/ friction [0.95] and w/ bounce [0]\nAdd Block [1] from [800] [-100] to [900] [25] w/ friction [0.9] and w/ bounce [0]\nAdd Block [1] from [900] [-100] to [1000] [75] w/ friction [0.9] and w/ bounce [0]\nAdd Block [1] from [1000] [-100] to [1150] [0] w/ friction [0.9] and w/ bounce [0]\nAdd Block [1] from [1225] [-50] to [1400] [0] w/ friction [0.9] and w/ bounce [0]\nAdd Block [6] from [1155] [-25] to [1220] [0] w/ friction [1.5] and w/ bounce [0]\nAdd Block [1] from [1405] [40] to [1445] [50] w/ friction [0.9] and w/ bounce [0]\nAdd Block [3] from [1405] [-50] to [1445] [35] w/ friction [0.9] and w/ bounce [1]\nAdd Block [1] from [1475] [0] to [1700] [50] w/ friction [0.9] and w/ bounce [0]\nAdd Block [2] from [1575] [55] to [1600] [75] w/ friction [0.9] and w/ bounce [0]\n\ndefine Add Block (type) from (x) (y) to (x2) (y2) w/ friction (friction) and w/ bounce (bounce)\nadd (type) to [level v]\nadd (x) to [level v]\nadd (y) to [level v]\nadd (x2) to [level v]\nadd (y2) to [level v]\nadd (friction) to [level v]\nadd (bounce) to [level v]\n\ndefine Reset\nset [x v] to [0]\nset [y v] to [0]\nset [xv v] to [0]\nset [yv v] to [0]\nset [camera x v] to [0]\nset [camera y v] to [0]\nset [ground v] to [0]\nset camera\n\ndefine render\nerase all\nset pen size to (((Thickness) * (Zoom)) * ((Grid) * (2)))\ngrid\nset pen size to ((Thickness) * (Zoom))\nset pen color to (#000000)\nDraw Rect from ((X) + (Thickness)) ((Y) + (Thickness)) to ((X) + ((Width) - (Thickness))) ((Y) + ((Height) - (Thickness)))\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    Get Color (item (i) of [level v])\n    Draw Rect from (item ((i) + (1)) of [level v]) (item ((i) + (2)) of [level v]) to (item ((i) + (3)) of [level v]) (item ((i) + (4)) of [level v])\n    change [i v] by (7)\nend\n\ndefine Draw Rect from (x) (y) to (x2) (y2)\npen up\nGo to (x) (y)\npen down\nGo to (x) (y2)\nGo to (x2) (y2)\nGo to (x2) (y)\nGo to (x) (y)\npen up\n\ndefine Go to (x) (y)\ngo to x: (((x) - (Camera X)) * (Zoom)) y: (((y) - (Camera Y)) * (Zoom))\n\ndefine Get Color (color)\nif <(color) = [1]> then\n    set pen color to (#0ac300)\nend\nif <(color) = [2]> then\n    set pen color to (#ef0000)\nend\nif <(color) = [3]> then\n    set pen color to (#b100c3)\nend\nif <(color) = [4]> then\n    set pen color to (#b75a21)\nend\nif <(color) = [5]> then\n    set pen color to (#25ddff)\nend\nif <(color) = [6]> then\n    set pen color to (#ffd725)\nend\n\ndefine physics\nif <(ground) = [1]> then\n    if <key (left arrow v) pressed?> then\n        change [xv v] by (() - (Speed))\n    end\n    if <key (right arrow v) pressed?> then\n        change [xv v] by (Speed)\n    end\n    set [xv v] to ((xv) * (Friction))\nend\nset [xv v] to ((xv) * (Air Resistance))\nchange x by (round (xv))\nif <(ground) = [0]> then\n    change [yv v] by (Gravity)\nend\nif <(ground) = [1]> then\n    if <key (up arrow v) pressed?> then\n        set [yv v] to (Jump Height)\n    end\nend\nset [yv v] to ((yv) * (Air Resistance))\nchange y by (round (yv))\n\ndefine move camera\nchange [camera x v] by (round ((((X) + ((Width) / (2))) - (Camera X)) / (4)))\nchange [camera y v] by (round ((((Y) + ((Height) / (2))) - (Camera Y)) / (10)))\nif <(Camera X) < ((-240) + ((240) / (Zoom)))> then\n    set [camera x v] to ((-240) + ((240) / (Zoom)))\nend\nif <((Ending Goal) - ((240) / (Zoom))) < (Camera X)> then\n    set [camera x v] to ((Ending Goal) - ((240) / (Zoom)))\nend\nif <(Camera Y) < ((-180) + ((180) / (Zoom)))> then\n    set [camera y v] to ((-180) + ((180) / (Zoom)))\nend\n\ndefine change x by (xv)\nchange [x v] by (xv)\nCollisions\nrepeat until <(length of [collisions v]) = [0]>\n    if <[collisions v] contains [2]?> then\n        Reset\n    end\n    set [xv v] to ([floor v] of ((xv) * (() - (Bounce))) )\n    change [x v] by (() - (([abs v] of (xv) ) / (xv)))\n    Collisions\nend\n\ndefine Collisions\ndelete all of [collisions v]\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    if <<<((X) + (Width)) > (item ((i) + (1)) of [level v])> and <(item ((i) + (3)) of [level v]) > (X)>> and <<((Y) + (Height)) > (item ((i) + (2)) of [level v])> and <(item ((i) + (4)) of [level v]) > (Y)>>> then\n        add (item (i) of [level v]) to [collisions v]\n        set [friction v] to (item ((i) + (5)) of [level v])\n        set [bounce v] to (item ((i) + (6)) of [level v])\n    end\n    change [i v] by (7)\nend\n\ndefine change y by (yv)\nchange [y v] by (yv)\nset [ground v] to [0]\nCollisions\nset [i v] to [1]\nrepeat until <(length of [collisions v]) = [0]>\n    if <(yv) < [0]> then\n        set [ground v] to [1]\n    end\n    if <(([abs v] of (Gravity) ) * (2)) < ([abs v] of (yv) )> then\n        set [yv v] to ([floor v] of ((yv) * (() - (Bounce))) )\n    end\n    if <[collisions v] contains [2]?> then\n        Reset\n    end\n    change [y v] by (() - (([abs v] of (yv) ) / (yv)))\n    Collisions\n    change [i v] by (1)\nend\n\ndefine grid\npen up\nset pen color to (#e8e8e8)\nset [i v] to [-960]\nrepeat ((26) / (Zoom))\n    go to x: ((i) - ((((Camera X) * (Grid)) mod (48)) * (Zoom))) y: ((-240) - ((((Camera Y) * (Grid)) mod (48)) * (Zoom)))\n    pen down\n    go to x: ((x position) + (720)) y: ((y position) + (720))\n    pen up\n    go to x: ((x position) + (0)) y: ((y position) + (-720))\n    pen down\n    go to x: ((x position) + (-720)) y: ((y position) + (720))\n    pen up\n    change [i v] by ((48) * (Zoom))\nend\n\nset [zoom v] to [2]\n\ndefine death/win\nif <((Y) + (Height)) < [-180]> then\n    Reset\nend\nif <(Ending Goal) < (X)> then\n    if <(Editor Selected?) = [0]> then\n        stop [other scripts in sprite v]\n        Win Animation\n        broadcast (menu v)\n        stop [this script v]\n    else\n        Win Animation\n        Reset\n    end\nend\n\ndefine set camera\nchange [camera x v] by (round ((((X) + ((Width) / (2))) - (Camera X)) / (1)))\nchange [camera y v] by (round ((((Y) + ((Height) / (2))) - (Camera Y)) / (1)))\nif <(Camera X) < ((-240) + ((240) / (Zoom)))> then\n    set [camera x v] to ((-240) + ((240) / (Zoom)))\nend\nif <((Ending Goal) - ((240) / (Zoom))) < (Camera X)> then\n    set [camera x v] to ((Ending Goal) - ((240) / (Zoom)))\nend\nif <(Camera Y) < ((-180) + ((180) / (Zoom)))> then\n    set [camera y v] to ((-180) + ((180) / (Zoom)))\nend\n\ndefine Win Animation\nchange [x v] by (20)\nrender\nset pen color to (#f3f3f3)\nset pen size to (6)\nset [xv v] to [5]\ngo to x: (-245) y: (-180)\nrepeat until <(x position) > [240]>\n    change x by (xv)\n    set y to (-180)\n    pen down\n    set y to (180)\n    pen up\n    change [xv v] by (1)\n    set pen size to ((xv) + (1))\nend\nwait (0.5) seconds\nset pen color to (#ffffff)\nset pen size to (6)\nset [xv v] to [5]\ngo to x: (-245) y: (-180)\nrepeat until <(x position) > [240]>\n    change x by (xv)\n    set y to (-180)\n    pen down\n    set y to (180)\n    pen up\n    change [xv v] by (1)\n    set pen size to ((xv) + (1))\nend\nwait (0.5) seconds\n\nWin Animation\n\nerase all\n\nwhen I receive [menu v]\nset [playing? v] to [0]\n\nwhen I receive [game v]\nset [editor selected? v] to [0]\nswitch costume to (costume1 v)\nset size to (1000) %\nswitch costume to (costume2 v)\nhide\nGenerate Level\nFull Reset\nReset\nset [playing? v] to [1]\nforever\n    if <(Playing?) = [1]> then\n        render\n        physics\n        move camera\n        death/win\n    else\n        stop [this script v]\n    end\nend\n\nwhen I receive [editor v]\nset [editor selected? v] to [1]\nswitch costume to (costume1 v)\nset size to (1000) %\nswitch costume to (costume2 v)\nhide\nGenerate Editor Level\nFull Reset\nReset\nset [block # v] to [0]\nset [playing? v] to [0]\nforever\n    if <(Playing?) = [1]> then\n        Collision /w refresh\n        if <(length of [collisions v]) > [0]> then\n            set [playing? v] to [0]\n        else\n            physics\n            move camera\n            death/win\n            render\n        end\n    else\n        Editor controls\n        render\n        render editor\n    end\nend\n\ndefine Generate Editor Level\nset [ending goal v] to [720]\ndelete all of [level v]\nAdd Block [1] from [-100] [-100] to [100] [-50] w/ friction [0.9] and w/ bounce [0]\n\ndefine Editor controls\nEditor Camera\nif <<mouse down?> and <<<[-165] < (mouse x)> and <(mouse x) < [160]>> and <not <<[-115] > (mouse y)> and <(Menu #) > [0]>>>>> then\n    if <(mouse down?) = [0]> then\n        if <(Selected Block) > [0]> then\n            if <(Selected Block) = [1]> then\n                Add Block [1] from (((mouse x) / (Zoom)) + (Camera X)) (((mouse y) / (Zoom)) + (Camera Y)) to ((((mouse x) / (Zoom)) + (Camera X)) + (50)) ((((mouse y) / (Zoom)) + (Camera Y)) + (25)) w/ friction [0.9] and w/ bounce [0]\n            end\n            if <(Selected Block) = [2]> then\n                Add Block [2] from (((mouse x) / (Zoom)) + (Camera X)) (((mouse y) / (Zoom)) + (Camera Y)) to ((((mouse x) / (Zoom)) + (Camera X)) + (50)) ((((mouse y) / (Zoom)) + (Camera Y)) + (25)) w/ friction [0.9] and w/ bounce [0]\n            end\n            if <(Selected Block) = [3]> then\n                Add Block [3] from (((mouse x) / (Zoom)) + (Camera X)) (((mouse y) / (Zoom)) + (Camera Y)) to ((((mouse x) / (Zoom)) + (Camera X)) + (50)) ((((mouse y) / (Zoom)) + (Camera Y)) + (25)) w/ friction [0.9] and w/ bounce [1]\n            end\n            if <(Selected Block) = [4]> then\n                Add Block [4] from (((mouse x) / (Zoom)) + (Camera X)) (((mouse y) / (Zoom)) + (Camera Y)) to ((((mouse x) / (Zoom)) + (Camera X)) + (50)) ((((mouse y) / (Zoom)) + (Camera Y)) + (25)) w/ friction [0.5] and w/ bounce [0]\n            end\n            if <(Selected Block) = [5]> then\n                Add Block [5] from (((mouse x) / (Zoom)) + (Camera X)) (((mouse y) / (Zoom)) + (Camera Y)) to ((((mouse x) / (Zoom)) + (Camera X)) + (50)) ((((mouse y) / (Zoom)) + (Camera Y)) + (25)) w/ friction [0.95] and w/ bounce [0]\n            end\n            if <(Selected Block) = [6]> then\n                Add Block [6] from (((mouse x) / (Zoom)) + (Camera X)) (((mouse y) / (Zoom)) + (Camera Y)) to ((((mouse x) / (Zoom)) + (Camera X)) + (50)) ((((mouse y) / (Zoom)) + (Camera Y)) + (25)) w/ friction [1.5] and w/ bounce [0]\n            end\n            Collisions\n            if <(length of [collisions v]) > [0]> then\n                repeat (7)\n                    delete (length of [level v]) of [level v]\n                end\n            else\n                set [block # v] to ((length of [level v]) - (6))\n                set [selected block v] to [0]\n            end\n        else\n            set [block # v] to [0]\n            set [menu # v] to [0]\n            Click Blocks\n        end\n        set [mouse down? v] to [1]\n    else\n        if <(Block #) > [0]> then\n            replace item ((Block #) + (3)) of [level v] with ((round ((((mouse x) / (Zoom)) + (Camera X)) + ((item ((Block #) + (3)) of [level v]) - (item ((Block #) + (1)) of [level v])))) - (round (Click x)))\n            replace item ((Block #) + (4)) of [level v] with ((round ((((mouse y) / (Zoom)) + (Camera Y)) + ((item ((Block #) + (4)) of [level v]) - (item ((Block #) + (2)) of [level v])))) - (round (Click y)))\n            replace item ((Block #) + (1)) of [level v] with ((round (((mouse x) / (Zoom)) + (Camera X))) - (round (Click x)))\n            replace item ((Block #) + (2)) of [level v] with ((round (((mouse y) / (Zoom)) + (Camera Y))) - (round (Click y)))\n        else\n            if <<(mouse x) > ((((Ending Goal) - (Camera X)) * (Zoom)) - (15))> and <((((Ending Goal) - (Camera X)) * (Zoom)) - (-15)) > (mouse x)>> then\n                set [ending goal v] to (((mouse x) / (Zoom)) + (Camera X))\n                if <(Ending Goal) < [120]> then\n                    set [ending goal v] to [120]\n                end\n            end\n        end\n    end\nelse\n    set [mouse down? v] to [0]\nend\nif <(Block #) > [0]> then\n    set [menu # v] to ((item (Block #) of [level v]) + (3))\n    if <mouse down?> then\n        broadcast (Setup Menu B v)\n    end\nend\n\ndefine render editor\nGo to (Ending Goal) [0]\nset y to (-180)\nif <<(mouse x) > ((((Ending Goal) - (Camera X)) * (Zoom)) - (15))> and <((((Ending Goal) - (Camera X)) * (Zoom)) - (-15)) > (mouse x)>> then\n    set pen color to (#b5b5b5)\nelse\n    set pen color to (#808080)\nend\nset pen size to (20)\npen down\nset y to (180)\npen up\nif <(Selected Block) > [0]> then\n    set pen size to ((Thickness) * (Zoom))\n    Get Color (Selected Block)\n    set pen (transparency v) to (75)\n    Draw Rect from (((mouse x) / (Zoom)) + (Camera X)) (((mouse y) / (Zoom)) + (Camera Y)) to ((((mouse x) / (Zoom)) + (Camera X)) + (50)) ((((mouse y) / (Zoom)) + (Camera Y)) + (25))\n    set [block # v] to [0]\nend\nif <(Block #) > [0]> then\n    set pen size to (1)\n    set pen color to (#000000)\n    set pen (transparency v) to (50)\n    Draw Rect from (item ((Block #) + (1)) of [level v]) (item ((Block #) + (2)) of [level v]) to (item ((Block #) + (3)) of [level v]) (item ((Block #) + (4)) of [level v])\nend\n\ndefine Editor Camera\nif <key (left arrow v) pressed?> then\n    change [camera x v] by (-8)\nend\nif <key (right arrow v) pressed?> then\n    change [camera x v] by (8)\nend\nif <key (down arrow v) pressed?> then\n    change [camera y v] by (-8)\nend\nif <key (up arrow v) pressed?> then\n    change [camera y v] by (8)\nend\nif <(Camera X) < ((-240) + ((240) / (Zoom)))> then\n    set [camera x v] to ((-240) + ((240) / (Zoom)))\nend\nif <(Camera Y) < ((-180) + ((180) / (Zoom)))> then\n    set [camera y v] to ((-180) + ((180) / (Zoom)))\nend\n\nwhen I receive [menu v]\nstop [other scripts in sprite v]\n\nwhen I receive [back to edit v]\nset [block # v] to [0]\nset [menu # v] to [0]\nReset\n\ndefine Full Reset\nset [thickness v] to [4]\nset [zoom v] to [1]\nset [jump height v] to [15]\nset [air resistance v] to [0.95]\nset [speed v] to [2]\nset [gravity v] to [-1]\nset [height v] to [40]\nset [width v] to [40]\nset [grid v] to [0.5]\nset [music v] to [1]\n\ndefine Click Blocks\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    if <<(((mouse x) / (Zoom)) + (Camera X)) > ((item ((i) + (1)) of [level v]) - ((Thickness) / (2)))> and <(((mouse x) / (Zoom)) + (Camera X)) < ((item ((i) + (3)) of [level v]) + ((Thickness) / (2)))>> then\n        if <<(((mouse y) / (Zoom)) + (Camera Y)) > ((item ((i) + (2)) of [level v]) - ((Thickness) / (2)))> and <(((mouse y) / (Zoom)) + (Camera Y)) < ((item ((i) + (4)) of [level v]) + ((Thickness) / (2)))>> then\n            set [block # v] to (i)\n            set [click x v] to ((((mouse x) / (Zoom)) + (Camera X)) - (item ((i) + (1)) of [level v]))\n            set [click y v] to ((((mouse y) / (Zoom)) + (Camera Y)) - (item ((i) + (2)) of [level v]))\n        end\n    end\n    change [i v] by (7)\nend\n\ndefine Collision /w refresh\nCollisions\n\n@editor\n\nwhen flag clicked\nhide\nhide Menu B\nshow list [save v]\n\nwhen I receive [editor v]\nGenerate Clones\n\nwhen I start as a clone\nset [selected block v] to [0]\nset [menu # v] to [0]\nif <(costume [number v]) < [8]> then\n    go to x: (30) y: (0)\n    set [ghost v] effect to (100)\n    show\n    repeat (10)\n        change x by (-3)\n        change [ghost v] effect by (-10)\n    end\nelse\n    if <(costume [number v]) < [16]> then\n        go to x: (-30) y: (0)\n        set [ghost v] effect to (100)\n        show\n        repeat (10)\n            change x by (3)\n            change [ghost v] effect by (-10)\n        end\n    else\n        go to x: (0) y: (0)\n    end\nend\nif <<(costume [number v]) = [1]> or <(costume [number v]) = [8]>> then\n    forever\n        if <(Playing?) = [1]> then\n            hide\n        else\n            show\n            go to [back v] layer\n        end\n    end\nelse\n    if <(costume [number v]) < [8]> then\n        forever\n            if <(Playing?) = [1]> then\n                hide\n            else\n                show\n                if <touching (mouse-pointer v)?> then\n                    set [fisheye v] effect to (-50)\n                    if <mouse down?> then\n                        set [selected block v] to ((costume [number v]) - (1))\n                    end\n                else\n                    set [fisheye v] effect to (0)\n                end\n            end\n        end\n    else\n        if <(costume [number v]) < [16]> then\n            forever\n                if <(Playing?) = [1]> then\n                    hide\n                else\n                    show\n                    if <<touching (mouse-pointer v)?> or <<(costume [number v]) < [12]> and <(Menu #) = ((costume [number v]) - (8))>>> then\n                        set [brightness v] effect to (25)\n                        if <<mouse down?> and <touching (mouse-pointer v)?>> then\n                            if <(costume [number v]) < [12]> then\n                                set [block # v] to [0]\n                                set [menu # v] to ((costume [number v]) - (8))\n                                Setup Menu B\n                            else\n                                if <(costume [number v]) = [12]> then\n                                    set [playing? v] to [1]\n                                else\n                                    if <(costume [number v]) = [13]> then\n                                        Save\n                                    else\n                                        if <(costume [number v]) = [14]> then\n                                            Load\n                                        else\n                                            broadcast (menu v)\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    else\n                        set [brightness v] effect to (0)\n                    end\n                end\n            end\n        else\n            if <(costume [number v]) = [16]> then\n                forever\n                    if <(Playing?) = [0]> then\n                        hide\n                    else\n                        show\n                        if <<touching (mouse-pointer v)?> or <(Menu #) = ((costume [number v]) - (8))>> then\n                            set [brightness v] effect to (25)\n                            if <mouse down?> then\n                                set [playing? v] to [0]\n                                broadcast (Back to edit v)\n                            end\n                        else\n                            set [brightness v] effect to (0)\n                        end\n                    end\n                end\n            else\n                set [old menu v] to [0]\n                set [old block # v] to [0]\n                forever\n                    if <(Playing?) = [1]> then\n                        hide Menu B\n                    else\n                        if <(Menu #) > [0]> then\n                            if <not <<(old menu) = (Menu #)> and <(old block #) = (Block #)>>> then\n                                Setup Menu B\n                                set [old block # v] to (Block #)\n                                set [old menu v] to (Menu #)\n                            end\n                            hide Menu B\n                            show\n                            switch costume to ((16) + (Menu #))\n                            if <(Menu #) > [4]> then\n                                switch costume to (block menu v)\n                            end\n                            if <(Menu #) = [1]> then\n                                if <(More) = [0]> then\n                                    show variable [jump height v]\n                                    show variable [speed v]\n                                    show variable [more v]\n                                else\n                                    show variable [height v]\n                                    show variable [width v]\n                                    show variable [more v]\n                                end\n                            end\n                            if <(Menu #) = [2]> then\n                                if <(More) = [0]> then\n                                    show variable [thickness v]\n                                    show variable [grid v]\n                                    show variable [more v]\n                                else\n                                    show variable [zoom v]\n                                    show variable [music v]\n                                    show variable [more v]\n                                end\n                            end\n                            if <(Menu #) = [3]> then\n                                show variable [air resistance v]\n                                show variable [gravity v]\n                                show variable [ending goal v]\n                            end\n                            if <<(Menu #) > [3]> and <(Block #) > [0]>> then\n                                show variable [pos v]\n                                show variable [width: v]\n                                show variable [height: v]\n                                replace item ((Block #) + (3)) of [level v] with ((item ((Block #) + (1)) of [level v]) + (Width:))\n                                replace item ((Block #) + (4)) of [level v] with ((item ((Block #) + (2)) of [level v]) + (Height:))\n                                if <<(mouse x) > [195]> and <(mouse y) < [-145]>> then\n                                    next costume\n                                    if <mouse down?> then\n                                        Delete Block #\n                                        set [block # v] to [0]\n                                        set [menu # v] to [0]\n                                    end\n                                end\n                                if <(Menu #) = [4]> then\n                                    show variable [friction \(1\): v]\n                                    replace item ((Block #) + (5)) of [level v] with (Friction \(1\):)\n                                end\n                                if <(Menu #) = [5]> then\n                                    show variable [friction \(1\): v]\n                                    replace item ((Block #) + (5)) of [level v] with (Friction \(1\):)\n                                end\n                                if <(Menu #) = [6]> then\n                                    show variable [bounce: v]\n                                    replace item ((Block #) + (6)) of [level v] with (Bounce:)\n                                end\n                                if <(Menu #) = [7]> then\n                                    show variable [friction \(2\): v]\n                                    replace item ((Block #) + (5)) of [level v] with (Friction \(2\):)\n                                end\n                                if <(Menu #) = [8]> then\n                                    show variable [friction \(3\): v]\n                                    replace item ((Block #) + (5)) of [level v] with (Friction \(3\):)\n                                end\n                                if <(Menu #) = [9]> then\n                                    show variable [friction \(4\): v]\n                                    replace item ((Block #) + (5)) of [level v] with (Friction \(4\):)\n                                end\n                            end\n                        else\n                            hide Menu B\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine Generate Clones\nswitch costume to (menu r v)\nrepeat (17)\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I receive [menu v]\ndelete this clone\n\ndefine hide Menu B\nhide\nhide variable [more v]\nhide variable [jump height v]\nhide variable [speed v]\nhide variable [height v]\nhide variable [width v]\nhide variable [thickness v]\nhide variable [grid v]\nhide variable [zoom v]\nhide variable [music v]\nhide variable [air resistance v]\nhide variable [gravity v]\nhide variable [ending goal v]\nhide variable [friction \(1\): v]\nhide variable [friction \(2\): v]\nhide variable [friction \(3\): v]\nhide variable [friction \(4\): v]\nhide variable [bounce: v]\nhide variable [width: v]\nhide variable [height: v]\nhide variable [pos v]\n\ndefine Setup Menu B\nset [more v] to [0]\nif <(Block #) > [0]> then\n    set [friction \(1\): v] to (item ((Block #) + (5)) of [level v])\n    set [friction \(2\): v] to (item ((Block #) + (5)) of [level v])\n    set [friction \(3\): v] to (item ((Block #) + (5)) of [level v])\n    set [friction \(4\): v] to (item ((Block #) + (5)) of [level v])\n    set [bounce: v] to (item ((Block #) + (6)) of [level v])\n    set [width: v] to ((item ((Block #) + (3)) of [level v]) - (item ((Block #) + (1)) of [level v]))\n    set [height: v] to ((item ((Block #) + (4)) of [level v]) - (item ((Block #) + (2)) of [level v]))\n    set [pos v] to (join [\(] (join (item ((Block #) + (1)) of [level v]) (join [, ] (join (item ((Block #) + (2)) of [level v]) [\)]))))\nend\n\nwhen I receive [setup menu b v]\nSetup Menu B\n\ndefine Delete Block #\nrepeat (7)\n    delete (old block #) of [level v]\nend\n\ndefine Save\nset [save code v] to []\nAdd (Jump Height) to save code\nAdd (Speed) to save code\nAdd (Width) to save code\nAdd (Height) to save code\nAdd (Grid) to save code\nAdd (Thickness) to save code\nAdd (Zoom) to save code\nAdd (Music) to save code\nAdd (Gravity) to save code\nAdd (Air Resistance) to save code\nAdd (Ending Goal) to save code\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    set [j v] to [1]\n    repeat until <(j) > (length of (item (i) of [level v]))>\n        if <[numbers v] contains (letter (j) of (item (i) of [level v]))?> then\n            set [save code v] to (join (Save Code) (item (item # of (letter (j) of (item (i) of [level v])) in [numbers v]) of [letters v]))\n        else\n            set [save code v] to (join (Save Code) (letter (j) of (item (i) of [level v])))\n        end\n        change [j v] by (1)\n    end\n    set [save code v] to (join (Save Code) [\])\n    change [i v] by (1)\nend\ndelete all of [save v]\nadd [Triple Click at press ctr+c to Copy your Save Code] to [save v]\nadd (Save Code) to [save v]\nadd [Press Space To Close] to [save v]\nhide list [save v]\n\ndefine Load\nbroadcast (Get Load Code v) and wait\nif <not <(Save Code) = []>> then\n    Decode (Save Code)\n    set [camera x v] to [0]\n    set [camera y v] to [0]\n    set [playing? v] to [1]\nend\n\nwhen [space v] key pressed\nshow list [save v]\n\ndefine Decode (code)\ndelete all of [level v]\nset [k v] to [1]\nset [save code v] to []\nset [j v] to [1]\nrepeat (11)\n    repeat until <(letter (k) of (code)) = [\]>\n        set [save code v] to (join (Save Code) (letter (k) of (code)))\n        change [k v] by (1)\n    end\n    Set variable (j) to (Save Code)\n    set [save code v] to []\n    change [j v] by (1)\n    change [k v] by (1)\nend\nset [save code v] to []\nrepeat until <(k) > (length of (code))>\n    if <(letter (k) of (code)) = [\]> then\n        add (Save Code) to [level v]\n        set [save code v] to []\n    else\n        if <[letters v] contains (letter (k) of (code))?> then\n            set [save code v] to (join (Save Code) (item (item # of (letter (k) of (code)) in [letters v]) of [numbers v]))\n        else\n            set [save code v] to (join (Save Code) (letter (k) of (code)))\n        end\n        change [j v] by (1)\n    end\n    change [k v] by (1)\nend\n\nwhen I receive [menu v]\nhide\nhide Menu B\nshow list [save v]\n\ndefine Add (variable) to save code\nset [save code v] to (join (Save Code) (join (variable) [\]))\n\ndefine Set variable (num) to (var)\nif <(num) = [1]> then\n    set [jump height v] to (var)\nend\nif <(num) = [2]> then\n    set [speed v] to (var)\nend\nif <(num) = [3]> then\n    set [width v] to (var)\nend\nif <(num) = [4]> then\n    set [height v] to (var)\nend\nif <(num) = [5]> then\n    set [grid v] to (var)\nend\nif <(num) = [6]> then\n    set [thickness v] to (var)\nend\nif <(num) = [7]> then\n    set [zoom v] to (var)\nend\nif <(num) = [8]> then\n    set [music v] to (var)\nend\nif <(num) = [9]> then\n    set [gravity v] to (var)\nend\nif <(num) = [10]> then\n    set [air resistance v] to (var)\nend\nif <(num) = [11]> then\n    set [ending goal v] to (var)\nend\n\n@title\n\nwhen flag clicked\nhide\n\nwhen I receive [menu v]\nswitch costume to (title v)\ncreate clone of (_myself_ v)\nswitch costume to (play v)\ncreate clone of (_myself_ v)\nswitch costume to (edit v)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nset [ghost v] effect to (100)\nshow\ngo to x: (-380) y: (0)\nrepeat (20)\n    change x by ((x position) / (-5))\n    change [ghost v] effect by (-5)\nend\nset [ghost v] effect to (0)\ngo to x: (0) y: (0)\nif <(costume [number v]) > [1]> then\n    forever\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (30)\n            if <mouse down?> then\n                if <(costume [number v]) = [2]> then\n                    broadcast (Game v)\n                else\n                    wait until <not <mouse down?>>\n                    broadcast (Editor v)\n                end\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    end\nend\n\nwhen I receive [game v]\ndelete this clone\n\nwhen I receive [editor v]\ndelete this clone\n\n