Explorer || A Scrolling Platformer

Instructions: PC = Arrow keys to move.\n\nMobile = top third of the screen to jump up, middle third right half to move right while jumping, middle third left half to move left while jumping, bottom third right half to move right, bottom third left half to move left.\n\nAll levels are possible.\n\nYou have to collect all of the coins to pass through the portal otherwise the portal will not open.

@Stage\n\nwhen [m v] key pressed\nset [mouse v] to (join ((mouse x) + (SCROLL X)) (join [, ] ((mouse y) + (SCROLL Y))))\nshow variable [mouse v]\n\nwhen I receive [play game v]\nforever\n    play sound [Dance Energetic v] until done\nend\n\nwhen flag clicked\nswitch backdrop to (logo v)\nplay sound [Triumph v] until done\n\nwhen I receive [green flag v]\nswitch backdrop to (sky v)\n\n@blank\n\n@Player\n\nwhen flag clicked\nhide\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        switch costume to (player-stand v)\n        game win\n    else\n        switch costume to (player-stand v)\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 [sx v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset size to (100) %\nset [ghost v] effect to (0)\nswitch costume to (player-stand v)\nshow\n\ndefine tick\npoint in direction (90)\nif <<(sx) < [2]> and <(sx) > [-2]>> then\n    if <(sy) > [2]> then\n        switch costume to (player-up v)\n    else\n        if <(sy) < [-2]> then\n            switch costume to (player-down v)\n        else\n            switch costume to (player-stand v)\n        end\n    end\nelse\n    if <(sx) > [0]> then\n        if <(sy) > [0]> then\n            switch costume to (player-right-up v)\n        else\n            if <(sy) < [-2]> then\n                switch costume to (player-right-down v)\n            else\n                switch costume to (player-right v)\n            end\n        end\n    else\n        if <(sy) > [0]> then\n            switch costume to (player-left-up v)\n        else\n            if <(sy) < [-2]> then\n                switch costume to (player-left-down v)\n            else\n                switch costume to (player-left v)\n            end\n        end\n    end\nend\nif <<key (left arrow v) pressed?> or <<mouse down?> and <<(mouse y) < [60]> and <(mouse x) < [0]>>>> then\n    if <(sx) > [-20]> then\n        change [sx v] by (-2)\n    end\nend\nif <<key (right arrow v) pressed?> or <<mouse down?> and <<(mouse y) < [60]> and <(mouse x) > [0]>>>> then\n    if <(sx) < [20]> then\n        change [sx v] by (2)\n    end\nend\nset [sx v] to ((sx) * (0.8))\nif <([abs v] of (sx) ) > [0.9]> then\n    change player x by (round (sx))\nend\nif <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > [-60]>>> then\n    if <(in air) < [4]> then\n        set [sy v] to [16]\n    end\nend\nif <(sy) > [-20]> then\n    change [sy v] by (-2)\nend\nchange player y by (sy)\ntest die\nchange [scroll x v] by (round (((x) - (SCROLL X)) / (10)))\nif <(SCROLL X) < [0]> then\n    set [scroll x v] to [0]\nend\nchange [scroll y v] by (round (((y) - (SCROLL Y)) / (10)))\nif <(SCROLL Y) < [0]> then\n    set [scroll y v] to [0]\nend\nif <touching (water-swimable v)?> then\n    if <(sy) > [1]> then\n        set [sy v] to [1]\n    end\n    if <(sy) < [-1]> then\n        set [sy v] to [-1]\n    end\n    set [in air v] to [3]\nend\npossision\nif <(y) < [-180]> then\n    set [exit v] to [die]\nend\n\ndefine change player y by (sy)\nchange [y v] by (sy)\nchange [in air v] by (1)\npossision\nrepeat until <not <touching (platforms v)?>>\n    if <(sy) > [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    possision\n    set [sy v] to [0]\nend\nif <touching (platforms v)?> then\n    set [exit v] to [die]\nend\n\ndefine possision\ngo to x: ((x) - (SCROLL X)) y: ((y) - (SCROLL Y))\n\ndefine change player x by (sx)\nchange [x v] by (sx)\npossision\nif <touching (platforms v)?> then\n    repeat (12)\n        change [y v] by (1)\n        possision\n        if <not <touching (platforms v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    if <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > [-60]>>> then\n        if <not <touching (water-swimable v)?>> then\n            if <(sx) > [0]> then\n                set [sx v] to [-16]\n            else\n                set [sx v] to [16]\n            end\n            set [in air v] to [0]\n        end\n    else\n        set [sx v] to [0]\n    end\n    repeat until <not <touching (platforms v)?>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        possision\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 (danger v)?> then\n    set [exit v] to [die]\nend\n\ndefine game win\nrepeat (50)\n    point towards (exit v)\n    turn right (65) degrees\n    move ((distance to [exit 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\nwhen I receive [play game v]\n\n    set [time v] to ((round ((timer) * (10))) / (10))\nend\n\n@Platforms\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\npossion ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\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 [480] ,y [0]\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        clone at x [0] ,y [360]\n        clone at x [0] ,y [360]\n        clone at x [0] ,y [360]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n        else\n            switch costume to (level win v)\n        end\n    end\nend\n\ndefine possion (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\nwhen flag clicked\nhide\n\n@Collectables\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\npossion ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    change [collectted v] by (1)\n    if <(COLLECTTED) = (COLLECTED MAX)> then\n        broadcast (open portal v)\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collectted v] to [0]\nset [collected max v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (coin v)\n    clone at x [50] ,y [-15]\n    clone at x [50] ,y [20]\n    clone at x [50] ,y [55]\n    clone at x [350] ,y [15]\n    clone at x [350] ,y [45]\n    clone at x [600] ,y [15]\n    clone at x [600] ,y [45]\n    clone at x [888] ,y [-15]\n    clone at x [933] ,y [30]\n    clone at x [978] ,y [-15]\n    clone at x [1892] ,y [-15]\n    clone at x [2033] ,y [-15]\n    clone at x [2183] ,y [-15]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (coin v)\n        clone at x [-125] ,y [81]\n        clone at x [-171] ,y [182]\n        clone at x [-126] ,y [275]\n        clone at x [8] ,y [454]\n        clone at x [-1] ,y [586]\n        clone at x [27] ,y [781]\n        clone at x [-30] ,y [961]\n        clone at x [19] ,y [1055]\n        clone at x [-27] ,y [1152]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (coin v)\n            clone at x [-50] ,y [-15]\n            clone at x [-50] ,y [20]\n            clone at x [-50] ,y [55]\n            clone at x [770] ,y [-2]\n            clone at x [1033] ,y [-15]\n            clone at x [1033] ,y [20]\n            clone at x [1033] ,y [55]\n            clone at x [1180] ,y [-19]\n            clone at x [1301] ,y [-16]\n            clone at x [1482] ,y [-17]\n            clone at x [1598] ,y [-19]\n            clone at x [2131] ,y [-29]\n            clone at x [2037] ,y [-29]\n            clone at x [1954] ,y [-29]\n            clone at x [1841] ,y [-29]\n        else\n            set [x v] to [-999]\n        end\n    end\n    set [x v] to [-99999999999999999999]\nend\nset [x v] to [-99999999999999999999]\n\ndefine possion (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)\ncreate clone of (_myself_ v)\nchange [collected max v] by (1)\n\nwhen flag clicked\nhide\n\n@Exit\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\npossion ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <<(costume [number v]) = [2]> and <touching (player v)?>> then\n    set [exit v] to [win]\nend\n\nwhen I receive [setup v]\nhide\nset [collectted v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (exit closed v)\n    clone at x [2307] ,y [51]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (exit closed v)\n        clone at x [-6] ,y [1278]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (exit closed v)\n            clone at x [2311] ,y [60]\n        else\n            if <(username) = [Saturn-Rings]> then\n                switch costume to (exit closed v)\n                clone at x [0] ,y [60]\n            else\n                set [x v] to [-999]\n            end\n        end\n    end\nend\n\ndefine possion (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 (exit open v)\n\nwhen flag clicked\nhide\n\n@Water\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\npossion ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\ngo to [back v] layer\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (water v)\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (floor bug fix v)\n        clone at x [480] ,y [0]\n        switch costume to (water v)\n        clone at x [480] ,y [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (water v)\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n        else\n            switch costume to (water v)\n            clone at x [480] ,y [0]\n        end\n    end\nend\n\ndefine possion (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)\n\nwhen flag clicked\nhide\n\n@Danger\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\npossion ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\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 [480] ,y [0]\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\n    clone at x [480] ,y [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        clone at x [0] ,y [360]\n        clone at x [0] ,y [360]\n        clone at x [0] ,y [360]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n        else\n            set [x v] to [-999]\n        end\n    end\nend\n\ndefine possion (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\nwhen flag clicked\nhide\n\n@Water-Swimable\n\nwhen I receive [green flag v]\nhide\n\nwhen I receive [tick v]\npossion ((x) - (SCROLL X)) ((y) - (SCROLL Y))\n\nwhen I receive [setup v]\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    set [x v] to [-99999999]\nelse\n    if <(LEVEL) = [2]> then\n        set [x v] to [-99999999]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (water v)\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n            clone at x [480] ,y [0]\n        else\n            set [x v] to [-999]\n        end\n    end\nend\n\nswitch costume to (water v)\n\ndefine possion (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\nwhen flag clicked\nhide\n\n@Sprite3\n\nwhen flag clicked\nhide\nset [ghost v] effect to (100)\n\nwhen I receive [message1 v]\nshow\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\n\nwhen I receive [green flag v]\nhide\n\n@Sprite1\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset size to (0) %\nshow\nrepeat (7)\n    change size by (10)\nend\nrepeat (4)\n    change size by (-5)\nend\nbroadcast (message1 v)\nrepeat (5)\n    change y by (10)\nend\n\nwhen I receive [green flag v]\nhide\n\n@Sprite2\n\nwhen flag clicked\nhide\nrepeat (120)\n    go to x: (pick random (-230) to (-200)) y: (pick random (-120) to (120))\n    create clone of (_myself_ v)\n    go to x: (pick random (230) to (200)) y: (pick random (-120) to (120))\n    create clone of (_myself_ v)\nend\nbroadcast (green flag v) and wait\nbroadcast (play game v) and wait\nhide\n\nwhen I start as a clone\ngo to [back v] layer\nset size to (pick random (10) to (30)) %\nif <not <touching color (#000000)?>> then\n    show\nend\nif <(x position) > [0]> then\n    repeat until <(x position) < [0]>\n        point in direction (-90)\n        move (10) steps\n    end\nelse\n    repeat until <(x position) > [0]>\n        point in direction (90)\n        move (10) steps\n    end\nend\ndelete this clone\n\nwhen I receive [green flag v]\nhide\n\n@Sprite4\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\n\n