100% Pen Platformer Level Editor

Instructions: Eng:\nThis is the level editor for the 100% Pen Platformer, press the mouse button to place a block. Press e to toggle between test and edit mode.\nPress D to delete a block.\nPress 1 to select walls,\n2 for Lava, 3 for Bouncy-blocks, 4 for Checkpoints, 5 for the goal, and 6 for portals. If you want to place a portal, you need to press the mouse button twice, once to select where the portal needs to be and once for the position the player has to be teleported to.\nPress S to see the Level Code of your Level and press L to load a Level.\nAttention: Please don't write a comment with your Level-code, it's too long for a comment, please post your Level-code in this forum Topic: https://scratch.mit.edu/discuss/topic/339884/\nMove with the Arrow-keys, jump with the Up-arrow key. Blue blocks are walls, red blocks are lava, purple is bouncy, and yellow is a Checkpoint.\nUsing the arrows in the top-right corner you can change the move speed and the jump height of the player! Press the arrow that points to the left to make the player slower, the arrow to the right to make him faster, the arrow to the top to make him jump higher, and the arrow to the bottom to make him jump lower.\nThis game is a Scrolling game and also 100% Pen.\n\nDe:\nDas ist der LevelEditor für den 100% Pen Platformer, drücke die Maustaste um ein Block zu platzieren. Drücke E um zwischen dem Test- und dem Baumodus zu wechseln.\nDrücke D um einen Block zu löschen.\nDrücke 1 um Wände auszuwählen,\n2 für Lava, 3 für Trampoline, 4 für Checkpoints, 5 für das Ziel und 6 für Portale. Wenn du ein Portal platzieren willst, musst du die Maustaste 2-mal drücken, einmal um das Portal zu platzieren und einmal um zu bestimmen wo der Spieler \nhin teleportiert wird.\nDrücke S um dir den Level Code für dein Level anzuzeigen und drücke L um ein Level zu laden.\nAchtung: Bitte schreibe den Level Code nicht in die Kommentare, er ist dafür zu lang, bitte schreibe die Level Codes in dieses Forum: https://scratch.mit.edu/discuss/topic/339884/\nBewege dich mit den Pfeiltasten und springe mit der Pfeiltaste nach oben. Die blauen Blöcke sind Wände, die roten Blöcke sind Lava, lila Blöcke sind Trampoline und gelbe Blöcke sind Checkpoints.\nMit den Pfeilen oben rechts in der Ecke kannst du einstellen wie schnell sich der Spieler bewegt und wie hoch er springt! Drücke den Pfeil nach links damit sich der Spieler langsamer bewegt, den Pfeil nach rechts damit er sich schneller bewegt, den Pfeil nach oben damit er höher springt und den Pfeil nach unten damit er nicht so hoch springt.\nDieses Spiel ist ein Scrolling Spiel und außerdem 100% Pen.

