Platformer
@Stage\n\nwhen [p v] key pressed\nforever\n    hide variable [pointer v]\n    set [pointer v] to (join ((Scroll X) + (mouse x)) (join [, ] ((Scroll Y) + (mouse y))))\nend\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag v) and wait\nbroadcast (Play Game v) and wait\n\nwhen I receive [green flag v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\nset [level v] to [1]\nforever\n    broadcast (Reset v) and wait\n    broadcast (Setup v) and wait\n    Game On\n    repeat until <(Exit) > []>\n        Tick\n        broadcast (Tick v) and wait\n    end\n    if <(Exit) = [Win]> then\n        Level - Over\n    else\n        Game - Die\n    end\nend\n\ndefine Game On\nset [x v] to [0]\nset [y v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset size to (100) %\nclear graphic effects\nshow\n\ndefine Tick\nif <key (left arrow v) pressed?> then\n    Change Player X by [-8]\nend\nif <key (right arrow v) pressed?> then\n    Change Player X by [8]\nend\nif <key (up arrow v) pressed?> then\n    if <(In Air) < [4]> then\n        set [sy v] to [16]\n    end\nend\nchange [sy v] by (-2)\nChange Player Y by (SY)\nTest - Die\nset [scroll x v] to (X)\nchange [scroll y v] by (round (((Y) - (Scroll Y)) / (10)))\nif <(Scroll Y) < [0]> then\n    set [scroll y v] to [0]\nend\nPosition\nif <(Y) < [-180]> then\n    set [exit v] to [Die]\nend\n\ndefine Change Player Y by (scroll y)\nchange [y v] by (scroll y)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (platforms v)?>>\n    if <(scroll y) > [0]> then\n        change [y v] by (-1)\n    else\n        change [y v] by (1)\n        set [in air v] to [0]\n    end\n    Position\n    set [sy v] to [0]\nend\n\ndefine Position\ngo to x: ((X) - (Scroll X)) y: ((Y) - (Scroll Y))\n\ndefine Change Player X by (scroll x)\nchange [x v] by (scroll x)\nPosition\nif <touching (platforms v)?> then\n    repeat (12)\n        change [y v] by (1)\n        Position\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <touching (platforms v)?>>\n        if <(scroll x) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        Position\n    end\nend\n\ndefine Game - Die\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\ndefine Test - Die\nif <touching (lava v)?> then\n    set [exit v] to [Die]\nend\n\ndefine Level - Over\nrepeat (50)\n    point towards (portal v)\n    turn right (65) degrees\n    move ((distance to [portal v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (2)\nend\nhide\nchange [level v] by (1)\nwait (1) seconds\n\n@Platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (Scroll X)) ((Y) - (Scroll Y))\n\nwhen I receive [setup v]\nset [x v] to [0]\nset [y v] to [0]\nif <(Level) = [1]> then\n    switch costume to (level 1.1 v)\n    Clone at X : [360] Y : [0]\n    Clone at X : [360] Y : [0]\n    Clone at X : [360] Y : [0]\n    Clone at X : [360] Y : [0]\nelse\n    if <(Level) = [2]> then\n        switch costume to (level 2.1 v)\n        Clone at X : [195] Y : [189]\n        Clone at X : [225] Y : [0]\n        Clone at X : [525] Y : [27]\n    else\n        if <(Level) = [3]> then\n            switch costume to (level 3.1 v)\n            Clone at X : [400] Y : [0]\n            Clone at X : [360] Y : [0]\n            Clone at X : [360] Y : [0]\n        else\n            if <(Level) = [4]> then\n                switch costume to (level 4.1 v)\n            else\n            end\n        end\n    end\nend\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at X : (x) Y : (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\n@Lava\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (Scroll X)) ((Y) - (Scroll Y))\n\nwhen I receive [setup v]\nset [x v] to [0]\nset [y v] to [0]\nif <(Level) = [1]> then\n    switch costume to (level 1.1 v)\n    Clone at X : [360] Y : [0]\n    Clone at X : [360] Y : [0]\n    Clone at X : [360] Y : [0]\n    Clone at X : [360] Y : [0]\nelse\n    if <(Level) = [2]> then\n        switch costume to (level 2.1 v)\n        Clone at X : [195] Y : [189]\n        Clone at X : [225] Y : [0]\n        Clone at X : [525] Y : [27]\n    else\n        if <(Level) = [3]> then\n            switch costume to (level 3.1 v)\n            Clone at X : [400] Y : [0]\n            Clone at X : [360] Y : [0]\n            Clone at X : [360] Y : [0]\n        else\n            if <(Level) = [4]> then\n                switch costume to (level 4.1 v)\n            end\n        end\n    end\nend\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at X : (x) Y : (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\n@Collectable\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (Scroll X)) ((Y) - (Scroll Y))\nif <touching (player v)?> then\n    change [collected v] by (1)\n    if <(Collected) = (Collected Maximum)> then\n        broadcast (Open Portal v)\n    else\n        broadcast (Close Portal v)\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nset [collected v] to [0]\nset [collected maximum v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(Level) = [1]> then\n    switch costume to (collectable v)\n    Clone at X : [50] Y : [25]\n    Clone at X : [100] Y : [25]\n    Clone at X : [295] Y : [91]\n    Clone at X : [345] Y : [91]\n    Clone at X : [395] Y : [91]\n    Clone at X : [481] Y : [151]\n    Clone at X : [657] Y : [88]\n    Clone at X : [707] Y : [88]\n    Clone at X : [968] Y : [89]\n    Clone at X : [1112] Y : [21]\n    Clone at X : [1196] Y : [24]\n    Clone at X : [1339] Y : [22]\n    Clone at X : [1437] Y : [22]\n    Clone at X : [1537] Y : [22]\nelse\n    if <(Level) = [2]> then\n        switch costume to (collectable v)\n        Clone at X : [111] Y : [24]\n        Clone at X : [60] Y : [71]\n        Clone at X : [165] Y : [116]\n        Clone at X : [94] Y : [169]\n        Clone at X : [265] Y : [219]\n        Clone at X : [491] Y : [190]\n        Clone at X : [634] Y : [239]\n        Clone at X : [897] Y : [240]\n        Clone at X : [953] Y : [240]\n        Clone at X : [1049] Y : [240]\n    else\n        if <(Level) = [3]> then\n            switch costume to (collectable v)\n            Clone at X : [62] Y : [22]\n            Clone at X : [140] Y : [22]\n            Clone at X : [328] Y : [22]\n            Clone at X : [390] Y : [75]\n            Clone at X : [430] Y : [75]\n            Clone at X : [455] Y : [22]\n            Clone at X : [697] Y : [22]\n            Clone at X : [778] Y : [22]\n            Clone at X : [860] Y : [22]\n            Clone at X : [995] Y : [22]\n            Clone at X : [1044] Y : [22]\n            Clone at X : [1116] Y : [22]\n            Clone at X : [1190] Y : [22]\n        end\n    end\nend\nset [x v] to [-11111111111]\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at X : (x) Y : (y)\nset [x v] to (x)\nset [y v] to (y)\nchange [collected maximum v] by (1)\nhide variable [collected maximum v]\ncreate clone of (_myself_ v)\n\n@Portal\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (Scroll X)) ((Y) - (Scroll Y))\nif <<touching (player v)?> and <(costume [name v]) = [Open]>> then\n    set [exit v] to [Win]\nend\n\nwhen I receive [setup v]\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(Level) = [1]> then\n    switch costume to (closed v)\n    Clone at X : [1663] Y : [55]\nelse\n    if <(Level) = [2]> then\n        switch costume to (closed v)\n        Clone at X : [1144] Y : [273]\n    else\n        if <(Level) = [3]> then\n            switch costume to (closed v)\n            Clone at X : [1314] Y : [39]\n        else\n            if <(Level) = [4]> then\n                set [x v] to [-1111111]\n                switch costume to (closed v)\n            end\n        end\n    end\nend\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at X : (x) Y : (y)\nset [x v] to (x)\nset [y v] to (y)\n\nwhen I receive [open portal v]\nswitch costume to (open v)\n\n