ʟᴀᴠᴀ ᴄᴀᴠᴇ- a mobile friendly scrolling platformer

Instructions: Welcome to Lava Cave, a mobile-friendly scrolling platformer. 1st scrolling platformer in a series of 5. Sequel:Grassy hill,A scrolling platformer.\nhttps://scratch.mit.edu/projects/399664253/\nControls:Arrow keys,wasd or mobile to move.\nCollect all the coins and the portal will brighten up. If the portal is dark it means you haven't collected all the coins and you need to or going onto the portal will not bring you to the next level.

@Stage\n\n@Player\n\nwhen flag clicked\nhide\nbroadcast (Green Flag v) and wait\nbroadcast (Play Game v) and wait\nwait (4) seconds\nshow\n\nwhen I receive [green flag v]\n\ngo to [front v] layer\n\nwhen I receive [play game v]\nset [level v] to [1]\nforever\n    show\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)\n    end\n    if <(EXIT) = [win]> then\n        Game - Win\n    else\n        Game - Die\n    end\nend\n\nbroadcast (Tick v) and wait\n\ndefine Game On\nset [y v] to [0]\nset [x v] to [0]\nset [sx v] to [0]\nset [sy v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset [ghost v] effect to (0)\nset size to (100) %\n\nshow\n\ndefine Tick\nif <<<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <(left) = [1]>> or <<mouse down?> and <(mouse x) < (x position)>>> then\n    change [sx v] by (-2)\n    point in direction (-90)\nend\nif <<<mouse down?> and <(x position) < (mouse x)>> or <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <(right) = [1]>>> then\n    change [sx v] by (2)\n    point in direction (90)\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 <key (w v) pressed?>> or <(up) = [1]>> or <<mouse down?> and <(mouse y) > (y position)>>> 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\nset [scroll x v] to (x)\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\nPosition\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)\nPosition\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    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 (sx)\nchange [x v] by (sx)\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    if <<<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <(up) = [1]>> or <<mouse down?> and <(mouse y) > (y position)>>> 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    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        Position\n    end\nend\n\ndefine Game - Die\nset [exit v] to []\nbroadcast (DIE v)\n\nrepeat (5)\nend\nhide\nwait (0.5) seconds\n\nwait (2) seconds\n\nshow\nhide\n\nwait (0.1) seconds\n\ndefine Test - Die\nif <<touching (danger v)?> or <key (r v) pressed?>> then\n    if <touching (danger v)?> then\n        change [deaths at level v] by (1)\n    end\n    set [exit v] to [die]\nend\n\ndefine Game - Win\nbroadcast (nex level v)\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\ndefine Walk\n\nwhen I receive [walk v]\n\n\n\n\nwhen I receive [walk v]\n\nwhen flag clicked\nforever\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\nend\n\n\n\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<key (right arrow v) pressed?> or <key (d v) pressed?>>> then\n    if <[3] < (costume [number v])> then\n        wait (0.1) seconds\n        next costume\n    else\n        switch costume to (walk 1 v)\n    end\nelse\n    switch costume to (idle v)\nend\n\nwhen flag clicked\nhide\n\nturn right (15) degrees\n\nwhen flag clicked\nwait (4) seconds\nforever\n    play sound [Crusaders-Approaching v] until done\nend\n\nbroadcast (DIE v)\n\nwhen I receive [nex level v]\nset [deaths at level v] to [0]\n\nwhen I receive [skip v]\nhide\nwait (1) seconds\nshow\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]\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: [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: [0] y: [0]\n        Clone at x: [100] y: [0]\n        Clone at x: [200] y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (amon2 v)\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (level 4 v)\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (level 6 v)\n                    Clone at x: [200] y: [0]\n                else\n                    if <(LEVEL) = [6]> then\n                        switch costume to (7 v)\n                    else\n                        if <(LEVEL) = [7]> then\n                            switch costume to (8 v)\n                        else\n                            if <(LEVEL) = [8]> then\n                                switch costume to (level 5 v)\n                            end\n                        end\n                    end\n                end\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\nnext costume\nnext costume\n\ncreate clone of (_myself_ v)\n\nClone at x: [200] y: [0]\n\nClone at x: [200] y: [0]\n\nwhen I receive [die v]\n\nbroadcast (Setup v)\n\n@Collectables\n\nwhen I receive [green flag v]\nhide\n\nshow\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <touching (player v)?> then\n    broadcast (COLLECTED v)\n    change [collected v] by (1)\n    if <(COLLECTED) = (COLLECTED MAX)> then\n        broadcast (Open Portal v)\n    end\n    delete this clone\nend\n\nwhen I receive [setup v]\nhide\nset [collected max v] to [0]\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    Clone at x: [260] y: [-40]\n    Clone at x: [25] y: [10]\n    Clone at x: [830] y: [72]\n    Clone at x: [470] y: [6]\n    Clone at x: [720] y: [32]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x: [220] y: [90]\n        Clone at x: [50] y: [100]\n        Clone at x: [-109] y: [40]\n        Clone at x: [380] y: [60]\n    else\n        if <(LEVEL) = [3]> then\n            Clone at x: [220] y: [90]\n            Clone at x: [130] y: [50]\n            Clone at x: [-150] y: [40]\n            Clone at x: [350] y: [120]\n        else\n            if <(LEVEL) = [4]> then\n                Clone at x: [100] y: [60]\n                Clone at x: [170] y: [150]\n                Clone at x: [30] y: [200]\n            else\n                if <(LEVEL) = [5]> then\n                    Clone at x: [-100] y: [-20]\n                    Clone at x: [100] y: [0]\n                    Clone at x: [165] y: [80]\n                    Clone at x: [330] y: [130]\n                    Clone at x: [550] y: [130]\n                    Clone at x: [-150] y: [190]\n                    Clone at x: [0] y: [190]\n                else\n                    if <(LEVEL) = [6]> then\n                        Clone at x: [120] y: [0]\n                        Clone at x: [200] y: [0]\n                        Clone at x: [450] y: [0]\n                        Clone at x: [450] y: [150]\n                        Clone at x: [165] y: [175]\n                        Clone at x: [150] y: [280]\n                        Clone at x: [430] y: [300]\n                    else\n                        if <(LEVEL) = [7]> then\n                            Clone at x: [-200] y: [0]\n                            Clone at x: [200] y: [0]\n                            Clone at x: [200] y: [-125]\n                            Clone at x: [200] y: [120]\n                            Clone at x: [0] y: [120]\n                            Clone at x: [340] y: [300]\n                        end\n                    end\n                end\n            end\n        end\n    end\n    set [x v] to [-9999999999]\nend\nset [x v] to [-9999999999]\n\ncreate clone of (_myself_ v)\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 max v] by (1)\ncreate clone of (_myself_ v)\n\nswitch costume to (dot v)\n\nswitch costume to (dot v)\n\nwhen flag clicked\n\nwhen I start as a clone\nforever\n    wait (0.25) seconds\n    next costume\nend\n\nClone at x: [120] y: [27]\n\nClone at x: [220] y: [90]\nClone at x: [130] y: [50]\n\nClone at x: [170] y: [150]\nClone at x: [30] y: [200]\n\nwhen I receive [collected v]\nplay sound [Coin v] until done\n\nClone at x: [450] y: [150]\nClone at x: [165] y: [175]\nClone at x: [150] y: [280]\n\nnext costume\n\nnext costume\n\n@DANGER\n\nwhen I receive [green flag v]\nhide\n\nshow\n\nwhen I receive [tick v]\nPosition ((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: [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: [630] y: [-30]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 v)\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (4 v)\n            else\n                if <(LEVEL) = [5]> then\n                    switch costume to (5 v)\n                else\n                    if <(LEVEL) = [6]> then\n                        switch costume to (6 v)\n                    else\n                        if <(LEVEL) = [7]> then\n                            switch costume to (7 v)\n                        else\n                            if <(LEVEL) = [8]> then\n                                switch costume to (8 v)\n                            end\n                        end\n                    end\n                end\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\nClone at x: [20] y: [-47]\n\nbroadcast (Green Flag v)\n\n@Exit\n\nwhen I receive [green flag v]\nhide\n\nshow\n\nwhen I receive [tick v]\nPosition ((x) - (SCROLL X)) ((y) - (SCROLL Y))\nif <<touching (player v)?> and <(portal open?) = [1]>> then\n    set [exit v] to [win]\nend\n\nwhen I receive [setup v]\nhide\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(LEVEL) = [1]> then\n    set [portal open? v] to [0]\n    set [brightness v] effect to (-40)\n    switch costume to (closed v)\n    Clone at x: [922] y: [21]\nelse\n    if <(LEVEL) = [2]> then\n        set [portal open? v] to [0]\n        set [ghost v] effect to (40)\n        set [brightness v] effect to (-40)\n        switch costume to (closed v)\n        Clone at x: [600] y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            set [portal open? v] to [0]\n            switch costume to (closed v)\n            set [ghost v] effect to (40)\n            set [brightness v] effect to (-40)\n            Clone at x: [500] y: [100]\n        else\n            if <(LEVEL) = [4]> then\n                set [portal open? v] to [0]\n                set [brightness v] effect to (-40)\n                set [ghost v] effect to (40)\n                Clone at x: [-190] y: [200]\n            else\n                if <(LEVEL) = [5]> then\n                    set [portal open? v] to [0]\n                    set [brightness v] effect to (-40)\n                    set [ghost v] effect to (40)\n                    Clone at x: [400] y: [200]\n                else\n                    if <(LEVEL) = [6]> then\n                        set [portal open? v] to [0]\n                        set [brightness v] effect to (-40)\n                        set [ghost v] effect to (40)\n                        Clone at x: [500] y: [350]\n                    else\n                        if <(LEVEL) = [7]> then\n                            set [portal open? v] to [0]\n                            set [brightness v] effect to (-40)\n                            set [ghost v] effect to (40)\n                            Clone at x: [0] y: [0]\n                        else\n                            if <(LEVEL) = [8]> then\n                                set [portal open? v] to [0]\n                                set [brightness v] effect to (-40)\n                                set [ghost v] effect to (40)\n                                Clone at x: [10000] y: [100000]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nClone at x: [920] y: [-28]\n\ncreate clone of (_myself_ v)\n\nnext costume\nnext costume\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\n    set [portal show? v] to [1]\nelse\n    hide\n    set [portal show? v] to [0]\nend\n\nwhen I receive [reset v]\nset [portal open? v] to [0]\nset [ghost v] effect to (40)\nset [brightness v] effect to (-40)\nswitch costume to (closed 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]\nset [brightness v] effect to (5)\nset [ghost v] effect to (0)\nset [portal open? v] to [1]\n\nhide\n\nswitch costume to (open v)\n\nwhen flag clicked\nforever\n    if <(portal show?) = [1]> then\n        next costume\n        wait (0.1) seconds\n    end\nend\n\nClone at x: [600] y: [0]\n\nwait (1) seconds\n\nbroadcast (Setup v)\n\n@background\n\n@particales\n\nwhen I start as a clone\nshow\nset [ghost v] effect to (100)\nchange [color v] effect by (pick random (-5) to (5))\nset size to (pick random (60) to (10)) %\nset [ghost v] effect to (pick random (65) to (110))\ngo to x: (600) y: (pick random (-167.01) to (167))\nglide (pick random (6) to (1)) secs to x: (-300) y: (pick random (-167.01) to (167))\nrepeat (20)\n    change [ghost v] effect by (20)\nend\ndelete this clone\n\nwhen flag clicked\nforever\n\nwhen flag clicked\nforever\n    create clone of (_myself_ v)\n    wait (0.01) seconds\nend\n\nwait (0.01) seconds\n\nwhen I start as a clone\nforever\n    turn right (1) degrees\nend\n\n\n\nwhen flag clicked\nforever\nend\n\nset [particle on? v] to [0]\nwait (1) seconds\nwait until <key (q v) pressed?>\nset [particle on? v] to [1]\nwait (1) seconds\nwait until <key (q v) pressed?>\n\nif <(particle on?) = [1]> then\nend\n\n@Sprite1\n\nwhen flag clicked\ngo to [front v] layer\nshow\nwait (1) seconds\nhide\n\n@gSSSrFvjUzkvmxmeMYjyJ5\n\nwhen flag clicked\nhide\nwait (1) seconds\nshow\ngo to [front v] layer\nswitch costume to (gsssrfvjuzkvmxmemyjyj5 v)\nrepeat (36)\n    next costume\n    wait (0.1) seconds\nend\nhide\n\n@Sprite6\n\nwhen flag clicked\nhide\nwait (2) seconds\nshow\ngo to [front v] layer\nwait (0.5) seconds\ncreate clone of (_myself_ v)\nwait (3) seconds\nhide\n\nwhen I start as a clone\nswitch costume to (costume2 v)\nwait (3) seconds\nhide\n\n@Sprite2\n\nwhen flag clicked\nhide\nwait (6) seconds\nshow\nwait (8) seconds\nhide\n\n@Sprite3\n\nwhen flag clicked\nforever\n    if <[7] < (deaths at level)> then\n        show\n    else\n        hide\n    end\nend\n\nif  then\nend\n\nwhen this sprite clicked\nset [exit v] to [WIN]\nbroadcast (nex level v)\nbroadcast (skip v)\n\n