Tutorial - Pen Platformer
@Stage\n\n@pen\n\nwhen flag clicked\nReset\nforever\n    erase all\n    if <(SLIDE) = [1]> then\n        Make Level\n        Render\n        update\n        Render Player at ((X) - (CamX)) ((Y) - (CamY)) size [20]\n    end\nend\n\ndefine Reset\nset [#penradius v] to [10]\nset [camy v] to (Y)\nset [camx v] to (X)\nset [collisions v] to [0]\nset [sx v] to [0]\nset [sy v] to [0]\nset [x v] to [0]\nset [y v] to [100]\n\ndefine update\nchange [camx v] by (((X) - (CamX)) / (10))\nchange [camy v] by (((Y) - (CamY)) / (10))\nchange [sx v] by (((<key (left arrow v) pressed?> * (-1)) + <key (right arrow v) pressed?>) - ((Sx) * (0.1)))\nchange [x v] by (Sx)\ncollisions\nif <(Collisions) = [1]> then\n    change [x v] by (() - (Sx))\n    set [sx v] to [0]\nend\nchange [sy v] by (-1)\nchange [y v] by (Sy)\ncollisions\nif <(Collisions) = [1]> then\n    change [y v] by (() - (Sy))\n    set [sy v] to (<key (up arrow v) pressed?> * (15))\nend\n\ndefine Render\nset [_i v] to [0]\nrepeat ((length of [points v]) / (5))\n    pen up\n    set pen size to (#PenRadius)\n    get colour (type (item ((_i) + (5)) of [points v]) )\n    Go To ( X (item ((_i) + (1)) of [points v]) Y (item ((_i) + (2)) of [points v]) )\n    pen down\n    Go To ( X ((item ((_i) + (1)) of [points v]) + (item ((_i) + (3)) of [points v])) Y (item ((_i) + (2)) of [points v]) )\n    Go To ( X ((item ((_i) + (1)) of [points v]) + (item ((_i) + (3)) of [points v])) Y ((item ((_i) + (2)) of [points v]) + (item ((_i) + (4)) of [points v])) )\n    Go To ( X (item ((_i) + (1)) of [points v]) Y ((item ((_i) + (2)) of [points v]) + (item ((_i) + (4)) of [points v])) )\n    Go To ( X (item ((_i) + (1)) of [points v]) Y (item ((_i) + (2)) of [points v]) )\n    change [_i v] by (5)\nend\n\ndefine Make Level\ndelete all of [points v]\nAdd Cube [-100] [-100] [200] [80] type [1]\nAdd Cube [100] [-100] [20] [120] type [2]\nAdd Cube [-120] [-100] [20] [200] type [1]\nAdd Cube [200] [-100] [50] [20] type [3]\n\ndefine Add Cube (x) (y) (length) (height) type (type)\nadd (x) to [points v]\nadd (y) to [points v]\nadd (length) to [points v]\nadd (height) to [points v]\nadd (type) to [points v]\n\ndefine Go To ( X (x) Y (y) )\ngo to x: ((x) - (CamX)) y: ((y) - (CamY))\n\ndefine get colour (type (type) )\nif <(type) = [1]> then\n    set pen color to (#22a000)\nend\nif <(type) = [2]> then\n    set pen color to (#ff0000)\nend\nif <(type) = [3]> then\n    set pen color to (#fff600)\nend\n\ndefine collisions\nset [_i v] to [0]\nset [collisions v] to [0]\nrepeat ((length of [points v]) / (5))\n    if <((X) + ((#PlayerSize) + (#PenRadius))) > (item ((_i) + (1)) of [points v])> then\n        if <((Y) + ((#PlayerSize) + (#PenRadius))) > (item ((_i) + (2)) of [points v])> then\n            if <((X) - (#PenRadius)) < ((item ((_i) + (1)) of [points v]) + (item ((_i) + (3)) of [points v]))> then\n                if <((Y) - (#PenRadius)) < ((item ((_i) + (2)) of [points v]) + (item ((_i) + (4)) of [points v]))> then\n                    set [collisions v] to (item ((_i) + (5)) of [points v])\n                    if <(Collisions) = [3]> then\n                        set [sy v] to ((25) + (<key (up arrow v) pressed?> * (5)))\n                    end\n                end\n            end\n        end\n    end\n    change [_i v] by (5)\nend\nif <<(Collisions) = [2]> or <(CamY) < [-700]>> then\n    Reset\nend\n\ndefine Render Player at (x) (y) size (size)\nset [#playersize v] to (size)\nset pen color to (#4de8eb)\npen up\ngo to x: (x) y: (y)\npen down\ngo to x: ((x) + (size)) y: (y)\ngo to x: ((x) + (size)) y: ((y) + (size))\ngo to x: (x) y: ((y) + (size))\ngo to x: (x) y: (y)\n\n@Sprite1\n\ndefine mouse clicked\nset [old mouse clicked v] to (Mouse Clicked)\nset [mouse clicked v] to ((<(Old mouse clicked) > [0]> * <mouse down?>) + <mouse down?>)\n\nwhen flag clicked\nset [slide v] to [1]\nforever\n    go to x: (147) y: (155)\n    mouse clicked\n    if <touching (mouse-pointer v)?> then\n        change size by (((120) - (size)) / (5))\n    end\n    if <not <touching (mouse-pointer v)?>> then\n        change size by (((100) - (size)) / (5))\n    end\n    if <<<(Mouse Clicked) = [1]> and <touching (mouse-pointer v)?>> and <not <(SLIDE) = [1]>>> then\n        set size to (20) %\n        change [slide v] by (-1)\n        broadcast (reset v)\n    end\nend\n\n@Sprite2\n\nwhen flag clicked\nforever\n    go to x: (211) y: (155)\n    mouse clicked\n    if <touching (mouse-pointer v)?> then\n        change size by (((120) - (size)) / (5))\n    end\n    if <not <touching (mouse-pointer v)?>> then\n        change size by (((100) - (size)) / (5))\n    end\n    if <<(Mouse Clicked) = [1]> and <touching (mouse-pointer v)?>> then\n        set size to (20) %\n        change [slide v] by (1)\n        broadcast (reset v)\n    end\n    set [slide v] to ((SLIDE) mod (11))\n    if <(SLIDE) = [0]> then\n        change [slide v] by (1)\n    end\nend\n\ndefine mouse clicked\nset [old mouse clicked v] to (Mouse Clicked)\nset [mouse clicked v] to ((<(Old mouse clicked) > [0]> * <mouse down?>) + <mouse down?>)\n\n@slides\n\nwhen flag clicked\nforever\n    switch costume to (SLIDE)\nend\n\n@BLOCKS\n\nwhen flag clicked\nforever\n    switch costume to (SLIDE)\n    show\n    if <touching (mouse-pointer v)?> then\n        think [drag me]\n    else\n        think []\n    end\nend\n\nwhen I receive [reset v]\nset drag mode [draggable v]\ngo to x: (0) y: (-200)\n\n@TB\n\nwhen flag clicked\nforever\n    set [ghost v] effect to (100)\n    go to [front v] layer\nend\n\n