Scrolling Platformer Engine

Instructions: -------------------------------------INSTRUCTIONS--------------------------------------\nJust use arrow keys! Try to complete the 10 levels as fast as you can and get the highscore!\n\n---\n\n\nAlso, check out my Youtube channel for game tutorials:\nhttps://www.youtube.com/channel/UCXJDb8HZ8Hz9HDxWL-wRvmg\n\n

@Stage\n\nwhen I receive [start game v]\nrepeat (30)\n    change volume by (-10)\nend\nstop [other scripts in sprite v]\nforever\n    if <(level) = [1]> then\n        switch backdrop to (backdrop2 v)\n    end\n    if <(level) = [2]> then\n        switch backdrop to (backdrop3 v)\n    end\n    if <(level) = [3]> then\n        switch backdrop to (backdrop4 v)\n    end\n    if <(level) = [4]> then\n        switch backdrop to (backdrop5 v)\n    end\n    if <(level) = [5]> then\n        switch backdrop to (backdrop6 v)\n    end\n    if <(level) = [6]> then\n        switch backdrop to (backdrop7 v)\n    end\n    if <(level) = [7]> then\n        switch backdrop to (backdrop8 v)\n    end\n    if <(level) = [8]> then\n        switch backdrop to (backdrop9 v)\n    end\n    if <(level) = [8]> then\n        switch backdrop to (backdrop11 v)\n    end\n    if <(level) = [9]> then\n        switch backdrop to (backdrop10 v)\n    end\n    if <(level) = [10]> then\n        switch backdrop to (backdrop12 v)\n    end\n    if <(level) = [14]> then\n        switch backdrop to (backdrop13 v)\n    end\n    if <(level) = [15]> then\n        switch backdrop to (backdrop12 v)\n        broadcast (boss fight v)\n        stop [this script v]\n    end\nend\n\nwhen I receive [move on v]\nforever\n    if <(level) = [16]> then\n        switch backdrop to (backdrop1 v)\n    end\n    if <(level) = [17]> then\n        switch backdrop to (backdrop15 v)\n    end\nend\n\nwhen I receive [start screen v]\nset volume to (100) %\nswitch backdrop to (backdrop1 v)\nplay sound [ReiX-Digital Insanity - Unreal Superhero.mp3 v] until done\n\n@Player\n\nwhen flag clicked\ngo to [back v] layer\nswitch costume to (costume1 v)\ngo to x: (0) y: (-60)\nset size to (500) %\nforever\n    if <touching color (#ff0000)?> then\n        go to x: (-198) y: (-126)\n    end\nend\n\nwhen I receive [right v]\nnext costume\n\nwhen I receive [left v]\nswitch costume to ((costume [number v]) - (1))\n\nwhen I receive [start game v]\ngo to x: (-198) y: (-126)\nset size to (400) %\nforever\n    go to [front v] layer\n    if <key (left arrow v) pressed?> then\n        change [xvel v] by (-1)\n    end\n    if <key (right arrow v) pressed?> then\n        change [xvel v] by (1)\n    end\n    set [xvel v] to ((Xvel) * (0.9))\n    change x by (Xvel)\n    if <touching (ground v)?> then\n        change y by (1)\n        if <touching (ground v)?> then\n            change y by (1)\n            if <touching (ground v)?> then\n                change y by (1)\n                if <touching (ground v)?> then\n                    change y by (1)\n                    if <touching (ground v)?> then\n                        change y by (1)\n                        if <touching (ground v)?> then\n                            change y by (1)\n                            if <touching (ground v)?> then\n                                change y by (1)\n                                if <touching (ground v)?> then\n                                    change x by ((Xvel) * (-1))\n                                    change y by (-7)\n                                    if <key (up arrow v) pressed?> then\n                                        if <(Xvel) > [0]> then\n                                            set [xvel v] to [-5]\n                                        else\n                                            set [xvel v] to [5]\n                                        end\n                                        set [yvel v] to [10]\n                                    else\n                                        set [xvel v] to [0]\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change [yvel v] by (-1)\n    change y by (Yvel)\n    if <touching (ground v)?> then\n        change y by ((Yvel) * (-1))\n        set [yvel v] to [0]\n    end\n    change y by (-1)\n    if <touching (ground v)?> then\n        if <key (up arrow v) pressed?> then\n            set [yvel v] to [15]\n        end\n    end\n    change y by (1)\nend\n\nwhen I receive [next level v]\ngo to x: (-198) y: (-126)\nchange [level v] by (1)\n\nwhen I receive [start game v]\nwait (1) seconds\nset volume to (100) %\nforever\n    play sound [City Lights v] until done\nend\n\nwhen I receive [boss fight failed v]\ngo to x: (-198) y: (-126)\n\n@Ground\n\nwhen flag clicked\nset [level v] to [1]\nforever\n    switch costume to (level)\nend\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\ngo to [back v] layer\n\n@Arrow right\n\nwhen this sprite clicked\nbroadcast (right v)\nwait (.5) seconds\n\nwhen I receive [start game v]\nhide\n\nwhen flag clicked\ngo to x: (49) y: (-61)\nshow\n\n@Title\n\nwhen flag clicked\nforever\n    set size to (100) %\n    go to x: (0) y: (96)\n    show\n    clear graphic effects\n    set [ghost v] effect to (0)\n    forever\n        change y by ([cos v] of ((p) / (1)) )\n        change [p v] by (5)\n    end\nend\n\nwhen I receive [start game v]\nstop [other scripts in sprite v]\nhide\n\n@Arrow right2\n\nwhen this sprite clicked\nbroadcast (left v)\nwait (.5) seconds\n\nwhen I receive [start game v]\nhide\n\nwhen flag clicked\ngo to x: (-55) y: (-61)\nshow\n\n@play\n\nwhen this sprite clicked\nbroadcast (start game v)\n\nwhen flag clicked\nshow\ngo to x: (14) y: (34)\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (110) %\n    else\n        set size to (100) %\n    end\nend\n\nwhen I receive [start game v]\nhide\n\n@next\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\nforever\n    if <touching (player v)?> then\n        broadcast (next level v)\n    end\n    if <(level) = [17]> then\n        hide\n    end\nend\n\nwhen I receive [boss fight v]\nhide\n\nwhen I receive [move on v]\nshow\nswitch backdrop to (backdrop14 v)\n\nwhen I receive [start game v]\nshow\n\n@lava\n\nwhen flag clicked\nhide\nforever\n    if <(level) = [3]> then\n        show\n        switch costume to (costume1 v)\n        go to x: (-14) y: (-66)\n    end\n    if <(level) = [4]> then\n        show\n        switch costume to (costume2 v)\n        go to x: (10) y: (-66)\n    end\n    if <(level) = [5]> then\n        show\n        switch costume to (costume3 v)\n        go to x: (10) y: (-68)\n    end\n    if <(level) = [6]> then\n        show\n        switch costume to (costume4 v)\n        go to x: (0) y: (-55)\n    end\n    if <(level) = [7]> then\n        hide\n    end\n    if <(level) = [10]> then\n        show\n        switch costume to (costume1 v)\n        go to x: (-22) y: (-66)\n    end\n    if <(level) = [11]> then\n        show\n        switch costume to (costume4 v)\n        go to x: (-120) y: (-48)\n    end\n    if <(level) = [12]> then\n        show\n        switch costume to (costume2 v)\n        go to x: (29) y: (-55)\n    end\n    if <(level) = [13]> then\n        show\n        switch costume to (costume3 v)\n        go to x: (-68) y: (-66)\n    end\n    if <(level) = [14]> then\n        hide\n    end\nend\n\n@laser\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to x: (0) y: (0)\ngo to [back v] layer\nhide\nwait until <(level) = [8]>\nshow\nrepeat until <(level) = [9]>\n    switch costume to (costume1 v)\n    wait (1) seconds\n    switch costume to (costume2 v)\n    wait (1) seconds\nend\n\nwhen flag clicked\nforever\n    if <(level) = [9]> then\n        hide\n    end\nend\n\n@Dark Cube\n\nwhen flag clicked\nset [ghost v] effect to (0)\nhide\n\nwhen I receive [boss fight v]\nswitch costume to (costume1 v)\nshow\nset size to (400) %\ngo to x: (74) y: (-125)\nsay [Hello I see that you escaped before I could take over] for (3) seconds\nsay [But today you will not I will destroy you and this city will be MINE!] for (4) seconds\nbroadcast (ring #1 v)\nwait (1) seconds\nsay [You see this ring! It will destroy you!!!!!!!!!!!!] for (3) seconds\n\nbroadcast (boss fight v)\n\nwhen I receive [ring #2 v]\nsay [owww!!!!!!!!!!!!!!] for (2) seconds\nsay [take this] for (2) seconds\n\nwhen I receive [boss fight failed v]\nwait (1) seconds\nbroadcast (ring #1 v)\nwait (1) seconds\nsay [You see this ring! It will destroy you!!!!!!!!!!!!] for (3) seconds\n\nwhen I receive [ring #3 v]\nstop [other scripts in sprite v]\nsay [owww!!!!!!!!!!!!!!] for (2) seconds\nsay [YARRRRRRGHHHHHH!!!!!!] for (2) seconds\nsay [This one is sure to destroy you] for (2) seconds\nswitch costume to (costume2 v)\n\nsay [take this] for (2) seconds\n\nwhen I receive [no too much v]\nsay [no I-I-I can't hold this it is too-too-too much] for (3) seconds\nwait (1.5) seconds\nsay [noooo!!!!!!] for (2) seconds\nrepeat (100)\n    change [ghost v] effect by (1)\nend\nbroadcast (move on v)\n\n@Fire ring\n\nwhen I receive [ring #1 v]\nset size to (100) %\npoint in direction (90)\nshow\ngo to x: (79) y: (-54)\nwait (6) seconds\npoint in direction (-30)\nforever\n    repeat until <touching (_edge_ v)?>\n        move (10) steps\n    end\n    point towards (player v)\nend\n\nwhen flag clicked\nhide\nset size to (100) %\n\nwhen I receive [boss fight v]\nhide\n\nwhen I receive [ring #1 v]\nforever\n    if on edge, bounce\n    if <touching (player v)?> then\n        stop [other scripts in sprite v]\n        broadcast (boss fight failed v)\n        hide\n        stop [this script v]\n    end\n    if <touching (dark cube v)?> then\n        stop [other scripts in sprite v]\n        broadcast (ring #2 v)\n        hide\n        stop [this script v]\n    end\nend\n\nhide\n\nrepeat (25)\n\nwhen I receive [ring #2 v]\ncreate clone of (_myself_ v)\nwait (3) seconds\nset size to (50) %\npoint in direction (90)\nshow\ngo to x: (31) y: (-79)\nwait (4) seconds\npoint in direction (-30)\nforever\n    repeat until <touching (_edge_ v)?>\n        move (10) steps\n    end\n    point towards (player v)\nend\n\nwhen I start as a clone\nwait (3) seconds\nset size to (50) %\npoint in direction (90)\nshow\ngo to x: (133) y: (-79)\nwait (4) seconds\npoint in direction (30)\nforever\n    repeat until <touching (_edge_ v)?>\n        move (10) steps\n    end\n    point towards (player v)\nend\n\nwhen I receive [ring #2 v]\nforever\n    if on edge, bounce\n    if <touching (player v)?> then\n        stop [other scripts in sprite v]\n        broadcast (boss fight failed v)\n        hide\n        stop [this script v]\n    end\n    if <touching (dark cube v)?> then\n        stop [other scripts in sprite v]\n        broadcast (ring #3 v)\n        hide\n        stop [this script v]\n    end\nend\n\nwhen I start as a clone\nforever\n    if on edge, bounce\n    if <touching (player v)?> then\n        stop [other scripts in sprite v]\n        broadcast (boss fight failed v)\n        hide\n        delete this clone\n    end\n    if <touching (dark cube v)?> then\n        stop [other scripts in sprite v]\n        broadcast (ring #3 v)\n        delete this clone\n    end\nend\n\nstop [this script v]\n\nhide\n\nstop [this script v]\n\nwhen I receive [ring #3 v]\nhide\n\nwhen I receive [ring #3 v]\ndelete this clone\n\nwhen I receive [ring #3 v]\nstop [other scripts in sprite v]\nwait (5) seconds\nset size to (100) %\nshow\ngo to x: (72) y: (-64)\nglide (1) secs to x: (73) y: (126)\nbroadcast (NO too much v)\nwait (4) seconds\nglide (.2) secs to x: (75) y: (-109)\nhide\n\n@Sprite3\n\nwhen flag clicked\ngo to [front v] layer\nset [ghost v] effect to (0)\nhide\nwait (3) seconds\nset [x v] to [30]\nshow\ngo to x: (300) y: (0)\nrepeat until <(x position) = [0]>\n    set [x v] to ((x) / (1.1))\n    change x by ((0) - (x))\nend\n\nwhen flag clicked\nwait (5) seconds\nbroadcast (Fade v)\nforever\n    change [ghost v] effect by (5)\nend\n\nwhen I receive [start screen v]\nhide\n\n@Sprite2\n\nwhen flag clicked\nshow\nstart sound [TheFatRat - Jackpot \(Jackpot EP Track 1\).mp3 v]\nset volume to (100) %\n\nwhen I receive [fade v]\nforever\n    change volume by (-2)\nend\n\nwhen I receive [start screen v]\nhide\n\n@Sprite1\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [sine v] to [0]\npoint in direction (90)\nforever\n    change [sine v] by (7.5)\n    point in direction ((([sin v] of (sine) ) * (15)) + (90))\n    set size to ((([sin v] of ((sine) * (2)) ) * (25)) + (100)) %\nend\n\nwhen I receive [fade v]\nforever\n    change [ghost v] effect by (5)\nend\n\nstop [other scripts in sprite v]\n\npoint in direction (90)\n\nwhen flag clicked\nshow\nwait (7) seconds\nbroadcast (start screen v)\nhide\n\n@thumbnail\n\nshow\ngo to x: (0) y: (0)\ngo to [front v] layer\n\nwhen flag clicked\nhide\n\n