@Stage\n\n@Pen\n\ndefine Draw Level (text)\nif <key (d v) pressed?> then\n    set [mouse x v] to ((round ((((mouse x) + (X)) + (240)) / (20))) + (500))\n    set [mouse y v] to ((round (((mouse y) + (180)) / (20))) + (10))\n    set [delete v] to (join (Mouse X) (join [ ] (Mouse Y)))\nend\nset [calclevelcode v] to []\nset [zeichen v] to [0]\nrepeat until <(Zeichen) > (length of (text))>\n    set [block v] to []\n    repeat until <<(letter (Zeichen) of (text)) = [N]> or <(Zeichen) > (length of (text))>>\n        set [block v] to (join (Block) (letter (Zeichen) of (text)))\n        change [zeichen v] by (1)\n    end\n    if <<(letter (1) of (Block)) = [S]> or <<not < (Block) contains (Delete)?>> and <not <<<((join (letter (6) of (Block)) (letter (7) of (Block))) - (10)) > [4]> and <((join (letter (6) of (Block)) (letter (7) of (Block))) - (10)) < [10]>> and <<((join (letter (2) of (Block)) (join (letter (3) of (Block)) (letter (4) of (Block)))) - (500)) > [-1]> and <((join (letter (2) of (Block)) (join (letter (3) of (Block)) (letter (4) of (Block)))) - (500)) < [5]>>>>>> then\n        if <(letter (1) of (Block)) = [S]> then\n            set [calclevelcode v] to (join [S] (join (join ((Jumpheight) + (10)) (join [D] (MoveSpeed))) [n]))\n        else\n            set [calclevelcode v] to (join (CalcLevelCode) (join (Block) [n]))\n            if <not <(letter (1) of (Block)) = [6]>> then\n                Draw Block ((join (letter (2) of (Block)) (join (letter (3) of (Block)) (letter (4) of (Block)))) - (500)) ((join (letter (6) of (Block)) (letter (7) of (Block))) - (10)) (letter (1) of (Block))\n            else\n                Draw Portal at ((join (letter (2) of (Block)) (join (letter (3) of (Block)) (letter (4) of (Block)))) - (500)) ((join (letter (6) of (Block)) (letter (7) of (Block))) - (10)) to ((join (letter (9) of (Block)) (join (letter (10) of (Block)) (letter (11) of (Block)))) - (500)) ((join (letter (13) of (Block)) (letter (14) of (Block))) - (10))\n            end\n        end\n    end\n    change [zeichen v] by (1)\nend\nset [levelcode v] to (CalcLevelCode)\nset [delete v] to [NaN]\n\nwhen [s v] key pressed\ndelete all of [level v]\nadd (LevelCode) to [level v]\nadd [Press space to close!] to [level v]\nhide list [level v]\nwait until <key (space v) pressed?>\nshow list [level v]\n\nwhen [l v] key pressed\nask [] and wait\nset [levelcode v] to (answer)\nset [jumpheight v] to ((join (letter (2) of (answer)) (letter (3) of (answer))) - (10))\nset [movespeed v] to (letter (5) of (answer))\n\nwhen I receive [won v]\nstop [other scripts in sprite v]\npen up\ngo to x: (0) y: (0)\nset pen color to (#000000)\nset pen size to (1)\npen down\nrepeat (100)\n    change pen size by (10)\n    go to x: (0) y: (0)\nend\nbroadcast (Start v)\n\nwhen I receive [start v]\nforever\n    erase all\n    Draw Grid\n    Draw blocks [0] [5] [4] [5] [1] Every [1] Blocks\n    Draw Level (LevelCode)\n    Player Physics\n    Draw Player\n    if <key (1 v) pressed?> then\n        set [type v] to [1]\n    end\n    if <key (2 v) pressed?> then\n        set [type v] to [2]\n    end\n    if <key (3 v) pressed?> then\n        set [type v] to [3]\n    end\n    if <key (4 v) pressed?> then\n        set [type v] to [4]\n    end\n    if <key (5 v) pressed?> then\n        set [type v] to [5]\n    end\n    if <key (6 v) pressed?> then\n        set [type v] to [6]\n    end\n    if <(Edit) = [1]> then\n        pen up\n        set pen color to (#000000)\n        go to x: (-200) y: (160)\n        set pen size to (50)\n        pen down\n        set pen size to (40)\n        if <(Type) = [1]> then\n            set pen color to (#0000ff)\n        end\n        if <(Type) = [2]> then\n            set pen color to (#ff0000)\n        end\n        if <(Type) = [3]> then\n            set pen color to (#d800b9)\n        end\n        if <(Type) = [4]> then\n            set pen color to (#faff00)\n        end\n        if <(Type) = [5]> then\n            set pen color to (#22cc00)\n        end\n        if <(Type) = [6]> then\n            set pen color to (#75d1ff)\n        end\n        move (0) steps\n        pen up\n        set pen color to (#0000ff)\n        if <(Jumpheight) > [19]> then\n            set pen color to (#ff0000)\n        end\n        set pen size to (1)\n        go to x: (220) y: (150)\n        pen down\n        go to x: (220) y: (175)\n        go to x: (215) y: (165)\n        pen up\n        go to x: (220) y: (175)\n        pen down\n        go to x: (225) y: (165)\n        set pen color to (#0000ff)\n        if <(Jumpheight) < [8]> then\n            set pen color to (#ff0000)\n        end\n        pen up\n        go to x: (200) y: (175)\n        pen down\n        go to x: (200) y: (150)\n        go to x: (195) y: (160)\n        pen up\n        go to x: (200) y: (150)\n        pen down\n        go to x: (205) y: (160)\n        set pen color to (#0000ff)\n        if <(MoveSpeed) > [3]> then\n            set pen color to (#ff0000)\n        end\n        pen up\n        go to x: (150) y: (165)\n        pen down\n        go to x: (180) y: (165)\n        go to x: (170) y: (160)\n        pen up\n        go to x: (180) y: (165)\n        pen down\n        go to x: (170) y: (170)\n        set pen color to (#0000ff)\n        if <(MoveSpeed) < [2]> then\n            set pen color to (#ff0000)\n        end\n        pen up\n        go to x: (140) y: (165)\n        pen down\n        go to x: (110) y: (165)\n        go to x: (115) y: (160)\n        pen up\n        go to x: (110) y: (165)\n        pen down\n        go to x: (115) y: (170)\n    end\nend\n\nwhen I receive [start v]\nset [inair? v] to [1]\nshow list [level v]\nforever\n    if <(Edit) = [1]> then\n        wait until <<mouse down?> or <key (f v) pressed?>>\n        if <<key (f v) pressed?> and <not <(Type) = [6]>>> then\n            if <(mouse y) < [150]> then\n                set [fmx v] to ((round ((((mouse x) + (X)) + (240)) / (20))) + (500))\n                set [fmy v] to ((round (((mouse y) + (180)) / (20))) + (10))\n                wait until <mouse down?>\n                set [mousex2 v] to ((round ((((mouse x) + (X)) + (240)) / (20))) + (500))\n                set [mousey2 v] to ((round (((mouse y) + (180)) / (20))) + (10))\n                if <(FMX) > (MouseX2)> then\n                    set [fillx v] to (MouseX2)\n                else\n                    set [fillx v] to (FMX)\n                end\n                if <(FMY) > (MouseY2)> then\n                    set [filly v] to (MouseY2)\n                else\n                    set [filly v] to (FMY)\n                end\n                wait until <not <mouse down?>>\n            end\n            Fill\n        else\n            if <(mouse y) < [150]> then\n                set [mouse x v] to ((round ((((mouse x) + (X)) + (240)) / (20))) + (500))\n                set [mouse y v] to ((round (((mouse y) + (180)) / (20))) + (10))\n                if <(Type) = [6]> then\n                    wait until <mouse down?>\n                    wait until <not <mouse down?>>\n                    wait until <mouse down?>\n                    set [mousex2 v] to ((round ((((mouse x) + (X)) + (240)) / (20))) + (500))\n                    set [mousey2 v] to ((round (((mouse y) + (180)) / (20))) + (10))\n                    set [levelcode v] to (join (LevelCode) (join (Type) (join (Mouse X) (join [ ] (join (Mouse Y) (join [ ] (join (MouseX2) (join [ ] (join (MouseY2) [n])))))))))\n                else\n                    set [levelcode v] to (join (LevelCode) (join (Type) (join (Mouse X) (join [ ] (join (Mouse Y) [n])))))\n                end\n            end\n        end\n        wait until <not <mouse down?>>\n    end\nend\n\ndefine Draw Portal at (x) (y) to (telex) (teley)\nset pen color to (#77d0ff)\nif <<((((x) * (20)) - (X)) - (240)) > [-240]> and <((((x) * (20)) - (X)) - (240)) < [240]>> then\n    pen up\n    go to x: ((((x) * (20)) - (X)) - (240)) y: (((y) * (20)) - (180))\n    set pen size to (20)\n    pen down\n    set pen size to (10)\n    change x by (7)\n    change y by (7)\n    change x by (-14)\n    change y by (-14)\n    change x by (14)\n    change y by (14)\n    if <<(Edit) = [0]> and <<<(PlayerX) > ((((x) * (20)) - (240)) - (20))> and <(PlayerX) < ((((x) * (20)) - (240)) + (20))>> and <<(PlayerY) < ((((y) * (20)) - (180)) + (20))> and <(PlayerY) > ((((y) * (20)) - (180)) - (20))>>>> then\n        set [playerx v] to (((telex) * (20)) - (240))\n        set [playery v] to (((teley) * (20)) - (180))\n    end\nend\n\nwhen flag clicked\nset [movespeed v] to [2]\nset [jumpheight v] to [10]\nset [edit v] to [1]\nset [levelcode v] to [S20D2n]\nset [playerx v] to [-200]\nset [playery v] to [0]\nset [yvel v] to [0]\nset [xvel v] to [0]\nhide\nset [x v] to [-200]\nset [spawnx v] to [2]\nset [spawny v] to [8]\nbroadcast (Start v)\n\ndefine Draw Block (x) (y) (type)\nif <(type) = [1]> then\n    set pen color to (#0000ff)\nend\nif <(type) = [2]> then\n    set pen color to (#ff0000)\nend\nif <(type) = [3]> then\n    set pen color to (#d800b9)\nend\nif <(type) = [4]> then\n    set pen color to (#faff00)\nend\nif <(type) = [5]> then\n    set pen color to (#22cc00)\nend\nif <<((((x) * (20)) - (X)) - (240)) > [-240]> and <((((x) * (20)) - (X)) - (240)) < [240]>> then\n    pen up\n    go to x: ((((x) * (20)) - (X)) - (240)) y: (((y) * (20)) - (180))\n    set pen size to (20)\n    pen down\n    set pen size to (10)\n    change x by (7)\n    change y by (7)\n    change x by (-14)\n    change y by (-14)\n    change x by (14)\n    change y by (14)\nend\n\ndefine Player Physics\nif <(Edit) = [0]> then\n    pen up\n    go to x: ((PlayerX) - (X)) y: (PlayerY)\n    set size to (100) %\n    if <<((PlayerX) - (X)) > [-240]> and <((PlayerX) - (X)) < [240]>> then\n        switch costume to (pen v)\n        set size to (400) %\n        pen up\n        go to x: ((PlayerX) - (X)) y: (PlayerY)\n        change [yvel v] by (-1)\n        change [playery v] by (Yvel)\n        go to x: ((PlayerX) - (X)) y: (PlayerY)\n        switch costume to (pen v)\n        point in direction (180)\n        if <touching color (#0000ff)?> then\n            repeat ([abs v] of (Yvel) )\n                if <touching color (#0000ff)?> then\n                    change y by (((Yvel) / ([abs v] of (Yvel) )) * (-1))\n                    change [playery v] by (((Yvel) / ([abs v] of (Yvel) )) * (-1))\n                end\n            end\n            set [yvel v] to [0]\n            change y by (-2)\n            set [inair? v] to [0]\n            if <touching color (#0000ff)?> then\n                if <key (up arrow v) pressed?> then\n                    set [yvel v] to (Jumpheight)\n                    set [inair? v] to [1]\n                end\n            end\n            change y by (2)\n        end\n        if <touching color (#d800b9)?> then\n            set [yvel v] to [16]\n        end\n        if <touching color (#22ce00)?> then\n            set [playerx v] to [-200]\n            set [playery v] to [0]\n            set [yvel v] to [0]\n            set [xvel v] to [0]\n            broadcast (Won v) and wait\n        end\n        if <touching color (#faff00)?> then\n            set [spawnx v] to (round (((PlayerX) + (240)) / (20)))\n            set [spawny v] to (round (((PlayerY) + (180)) / (20)))\n        end\n        go to x: ((PlayerX) - (X)) y: (PlayerY)\n        set [xvel v] to ((Xvel) * (.9))\n        if <key (right arrow v) pressed?> then\n            change [xvel v] by ((MoveSpeed) * (.5))\n        end\n        if <key (left arrow v) pressed?> then\n            change [xvel v] by ((MoveSpeed) * (-.5))\n        end\n        change [playerx v] by (Xvel)\n        go to x: (((PlayerX) - (X)) - (0.5)) y: (PlayerY)\n        set size to (410) %\n        point in direction (90)\n        if <touching color (#0000ff)?> then\n            repeat (([ceiling v] of ([abs v] of (Xvel) ) ) + (5))\n                if <touching color (#0000ff)?> then\n                    change [playerx v] by (((Xvel) / ([abs v] of (Xvel) )) * (-1))\n                    change x by (((Xvel) / ([abs v] of (Xvel) )) * (-1))\n                end\n            end\n            if <<key (up arrow v) pressed?> and <<<key (right arrow v) pressed?> or <key (left arrow v) pressed?>> and <(inair?) = [1]>>> then\n                set [yvel v] to (Jumpheight)\n                set [xvel v] to ((Xvel) * (-1.1))\n                set [inair? v] to [1]\n            else\n                set [xvel v] to [0]\n            end\n            change [playerx v] by (((Xvel) / ([abs v] of (Xvel) )) * (-1))\n        end\n        switch costume to (pen v)\n        set size to (400) %\n        if <<touching color (#ff0000)?> or <(PlayerY) < [-220]>> then\n            set [playerx v] to (((SpawnX) * (20)) - (240))\n            set [playery v] to ((((SpawnY) * (20)) - (180)) + (10))\n            set [yvel v] to [0]\n            set [xvel v] to [0]\n        end\n        go to x: (((PlayerX) - (X)) - (0.5)) y: (PlayerY)\n        if <touching color (#0001ff)?> then\n            set [moves v] to [1]\n            repeat until <not <touching color (#0001ff)?>>\n                set [counter v] to [0]\n                repeat until <<(Counter) = (Moves)> or <not <touching color (#0001ff)?>>>\n                    change y by (3)\n                    change [playery v] by (3)\n                    change [counter v] by (1)\n                end\n                set [counter v] to [0]\n                repeat until <<(Counter) = (Moves)> or <not <touching color (#0001ff)?>>>\n                    change x by (3)\n                    change [playerx v] by (3)\n                    change [counter v] by (1)\n                end\n                change [moves v] by (1)\n                set [counter v] to [0]\n                repeat until <<(Counter) = (Moves)> or <not <touching color (#0001ff)?>>>\n                    change y by (-3)\n                    change [playery v] by (-3)\n                    change [counter v] by (1)\n                end\n                set [counter v] to [0]\n                repeat until <<(Counter) = (Moves)> or <not <touching color (#0001ff)?>>>\n                    change x by (-3)\n                    change [playerx v] by (-3)\n                    change [counter v] by (1)\n                end\n                change [moves v] by (1)\n            end\n        end\n        set size to (100) %\n    end\nelse\n    change [playerx v] by (<key (right arrow v) pressed?> * (10))\n    change [playerx v] by (<key (left arrow v) pressed?> * (-10))\nend\nchange [x v] by (((PlayerX) - (X)) / (10))\n\ndefine Draw Player\nif <(Edit) = [0]> then\n    if <<((PlayerX) - (X)) > [-240]> and <((PlayerX) - (X)) < [240]>> then\n        set pen color to (#ff8800)\n        pen up\n        go to x: ((PlayerX) - (X)) y: (PlayerY)\n        set pen size to (20)\n        pen down\n        set pen size to (10)\n        change x by (7)\n        change y by (7)\n        change x by (-14)\n        change y by (-14)\n        change x by (14)\n        change y by (14)\n        pen up\n        go to x: (((PlayerX) - (X)) + (5)) y: ((PlayerY) + (5))\n        set pen size to (5)\n        set pen color to (#ffffff)\n        pen down\n        point towards (mouse-pointer v)\n        move (1) steps\n        set pen size to (2)\n        set pen color to (#000000)\n        pen down\n        pen up\n        go to x: (((PlayerX) - (X)) - (5)) y: ((PlayerY) + (5))\n        set pen size to (5)\n        set pen color to (#ffffff)\n        pen down\n        point towards (mouse-pointer v)\n        move (1) steps\n        set pen size to (2)\n        set pen color to (#000000)\n        pen down\n    end\nend\n\ndefine Draw blocks (x) (y) (x2) (y2) (type) Every (number) Blocks\nset [blocky v] to (y)\nrepeat ((((y2) - (y)) / (number)) + (1))\n    set [blockx v] to (x)\n    repeat (((x2) - (x)) / (number))\n        Draw Block (BlockX) (BlockY) (type)\n        change [blockx v] by (number)\n    end\n    Draw Block (BlockX) (BlockY) (type)\n    change [blocky v] by (number)\nend\n\nwhen I receive [start v]\nforever\n    wait until <key (e v) pressed?>\n    wait until <not <key (e v) pressed?>>\n    set [edit v] to ((1) - (Edit))\n    if <(Edit) = [0]> then\n        set [playerx v] to [-200]\n        set [playery v] to [0]\n        set [yvel v] to [0]\n        set [xvel v] to [0]\n        set [x v] to [-200]\n        set [spawnx v] to [2]\n        set [spawny v] to [8]\n    end\nend\n\nwhen I receive [start v]\nforever\n    if <(Edit) = [1]> then\n        if <mouse down?> then\n            if <<<(mouse x) > [215]> and <(mouse y) > [150]>> and <<(mouse x) < [225]> and <(mouse y) < [175]>>> then\n                change [jumpheight v] by (1)\n                if <(Jumpheight) > [20]> then\n                    set [jumpheight v] to [20]\n                end\n                wait until <not <mouse down?>>\n            end\n            if <<<(mouse x) > [195]> and <(mouse y) > [150]>> and <<(mouse x) < [205]> and <(mouse y) < [175]>>> then\n                change [jumpheight v] by (-1)\n                if <(Jumpheight) < [7]> then\n                    set [jumpheight v] to [7]\n                end\n                wait until <not <mouse down?>>\n            end\n            if <<<(mouse x) > [145]> and <(mouse y) > [158]>> and <<(mouse x) < [183]> and <(mouse y) < [173]>>> then\n                change [movespeed v] by (1)\n                if <(MoveSpeed) > [4]> then\n                    set [movespeed v] to [4]\n                end\n                wait until <not <mouse down?>>\n            end\n            if <<<(mouse x) > [110]> and <(mouse y) > [158]>> and <<(mouse x) < [144]> and <(mouse y) < [173]>>> then\n                change [movespeed v] by (-1)\n                if <(MoveSpeed) < [1]> then\n                    set [movespeed v] to [1]\n                end\n                wait until <not <mouse down?>>\n            end\n        end\n    end\nend\n\ndefine Fill\nrepeat (([abs v] of ((FMY) - (MouseY2)) ) + (1))\n    repeat (([abs v] of ((FMX) - (MouseX2)) ) + (1))\n        set [levelcode v] to (join (LevelCode) (join (Type) (join (FillX) (join [ ] (join (FillY) [n])))))\n        change [fillx v] by (1)\n    end\n    change [filly v] by (1)\n    change [fillx v] by ((([abs v] of ((FMX) - (MouseX2)) ) + (1)) * (-1))\nend\n\ndefine Draw Grid\nset pen color to (#000000)\nset pen size to (1)\nset [gx v] to [-220]\nset [gy v] to [-170]\nif <(Edit) = [1]> then\n    repeat (18)\n        pen up\n        go to x: (-240) y: (GY)\n        pen down\n        go to x: (240) y: (GY)\n        change [gy v] by (20)\n    end\n    repeat (25)\n        pen up\n        go to x: (((((X) mod (20)) * (-1)) - (10)) + (GX)) y: (-180)\n        pen down\n        go to x: (((((X) mod (20)) * (-1)) - (10)) + (GX)) y: (180)\n        change [gx v] by (20)\n    end\nend\n\n@Thumbnail\n\nwhen flag clicked\nhide\nforever\n    if <key (t v) pressed?> then\n        if <key (h v) pressed?> then\n            if <key (m v) pressed?> then\n                go to x: (0) y: (0)\n                show\n            end\n        end\n    end\nend\n\n