Gravity Platformer Level Editor
@Stage\n\nwhen flag clicked\nforever\n    play sound [Galaxy v] until done\nend\n\n@pen\n\nwhen flag clicked\nset [level v] to [1]\nswitch costume to (costume2 v)\nset size to (5000) %\nswitch costume to (costume1 v)\nhide\npoint in direction (90)\nCreate Level (level)\nset [camera x v] to [0]\nset [camera y v] to [0]\nset [gravity v] to [1]\nset [x v] to [0]\nset [y v] to [0]\nset [yv v] to [0]\nset [mode v] to [1]\nshow list [save code v]\nforever\n    render\n    if <(Mode) = [1]> then\n        Edit\n    else\n        physics\n    end\nend\n\ndefine render\ngo to x: (0) y: (0)\nset [pen x v] to [0]\nset [pen y v] to [0]\npen up\nerase all\nset pen size to (5)\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    if <(item (i) of [level v]) = [1]> then\n        set pen color to (#11b900)\n    end\n    if <(item (i) of [level v]) = [2]> then\n        set pen color to (#ab0000)\n    end\n    if <(item (i) of [level v]) = [3]> then\n        set pen color to (#009dff)\n    end\n    if <(item (i) of [level v]) = [4]> then\n        set pen color to (#ffd000)\n    end\n    if <<(item (i) of [level v]) > [4]> and <(item (i) of [level v]) < [9]>> then\n        set pen color to (#fa00ff)\n        if <(item (i) of [level v]) = [5]> then\n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (4)) of [level v]) + (-15)) <>\n            pen down\n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (2)) of [level v]) + (15)) \n            Go To ((item ((i) + (1)) of [level v]) + (15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) \n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (2)) of [level v]) + (15)) \n            Go To ((item ((i) + (3)) of [level v]) + (-15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) \n        end\n        if <(item (i) of [level v]) = [6]> then\n            Go To ((item ((i) + (3)) of [level v]) + (-15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) <>\n            pen down\n            Go To ((item ((i) + (1)) of [level v]) + (15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) \n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (2)) of [level v]) + (15)) \n            Go To ((item ((i) + (1)) of [level v]) + (15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) \n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (4)) of [level v]) + (-15)) \n        end\n        if <(item (i) of [level v]) = [7]> then\n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (2)) of [level v]) + (15)) <>\n            pen down\n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (4)) of [level v]) + (-15)) \n            Go To ((item ((i) + (1)) of [level v]) + (15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) \n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (4)) of [level v]) + (-15)) \n            Go To ((item ((i) + (3)) of [level v]) + (-15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) \n        end\n        if <(item (i) of [level v]) = [8]> then\n            Go To ((item ((i) + (1)) of [level v]) + (15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) <>\n            pen down\n            Go To ((item ((i) + (3)) of [level v]) + (-15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) \n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (2)) of [level v]) + (15)) \n            Go To ((item ((i) + (3)) of [level v]) + (-15)) (((item ((i) + (2)) of [level v]) + (item ((i) + (4)) of [level v])) / (2)) \n            Go To (((item ((i) + (1)) of [level v]) + (item ((i) + (3)) of [level v])) / (2)) ((item ((i) + (4)) of [level v]) + (-15)) \n        end\n    end\n    change [i v] by (1)\n    Draw Rect from ((item (i) of [level v]) - (-5)) ((item ((i) + (1)) of [level v]) - (-5)) to ((item ((i) + (2)) of [level v]) + (-5)) ((item ((i) + (3)) of [level v]) + (-5)) edit? <<(Mode) = [1]> and <(Edit Type) = [10]>>\n    change [i v] by (4)\nend\nset pen color to (#fe863d)\nDraw Rect from (x) (y) to ((x) + (25)) ((y) + (25)) edit? <>\n\ndefine Go To (x) (y) <diagonal>\nif <diagonal> then\n    pen up\nend\nChange X by (((x) - (Camera X)) - (pen x))\nChange Y by (((y) - (Camera Y)) - (pen y))\nif <diagonal> then\n    set [new x v] to (x position)\n    set [new y v] to (y position)\n    Change X by (() - (((x) - (Camera X)) - (pen x)))\n    Change Y by (() - (((y) - (Camera Y)) - (pen y)))\n    pen down\n    go to x: (new x) y: (new y)\nend\nset [pen x v] to ((x) - (Camera X))\nset [pen y v] to ((y) - (Camera Y))\n\ndefine Change X by (x)\nmove (x) steps\n\ndefine Change Y by (y)\nturn left (90) degrees\nmove (y) steps\nturn right (90) degrees\n\ndefine Create Level (level)\ndelete all of [level v]\nAdd Block [1] from [-50] [-50] to [50] [-25]\n\ndefine Add Block (type) from (x) (y) to (x2) (y2)\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]\n\ndefine Draw Rect from (x1) (y1) to (x2) (y2) edit? <edit?>\npen up\nGo To (x1) (y1) <>\npen down\nGo To (x2) (y1) <>\nGo To (x2) (y2) <>\nGo To (x1) (y2) <>\nGo To (x1) (y1) <>\npen up\nif <edit?> then\n    set pen color to (#cecece)\n    set pen (transparency v) to (25)\n    set pen size to (12)\n    Go To (x1) (y1) <>\n    pen down\n    pen up\n    Go To (x2) (y2) <>\n    pen down\n    pen up\n    set pen size to (5)\nend\n\ndefine physics\nif <key (left arrow v) pressed?> then\n    Move X by [-8]\nend\nif <key (right arrow v) pressed?> then\n    Move X by [8]\nend\nchange [yv v] by (-2)\nMove Y by (yv)\nif <<key (up arrow v) pressed?> and <(can jump) = [1]>> then\n    set [yv v] to [18]\nend\nGet Collisions\nif <[collisions v] contains [3]?> then\n    set [yv v] to [25]\nend\nGet Collisions\nif <[collisions v] contains [5]?> then\n    set [gravity v] to [1]\nend\nif <[collisions v] contains [6]?> then\n    set [gravity v] to [2]\nend\nif <[collisions v] contains [7]?> then\n    set [gravity v] to [3]\nend\nif <[collisions v] contains [8]?> then\n    set [gravity v] to [4]\nend\nif <<<<(x) < [-240]> or <(y) < [-180]>> or <<(x) > [4560]> or <(y) > [3420]>>> or <[collisions v] contains [2]?>> then\n    Die\nend\nif <[collisions v] contains [4]?> then\n    broadcast (You Won v)\n    Die\nend\nif <<(Gravity) = [2]> or <(Gravity) = [4]>> then\n    change [camera x v] by (round (((x) - (Camera X)) / (10)))\n    set [camera y v] to (y)\nelse\n    set [camera x v] to (x)\n    change [camera y v] by (round (((y) - (Camera Y)) / (10)))\nend\nset [camera x v] to (x)\nset [camera y v] to (y)\nif <(Camera X) < [0]> then\n    set [camera x v] to [0]\nend\nif <(Camera Y) < [0]> then\n    set [camera y v] to [0]\nend\n\ndefine Move X by (xv)\nif <(Gravity) = [1]> then\n    change [x v] by (xv)\nend\nif <(Gravity) = [2]> then\n    change [y v] by (() - (xv))\nend\nif <(Gravity) = [3]> then\n    change [x v] by (() - (xv))\nend\nif <(Gravity) = [4]> then\n    change [y v] by (xv)\nend\nGet Collisions\nrepeat until <not <[collisions v] contains [1]?>>\n    Get Collisions\n    if <(Gravity) = [1]> then\n        change [x v] by (() - ((xv) / ([abs v] of (xv) )))\n    end\n    if <(Gravity) = [2]> then\n        change [y v] by ((xv) / ([abs v] of (xv) ))\n    end\n    if <(Gravity) = [3]> then\n        change [x v] by ((xv) / ([abs v] of (xv) ))\n    end\n    if <(Gravity) = [4]> then\n        change [y v] by (() - ((xv) / ([abs v] of (xv) )))\n    end\nend\n\ndefine Move Y by (yv)\nset [can jump v] to [0]\nif <(Gravity) = [1]> then\n    change [y v] by (yv)\nend\nif <(Gravity) = [2]> then\n    change [x v] by (yv)\nend\nif <(Gravity) = [3]> then\n    change [y v] by (() - (yv))\nend\nif <(Gravity) = [4]> then\n    change [x v] by (() - (yv))\nend\nGet Collisions\nrepeat until <not <[collisions v] contains [1]?>>\n    set [yv v] to [0]\n    if <(yv) < [0]> then\n        set [can jump v] to [1]\n    end\n    Get Collisions\n    if <(Gravity) = [1]> then\n        change [y v] by (() - ((yv) / ([abs v] of (yv) )))\n    end\n    if <(Gravity) = [2]> then\n        change [x v] by (() - ((yv) / ([abs v] of (yv) )))\n    end\n    if <(Gravity) = [3]> then\n        change [y v] by ((yv) / ([abs v] of (yv) ))\n    end\n    if <(Gravity) = [4]> then\n        change [x v] by ((yv) / ([abs v] of (yv) ))\n    end\nend\n\ndefine Get Collisions\ndelete all of [collisions v]\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    change [i v] by (1)\n    if <((x) + (25)) > (item (i) of [level v])> then\n        change [i v] by (1)\n        if <((y) + (25)) > (item (i) of [level v])> then\n            change [i v] by (1)\n            if <(item (i) of [level v]) > (x)> then\n                change [i v] by (1)\n                if <(item (i) of [level v]) > (y)> then\n                    change [i v] by (-4)\n                    add (item (i) of [level v]) to [collisions v]\n                    change [i v] by (4)\n                end\n                change [i v] by (-1)\n            end\n            change [i v] by (-1)\n        end\n        change [i v] by (-1)\n    end\n    change [i v] by (4)\nend\n\ndefine Die\nset [camera x v] to [0]\nset [camera y v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nset [yv v] to [0]\nset [gravity v] to [1]\npoint in direction (90)\n\ndefine Win\nchange [level v] by (1)\nCreate Level (level)\nset [gravity v] to [1]\nset [camera x v] to [0]\nset [camera y v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nset [yv v] to [0]\npoint in direction (90)\n\nWin\n\nCreate Level [2]\n\nCreate Level [3]\n\ndefine Edit\nif <<(mouse y) < [130]> and <<(mouse x) < [120]> or <[-95] < (mouse y)>>> then\n    if <[9] > (Edit Type)> then\n        pen up\n        if <(Edit Type) = [1]> then\n            set pen color to (#11b900)\n        end\n        if <(Edit Type) = [2]> then\n            set pen color to (#ab0000)\n        end\n        if <(Edit Type) = [3]> then\n            set pen color to (#009dff)\n        end\n        if <(Edit Type) = [4]> then\n            set pen color to (#ffd000)\n        end\n        if <<(Edit Type) > [4]> and <(Edit Type) < [9]>> then\n            set pen color to (#fa00ff)\n        end\n        set pen (transparency v) to (75)\n        Draw Rect from ((mouse x) + (Camera X)) ((mouse y) + (Camera Y)) to (((mouse x) + (Camera X)) + (50)) (((mouse y) + (Camera Y)) + (50)) edit? <>\n        if <mouse down?> then\n            wait until <not <mouse down?>>\n            Add Block (Edit Type) from ((mouse x) + (Camera X)) ((mouse y) + (Camera Y)) to (((mouse x) + (Camera X)) + (50)) (((mouse y) + (Camera Y)) + (50))\n        end\n    end\n    if <(Edit Type) = [9]> then\n        if <mouse down?> then\n            Try to Delete\n        end\n    end\n    if <(Edit Type) = [10]> then\n        if <mouse down?> then\n            Try to Select\n        else\n            set [selected block v] to [0]\n        end\n        if <(Selected Block) > [0]> then\n            set [editor x v] to ((mouse x) + (Camera X))\n            set [editor y v] to ((mouse y) + (Camera Y))\n            replace item (Selected Block) of [level v] with (editor x)\n            replace item ((Selected Block) + (1)) of [level v] with (editor y)\n            Fix Blocks\n        end\n    end\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [camera x v] by (-10)\nend\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [camera x v] by (10)\nend\nif <[0] > (Camera X)> then\n    set [camera x v] to [0]\nend\nif <<key (down arrow v) pressed?> or <key (s v) pressed?>> then\n    change [camera y v] by (-10)\nend\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    change [camera y v] by (10)\nend\nif <[0] > (Camera Y)> then\n    set [camera y v] to [0]\nend\n\ndefine Try to Delete\nset [editor x v] to ((mouse x) + (Camera X))\nset [editor y v] to ((mouse y) + (Camera Y))\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    change [i v] by (1)\n    if <(editor x) > (item (i) of [level v])> then\n        change [i v] by (1)\n        if <(editor y) > (item (i) of [level v])> then\n            change [i v] by (1)\n            if <(item (i) of [level v]) > (editor x)> then\n                change [i v] by (1)\n                if <(item (i) of [level v]) > (editor y)> then\n                    change [i v] by (-4)\n                    repeat (5)\n                        delete (i) of [level v]\n                    end\n                    change [i v] by (4)\n                end\n                change [i v] by (-1)\n            end\n            change [i v] by (-1)\n        end\n        change [i v] by (-1)\n    end\n    change [i v] by (4)\nend\n\ndefine Try to Select\nset [editor x v] to ((mouse x) + (Camera X))\nset [editor y v] to ((mouse y) + (Camera Y))\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    change [i v] by (1)\n    if <(editor x) > ((item (i) of [level v]) - (9))> then\n        change [i v] by (1)\n        if <(editor y) > ((item (i) of [level v]) - (9))> then\n            change [i v] by (-1)\n            if <((item (i) of [level v]) + (9)) > (editor x)> then\n                change [i v] by (1)\n                if <((item (i) of [level v]) + (9)) > (editor y)> then\n                    change [i v] by (-1)\n                    set [selected block v] to (i)\n                    change [i v] by (1)\n                end\n                change [i v] by (-1)\n            end\n            change [i v] by (1)\n        end\n        change [i v] by (-1)\n    end\n    change [i v] by (2)\n    if <(editor x) > ((item (i) of [level v]) - (9))> then\n        change [i v] by (1)\n        if <(editor y) > ((item (i) of [level v]) - (9))> then\n            change [i v] by (-1)\n            if <((item (i) of [level v]) + (9)) > (editor x)> then\n                change [i v] by (1)\n                if <((item (i) of [level v]) + (9)) > (editor y)> then\n                    change [i v] by (-1)\n                    set [selected block v] to (i)\n                    change [i v] by (1)\n                end\n                change [i v] by (-1)\n            end\n            change [i v] by (1)\n        end\n        change [i v] by (-1)\n    end\n    change [i v] by (2)\nend\n\ndefine Fix Blocks\nset [i v] to [1]\nrepeat until <(i) > (length of [level v])>\n    change [i v] by (1)\n    if <((Selected Block) mod (5)) = [2]> then\n        if <(item (i) of [level v]) > ((item ((i) + (2)) of [level v]) - (20))> then\n            replace item (i) of [level v] with ((item ((i) + (2)) of [level v]) - (20))\n        end\n        change [i v] by (1)\n        if <(item (i) of [level v]) > ((item ((i) + (2)) of [level v]) - (20))> then\n            replace item (i) of [level v] with ((item ((i) + (2)) of [level v]) - (20))\n        end\n        change [i v] by (-1)\n    else\n        if <(item (i) of [level v]) > ((item ((i) + (2)) of [level v]) - (20))> then\n            replace item ((i) + (2)) of [level v] with ((item (i) of [level v]) + (20))\n        end\n        change [i v] by (1)\n        if <(item (i) of [level v]) > ((item ((i) + (2)) of [level v]) - (20))> then\n            replace item ((i) + (2)) of [level v] with ((item (i) of [level v]) + (20))\n        end\n        change [i v] by (-1)\n    end\n    change [i v] by (4)\nend\n\nwhen I receive [die v]\nDie\n\nwhen I receive [save level v]\ndelete all of [save code v]\nadd [Triple Click The Following Code And Press Ctr+c To Copy It] to [save code v]\nadd (Save Code) to [save code v]\nadd [\(Press Space To Close\)] to [save code v]\nhide list [save code v]\nwait until <key (space v) pressed?>\nshow list [save code v]\n\n@menu bar\n\nwhen flag clicked\ngo to [front v] layer\ngo to x: (0) y: (0)\nforever\n    if <(Mode) = [1]> then\n        show\n    else\n        hide\n    end\nend\n\n@menu buttons\n\nwhen flag clicked\ngo to x: (-15) y: (0)\nhide\nswitch costume to (costume1 v)\nset [edit type v] to [1]\nrepeat (11)\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I start as a clone\nshow\ngo to [front v] layer\nforever\n    if <<(costume [number v]) = [11]> or <(costume [number v]) = [12]>> then\n        show\n        if <(Mode) = [1]> then\n            switch costume to (costume11 v)\n        else\n            switch costume to (costume12 v)\n        end\n    else\n        if <(Mode) = [1]> then\n            show\n        else\n            hide\n        end\n    end\n    if <touching (mouse-pointer v)?> then\n        set [brightness v] effect to (10)\n        if <mouse down?> then\n            if <(costume [number v]) = [11]> then\n                broadcast (die v)\n                set [mode v] to [0]\n                wait until <not <mouse down?>>\n            else\n                if <(costume [number v]) = [12]> then\n                    broadcast (die v)\n                    set [mode v] to [1]\n                    wait until <not <mouse down?>>\n                else\n                    set [edit type v] to (costume [number v])\n                end\n            end\n        end\n    else\n        set [brightness v] effect to (0)\n    end\n    if <(costume [number v]) = (Edit Type)> then\n        set [brightness v] effect to (15)\n    end\nend\n\n@You Win\n\nwhen flag clicked\nhide\n\nwhen I receive [you won v]\ngo to x: (0) y: (-30)\nset [ghost v] effect to (100)\nshow\nrepeat (10)\n    change y by (3)\n    change [ghost v] effect by (-10)\nend\nwait (1) seconds\nrepeat (10)\n    change y by (-3)\n    change [ghost v] effect by (10)\nend\nhide\n\n@Save Engine\n\nwhen flag clicked\nforever\n    if <(Mode) = [1]> then\n        show\n        go to [front v] layer\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (25)\n            if <mouse down?> then\n                Save\n                broadcast (Save Level v) and wait\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    else\n        hide\n    end\nend\n\ndefine Save\nset [save code v] to []\nset [j v] to [0]\nrepeat (length of [level v])\n    change [j v] by (1)\n    set [save code v] to (join (Save Code) (join (item (j) of [level v]) [/]))\nend\n\n@Load EngineSave Engine2\n\nwhen flag clicked\nforever\n    if <(Mode) = [1]> then\n        show\n        go to [front v] layer\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (25)\n            if <mouse down?> then\n                hide\n                ask [Enter Save Code:] and wait\n                show\n                if <not <(answer) = []>> then\n                    Load (answer)\n                end\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    else\n        hide\n    end\nend\n\ndefine Load (code)\ndelete all of [level v]\nset [item v] to []\nset [j v] to [0]\nrepeat (length of (code))\n    change [j v] by (1)\n    if <(letter (j) of (code)) = [/]> then\n        add (Item) to [level v]\n        set [item v] to []\n    else\n        set [item v] to (join (Item) (letter (j) of (code)))\n    end\nend\n\n@Thumbnail\n\ngo to x: (0) y: (0)\ngo to [front v] layer\nshow\n\nwhen flag clicked\nhide\n\n
Play the Full Game Instead Please:\nhttps://scratch.mit.edu/projects/322427861/\n\nThe Full Game Includes 30 built in levels plus several other improvements in quality.\n\nCreate an amazing scrolling platformer with this new engine! Select one of 8 block types and click to place blocks, and use the mouse icon to resize them. Use the X to remove blocks, and click play to test your level.\n\nPress arrow keys to scroll in the editor, and press save/load level to save and load your levels!\n\nCheck out my game made with these levels!\n\nShare levels here: https://scratch.mit.edu/discuss/topic/353858