Element - Platformer

Instructions: Arrow keys to move.\n\n[Update 2019] Fixed for Scratch 3.

@Stage\n\nwhen flag clicked\nswitch backdrop to (sky v)\nclear graphic effects\nforever\n    if <(Music) = [0]> then\n        play sound [Laura Shigihara - The Great World v] until done\n    else\n        wait (1) seconds\n    end\nend\n\nwhen I receive [reload v]\nset [brightness v] effect to (30)\nrepeat (5)\n    change [brightness v] effect by (-5)\n    wait (0.02) seconds\nend\nclear graphic effects\n\nwhen I receive [newlevel v]\nif <(Level) = [Volcanic 1]> then\n    switch backdrop to (cave v)\nend\nif <(Level) = [Volcanic 2]> then\n    switch backdrop to (cave2 v)\nend\nif <(Level) = [Volcanic 6]> then\n    switch backdrop to (sky v)\nend\nwait (0.05) seconds\nif <(Level) = [Volcanic 1]> then\n    switch backdrop to (cave v)\nend\nif <(Level) = [Volcanic 2]> then\n    switch backdrop to (cave2 v)\nend\nif <(Level) = [Volcanic 6]> then\n    switch backdrop to (sky v)\nend\n\nwhen flag clicked\nset [time v] to [0]\nhide variable [time v]\nrepeat until <key (any v) pressed?>\n    reset timer\nend\nwait (1) seconds\nwait until <(Level) = [Volcanic 6]>\nset [time v] to (timer)\nshow variable [time v]\n\nwhen flag clicked\nforever\n    if <not <(Music) = [0]>> then\n        stop all sounds\n    end\nend\n\n@Player\n\nwhen flag clicked\nforever\n    go to x: (X) y: (Y)\n    if <(Direction) = [0]> then\n        if <<(Yv) = [0]> and <(OnGround) > [0]>> then\n            switch costume to (stillforward v)\n        else\n            switch costume to (bounceforward v)\n        end\n    else\n        if <(Direction) < [0]> then\n            point in direction (-90)\n        else\n            point in direction (90)\n        end\n        if <<(Yv) = [0]> and <(OnGround) > [0]>> then\n            switch costume to (stillside v)\n        else\n            switch costume to (bounceside v)\n        end\n    end\n    if <key (q v) pressed?> then\n        broadcast (Reload v)\n    end\n    if <(Colour) < [30]> then\n        set [color v] effect to ((Colour) - (5))\n    else\n        set [color v] effect to ((Colour) + (50))\n    end\nend\n\n@Hitbox\n\nwhen flag clicked\ngo to x: (-220) y: (-60)\ngo [backward v] (99) layers\nset [level# v] to [1]\nforever\n    change [yv v] by (-0.5)\n    if <key (right arrow v) pressed?> then\n        change [xv v] by (0.3)\n    end\n    if <key (left arrow v) pressed?> then\n        change [xv v] by (-0.3)\n    end\n    set [xv v] to ((Xv) * (0.9))\n    change x by (Xv)\n    if <touching (platform v)?> then\n        change y by (1)\n        if <touching (platform v)?> then\n            change y by (1)\n            if <touching (platform v)?> then\n                change y by (1)\n                if <touching (platform v)?> then\n                    change y by (1)\n                    if <touching (platform v)?> then\n                        change y by (1)\n                        if <touching (platform v)?> then\n                            change x by ((Xv) * (-1))\n                            change x by (-1)\n                            change y by (-5)\n                            change x by (1)\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change y by (Yv)\n    if <touching (platform v)?> then\n        change y by ((Yv) * (-1))\n        set [yv v] to [0]\n    end\n    change y by (-1)\n    if <touching (platform v)?> then\n        set [onground v] to [1]\n        if <<key (up arrow v) pressed?> or <key (space v) pressed?>> then\n            set [yv v] to [8.4]\n        end\n    else\n        set [onground v] to [0]\n    end\n    if <<touching (blue v)?> and <(Colour) = [25]>> then\n        if <<key (up arrow v) pressed?> or <key (space v) pressed?>> then\n            set [yv v] to [1]\n        end\n    end\n    if <<touching (red v)?> and <(Colour) = [50]>> then\n        if <<key (up arrow v) pressed?> or <key (space v) pressed?>> then\n            set [yv v] to [1]\n        end\n    end\n    set [x v] to (x position)\n    set [y v] to (y position)\n    change y by (1)\nend\n\nwhen flag clicked\nset [ghost v] effect to (95)\nforever\n    if <<<touching (red v)?> and <not <(Colour) = [50]>>> or <<touching (blue v)?> and <(Colour) = [50]>>> then\n        broadcast (Reload v)\n    end\n    if <(round (Xv)) = [0]> then\n        set [direction v] to [0]\n    else\n        set [direction v] to (Xv)\n    end\n    if <(x position) > [235]> then\n        if <(Level#) = [6]> then\n            set [level# v] to [20]\n        else\n            change [level# v] by (1)\n        end\n        go to x: (-220) y: (-60)\n        broadcast (NewLevel v)\n    end\n    if <(y position) < [-175]> then\n        if <(Level#) = [6]> then\n            go to x: (-220) y: (-60)\n            set [level# v] to [10]\n            broadcast (NewLevel v)\n        else\n            broadcast (Reload v)\n        end\n    end\n    if <touching (blue v)?> then\n        set [xv v] to ((Xv) * (0.9))\n        set [yv v] to ((Yv) * (0.6))\n    end\n    if <touching (red v)?> then\n        set [xv v] to ((Xv) * (0.9))\n    end\nend\n\nwhen I receive [reload v]\ngo to x: (-220) y: (-60)\nset [xv v] to [0]\nset [yv v] to [0]\n\n@Platform\n\nwhen flag clicked\nswitch costume to (g1 v)\ngo to x: (0) y: (0)\n\nwhen I receive [newlevel v]\nwait (0.01) seconds\nif <(Level) = [Mist 6]> then\n    set [level# v] to [6]\n    switch costume to (w1 v)\nelse\n    if <(Level) = [World Gateway]> then\n        switch costume to (w1 v)\n    else\n        next costume\n    end\n    if <(Level) = [Mist 1]> then\n        switch costume to (m1 v)\n    else\n        if <(Level) = [Volcanic 1]> then\n            switch costume to (v1 v)\n        end\n    end\nend\n\n@Orb\n\nwhen flag clicked\nset [colour v] to [0]\nhide\n\nwhen I start as a clone\nwait until <touching (hitbox v)?>\nrepeat (8)\n    change [ghost v] effect by (12)\nend\nclear graphic effects\nset [colour v] to ((costume [number v]) * (25))\ndelete this clone\n\nwhen I receive [reload v]\ndelete this clone\n\nwhen I start as a clone\nshow\nforever\n    repeat (2)\n        change y by (1)\n        wait (0.04) seconds\n    end\n    repeat (2)\n        change y by (-1)\n        wait (0.04) seconds\n    end\nend\n\nwhen I receive [newlevel v]\ndelete this clone\n\nwhen I receive [reload v]\nRefresh\n\ndefine Refresh\nwait (0.01) seconds\nif <(Level#) = [3]> then\n    switch costume to (blue v)\n    go to x: (0) y: (0)\n    create clone of (_myself_ v)\nend\nif <(Level#) = [4]> then\n    switch costume to (yellow v)\n    go to x: (-40) y: (-59)\n    create clone of (_myself_ v)\nend\nif <(Level#) = [5]> then\n    set [colour v] to [75]\n    switch costume to (red v)\n    go to x: (-155) y: (45)\n    create clone of (_myself_ v)\nend\nif <(Level#) = [12]> then\n    set [colour v] to [50]\n    switch costume to (blue v)\n    go to x: (-155) y: (25)\n    create clone of (_myself_ v)\nend\nif <(Level#) = [14]> then\n    set [colour v] to [25]\n    switch costume to (red v)\n    go to x: (-135) y: (60)\n    create clone of (_myself_ v)\n    switch costume to (yellow v)\n    go to x: (180) y: (-75)\n    create clone of (_myself_ v)\nend\nif <(Level#) = [21]> then\n    set [colour v] to [75]\n    switch costume to (red v)\n    go to x: (-120) y: (100)\n    create clone of (_myself_ v)\nend\nif <(Level#) = [25]> then\n    set [colour v] to [50]\n    switch costume to (blue v)\n    go to x: (160) y: (-75)\n    create clone of (_myself_ v)\nend\n\nwhen I receive [newlevel v]\nRefresh\n\n@Red\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nwait (1) seconds\ngo [backward v] (99) layers\nwait until <(Level#) = [3]>\nswitch costume to (3 v)\nshow\nwait until <(Level#) = [4]>\nhide\nwait until <(Level#) = [5]>\nswitch costume to (5 v)\nshow\nwait until <(Level#) = [6]>\nswitch costume to (6 v)\nwait until <(Level#) = [10]>\nhide\nwait until <(Level#) = [12]>\nswitch costume to (12 v)\nshow\nwait until <(Level#) = [13]>\nhide\nwait until <(Level#) = [14]>\nswitch costume to (14 v)\nshow\nwait until <(Level#) = [6]>\nswitch costume to (6 v)\nwait until <(Level#) = [20]>\nhide\nwait until <(Level#) = [21]>\nswitch costume to (21 v)\nshow\nwait until <(Level#) = [22]>\nhide\n\n@Blue\n\nwhen flag clicked\nhide\nwait (1) seconds\ngo [backward v] (99) layers\nwait until <(Level#) = [6]>\ngo to x: (0) y: (0)\nswitch costume to (6 v)\nshow\nwait until <(Level#) = [10]>\ngo to x: (-96) y: (-70)\nswitch costume to (10 v)\nwait until <(Level#) = [11]>\nhide\nwait until <(Level#) = [12]>\ngo to x: (0) y: (0)\nswitch costume to (12 v)\nshow\nwait until <(Level#) = [13]>\nhide\nwait until <(Level#) = [14]>\nswitch costume to (2 v)\nshow\nwait until <(Level#) = [6]>\nswitch costume to (6 v)\nwait until <(Level#) = [20]>\nhide\nwait until <(Level#) = [22]>\nswitch costume to (22 v)\nshow\nwait until <(Level#) = [23]>\nhide\n\n@FallingPlatform\n\nwhen flag clicked\nhide\nwait (1) seconds\ngo [backward v] (99) layers\nwait until <(Level#) = [10]>\ngo to x: (0) y: (0)\nswitch costume to (m1 v)\nshow\nrepeat until <(Level#) = [11]>\n    if <touching (player v)?> then\n        change y by (-3)\n    else\n        if <(y position) < [0]> then\n            change y by (1)\n        end\n    end\nend\nhide\n\nwhen flag clicked\n\n@Text Prompt\n\nwhen flag clicked\nswitch costume to (costume1 v)\nwait (0.1) seconds\ngo to [front v] layer\ngo to x: (0) y: (0)\nshow\nrepeat (10)\n    change y by (5)\n    change [ghost v] effect by (9)\nend\nwait (0.1) seconds\nclear graphic effects\nhide\nwait (1.25) seconds\ngo [backward v] (999) layers\ngo to x: (0) y: (0)\nforever\n    if <(Level#) < [6]> then\n        set [level v] to (join [Grass ] (Level#))\n    else\n        if <(Level#) = [6]> then\n            set [level v] to [World Gateway]\n        else\n            if <(Level#) < [16]> then\n                set [level v] to (join [Mist ] ((Level#) - (9)))\n            else\n                set [level v] to (join [Volcanic ] ((Level#) - (19)))\n            end\n        end\n    end\nend\n\nwhen I receive [newlevel v]\nset [ghost v] effect to (100)\nhide\nswitch costume to (Level#)\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nclear graphic effects\nwait (1) seconds\nswitch costume to (Level#)\n\nwhen flag clicked\nwait (1) seconds\nwait until <(Level#) = [21]>\nwait (0.1) seconds\ngo to [front v] layer\nwait until <(Level#) = [22]>\nwait (0.1) seconds\ngo [backward v] (999) layers\n\n@Thumbnail\n\nwhen flag clicked\ngo to [front v] layer\nshow\ngo to x: (0) y: (0)\nwait (1) seconds\nrepeat (10)\n    change [ghost v] effect by (9)\nend\nhide\nclear graphic effects\n\n