Multiplayer Scrolling Platformer Engine!

Instructions: Use the arrow keys, was or tap to move\nShort and sweet XD\nThere are now 10 levels!!!\nWoohoo! Top loved!\n4th on trending!\nCHECK OUT MY NEW PLATFORMER!!\nhttps://scratch.mit.edu/projects/330168754/

@Stage\n\nwhen I receive [intro done v]\nforever\n    play sound [Vexento - Lights v] until done\n    play sound [Vexento - Happy Robot v] until done\n    play sound [Vexento - Sad Robot v] until done\nend\n\nwhen I receive [intro done v]\nforever\n    set volume to (Volume) %\nend\n\nwhen flag clicked\nset [volume v] to [100]\nstop all sounds\n\n@Ground\n\nwhen I receive [green flag  v]\ngo [forward v] (1) layers\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (Scroll X)) ((Y) - (Scroll Y))\n\nwhen I receive [setup v]\nrepeat (10)\n    delete this clone\nend\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(Level) = [1]> then\n    repeat (10)\n        delete this clone\n    end\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]\n    Clone at X: [360] Y: [0]\n    Clone at X: [360] Y: [0]\nelse\n    if <(Level) = [2]> then\n        repeat (10)\n            delete this clone\n        end\n        switch costume to (2 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]\n        Clone at X: [360] Y: [0]\n        Clone at X: [360] Y: [0]\n    else\n        if <(Level) = [3]> then\n            repeat (10)\n                delete this clone\n            end\n            switch costume to (3 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]\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]\n            Clone at X: [360] Y: [0]\n        else\n            hide\n            delete this clone\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\nwhen I receive [stop game v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Collectables\n\nwhen I receive [green flag  v]\nset [coins collected v] to (join (join [0] [/]) [4])\nhide variable [mouse v]\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (Scroll X)) ((((Y) + ((5) * ([sin v] of (((X) + (game tick)) * (10)) ))) - (10)) - (Scroll Y))\nif <touching (player v)?> then\n    change [collected v] by (1)\n    start sound [Coin v]\n    Show Total\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 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 (costume1 v)\n    Clone at X: [55] Y: [-56]\n    Clone at X: [824] Y: [-111]\n    Clone at X: [1679] Y: [-80]\nelse\n    if <(Level) = [2]> then\n        switch costume to (costume1 v)\n        Clone at X: [232] Y: [-106]\n        Clone at X: [1505] Y: [-136]\n        Clone at X: [358] Y: [119]\n    else\n        if <(Level) = [3]> then\n            switch costume to (costume1 v)\n            Clone at X: [550] Y: [168]\n            Clone at X: [1305] Y: [-59]\n            Clone at X: [3316] Y: [25]\n        end\n    end\nend\nset [x v] to [-99999]\nset [y v] to [322]\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\nwhen [m v] key pressed\nif <<(username) = [UnstripedZebra]> or <(username) = [UnstripedZebraTest]>> then\n    set [mouse v] to (join ((mouse x) + (Scroll X)) (join [, ] ((mouse y) + (Scroll Y))))\n    show variable [mouse v]\nend\n\ndefine Show Total\nset [coins collected v] to (join (join (Collected) [/]) (Collected Max))\n\nwhen I receive [stop game v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Danger\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 (spike v)\n    Clone at X: [226] Y: [-82]\n    Clone at X: [267] Y: [-82]\n    Clone at X: [777] Y: [-13]\n    Clone at X: [1391] Y: [0]\n    Clone at X: [1421] Y: [0]\n    Clone at X: [1451] Y: [0]\n    Clone at X: [1929] Y: [127]\nelse\n    if <(Level) = [2]> then\n        switch costume to (spike v)\n        Clone at X: [98] Y: [17]\n        Clone at X: [331] Y: [-136]\n        Clone at X: [366] Y: [-136]\n        Clone at X: [401] Y: [-136]\n        Clone at X: [1186] Y: [12]\n        Clone at X: [1290] Y: [15]\n        Clone at X: [1325] Y: [18]\n    else\n        if <(Level) = [3]> then\n            switch costume to (spike v)\n            Clone at X: [45] Y: [-87]\n            Clone at X: [242] Y: [45]\n            Clone at X: [267] Y: [45]\n            Clone at X: [415] Y: [26]\n            Clone at X: [515] Y: [-41]\n            Clone at X: [543] Y: [-50]\n            Clone at X: [575] Y: [-48]\n            Clone at X: [1087] Y: [-72]\n            Clone at X: [1443] Y: [158]\n            Clone at X: [1475] Y: [159]\n            Clone at X: [1776] Y: [-13]\n            Clone at X: [1810] Y: [-13]\n        else\n        end\n    end\nend\nset [x v] to [-99999]\nset [y v] to [322]\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)\ncreate clone of (_myself_ v)\n\nwhen I receive [stop game v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Exit\n\nwhen I receive [open portal v]\nswitch costume to (open v)\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]\nhide\nset [collected v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nif <(Level) = [1]> then\n    show\n    switch costume to (closed v)\n    Go to X: [2040] Y: [242]\nelse\n    if <(Level) = [2]> then\n        show\n        switch costume to (closed v)\n        Go to X: [2040] Y: [242]\n    else\n        if <(Level) = [3]> then\n            show\n            switch costume to (closed v)\n            Go to X: [3590] Y: [173]\n        else\n            hide\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 Go to 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\nwhen I receive [stop game v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Menu\n\nwhen flag clicked\nstop all sounds\nDelete\n\ndefine Reset\nset size to (100) %\nswitch costume to (full v)\ngo to x: (0) y: (0)\nset [id v] to [0]\nshow\nclear graphic effects\ngo to [front v] layer\npoint in direction (90)\nrepeat (3)\n    next costume\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\nswitch costume to (sound1 v)\nchange [id v] by (1)\ncreate clone of (_myself_ v)\nswitch costume to (sound0 v)\nrepeat (2)\n    next costume\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\nhide\n\nwhen I start as a clone\nshow\nif <(id) = [1]> then\n    forever\n        point in direction ((90) + ((2) * ([sin v] of (((timer) - (2)) * (275)) )))\n    end\nelse\n    if <(id) = [2]> then\nend\n\nwhen this sprite clicked\nif <(id) = [1]> then\n\nwhen I receive [play game v]\nDelete\n\ndefine Delete\nhide\ndelete this clone\n\nwhen I receive [menu v]\nReset\nwait (0.01) seconds\nhide\n\nwhen I receive [credits v]\nDelete\n\nwhen I receive [questions v]\nDelete\n\nwhen I receive [level select v]\nDelete\n\n@In-game Buttons\n\nwhen I start as a clone\nif <(id) = [1]> then\n    go to [front v] layer\n    go to x: (-204) y: (150)\n    forever\n        go to [front v] layer\n        if <touching (mouse-pointer v)?> then\n            change [brightness v] effect by (-10)\n            wait until <not <touching (mouse-pointer v)?>>\n            change [brightness v] effect by (10)\n        end\n    end\nelse\n    if <(id) = [2]> then\n        go to [front v] layer\n        go to x: (-167) y: (150)\n        forever\n            go to [front v] layer\n            if <touching (mouse-pointer v)?> then\n                change [brightness v] effect by (-10)\n                wait until <not <touching (mouse-pointer v)?>>\n                change [brightness v] effect by (10)\n            end\n        end\n    else\n        if <(id) = [3]> then\n            go to [front v] layer\n            go to x: (-130) y: (150)\n            forever\n                go to [front v] layer\n                if <touching (mouse-pointer v)?> then\n                    change [brightness v] effect by (-10)\n                    wait until <not <touching (mouse-pointer v)?>>\n                    change [brightness v] effect by (10)\n                end\n            end\n        else\n            if <(id) = [4]> then\n                go to [front v] layer\n                go to x: (0) y: (0)\n            end\n        end\n    end\nend\n\ndefine Delete\nhide\ndelete this clone\n\nwhen flag clicked\nset [id v] to [0]\nDelete\n\nwhen I receive [menu v]\nDelete\n\ndefine Reset\nset size to (100) %\nswitch costume to (full v)\ngo to x: (0) y: (0)\nset [id v] to [0]\nshow\nclear graphic effects\ngo to [front v] layer\npoint in direction (90)\nrepeat (2)\n    next costume\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\nnext costume\nrepeat (2)\n    next costume\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\nhide\n\nwhen I receive [play game v]\nDelete\nReset\n\nwhen this sprite clicked\nif <(id) = [1]> then\n    broadcast (Play Game v)\nelse\n    if <(id) = [2]> then\n        if < (costume [name v]) contains [1]?> then\n            set [volume v] to [0]\n            switch costume to (sound0 v)\n        else\n            set [volume v] to [100]\n            switch costume to (sound1 v)\n        end\n    else\n        if <(id) = [3]> then\n            broadcast (Menu v)\n            broadcast (Stop Game v)\n        else\n            if <(id) = [4]> then\n        end\n    end\nend\n\nwhen I receive [level select v]\nDelete\n\n@Questions/Instructions\n\nwhen flag clicked\nset [id v] to [0]\nDelete\n\ndefine Delete\nhide\ndelete this clone\n\nwhen I receive [menu v]\nDelete\n\nwhen I receive [questions v]\nReset\n\ndefine Reset\ngo to [front v] layer\nset [id v] to [0]\ngo to x: (0) y: (0)\nshow\nclear graphic effects\nswitch costume to (full v)\nrepeat (2)\n    next costume\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\nhide\n\nwhen I start as a clone\nif <(id) = [1]> then\n    go to x: (0) y: (0)\nelse\n    if <(id) = [2]> then\n        clear graphic effects\n        go to x: (-210) y: (-159)\n        if <touching (mouse-pointer v)?> then\n            change [brightness v] effect by (-10)\n            wait until <not <touching (mouse-pointer v)?>>\n            change [brightness v] effect by (10)\n        end\n    end\nend\n\nwhen this sprite clicked\nif <(id) = [1]> then\n\n@Thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nshow\nforever\n    go to [front v] layer\nend\n\n@mist\n\nwhen I receive [green flag  v]\ngo to [front v] layer\nhide\n\nwhen I receive [tick v]\nPosition ((X) - (Scroll X)) ((Y) - (Scroll Y))\n\nwhen I receive [setup v]\nrepeat (10)\n    delete this clone\nend\nhide\nset [x v] to [0]\nset [y v] to [0]\nif <(Level) = [1]> then\n    repeat (10)\n        delete this clone\n    end\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]\n    Clone at X: [360] Y: [0]\n    Clone at X: [360] Y: [0]\nelse\n    if <(Level) = [2]> then\n        repeat (10)\n            delete this clone\n        end\n        switch costume to (2 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]\n        Clone at X: [360] Y: [0]\n    else\n        if <(Level) = [3]> then\n            repeat (10)\n                delete this clone\n            end\n            switch costume to (3 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]\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]\n            Clone at X: [360] Y: [0]\n        else\n            hide\n            delete this clone\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\nwhen I receive [stop game v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@level select\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [menu v]\ngo to x: (0) y: (0)\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\nwhen I receive [level select v]\nClone\n\ndefine Clone\nrepeat (10)\n    delete this clone\nend\nset size to (100) %\ngo to x: (0) y: (0)\nset [id v] to [0]\nhide\nclear graphic effects\ngo to [front v] layer\nswitch costume to (full v)\nrepeat (6)\n    next costume\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\ngo to [front v] layer\nif <(id) = [1]> then\n    go to x: (0) y: (0)\n    go to [back v] layer\nelse\n    if <(id) = [2]> then\n        go to x: (0) y: (0)\n        repeat (30)\n            set y to (((y position) - (-130)) / (3))\n        end\n        forever\n            point in direction ((90) + ((3) * ([cos v] of (((timer) - (2)) * (275)) )))\n        end\n    else\n        if <(id) = [3]> then\n            go to x: (0) y: (0)\n            repeat (30)\n                set x to (((x position) - (130)) / (3))\n            end\n            set size to (100) %\n            forever\n                if <touching (mouse-pointer v)?> then\n                    change size by (10)\n                    wait until <not <touching (mouse-pointer v)?>>\n                    change size by (-10)\n                end\n            end\n        else\n            if <(id) = [4]> then\n                go to x: (0) y: (0)\n                set size to (100) %\n                forever\n                    if <touching (mouse-pointer v)?> then\n                        change size by (10)\n                        wait until <not <touching (mouse-pointer v)?>>\n                        change size by (-10)\n                    end\n                end\n            else\n                if <(id) = [5]> then\n                    go to x: (0) y: (0)\n                    repeat (30)\n                        set x to (((x position) - (-130)) / (3))\n                    end\n                    set size to (100) %\n                    forever\n                        if <touching (mouse-pointer v)?> then\n                            change size by (10)\n                            wait until <not <touching (mouse-pointer v)?>>\n                            change size by (-10)\n                        end\n                    end\n                else\n                    if <(id) = [6]> then\n                        go to x: (-199) y: (-137)\n                        set size to (100) %\n                        forever\n                            if <touching (mouse-pointer v)?> then\n                                change size by (10)\n                                wait until <not <touching (mouse-pointer v)?>>\n                                change size by (-10)\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen this sprite clicked\nif <(id) = [1]> then\n\nwhen I receive [play game v]\ngo to x: (0) y: (0)\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\n@Player\n\nwhen flag clicked\nbroadcast (Green Flag  v) and wait\n\nwhen I receive [green flag  v]\nhide\ngo to [front v] layer\n\nwhen I receive [play game v]\ngo to x: (0) y: (150)\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        Game - Win\n    else\n        Game - Die\n    end\nend\n\ndefine Game On\nset rotation style [left-right v]\nswitch costume to (idle v)\nset [x v] to [0]\nset [y v] to [0]\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [in air v] to [0]\nset [exit v] to []\nset [game tick v] to [0]\nset [frame v] to [0]\nshow\npoint in direction (90)\nset size to (95) %\nclear graphic effects\n\ndefine Tick\nset rotation style [left-right v]\nswitch costume to (hitbox v)\nif <not <<<<key (right arrow v) pressed?> or <<mouse down?> and <(x position) < (mouse x)>>> or <key (d v) pressed?>> or <<<key (left arrow v) pressed?> or <<mouse down?> and <(mouse x) < (x position)>>> or <key (a v) pressed?>>>> then\n    set [frame v] to [0]\nend\nif <<<key (left arrow v) pressed?> or <<mouse down?> and <(mouse x) < (x position)>>> or <key (a v) pressed?>> then\n    change [speed x v] by (-2)\n    change [frame v] by (0.5)\n    point in direction (-90)\nend\nif <<<key (right arrow v) pressed?> or <<mouse down?> and <(x position) < (mouse x)>>> or <key (d v) pressed?>> then\n    change [speed x v] by (2)\n    change [frame v] by (0.5)\n    point in direction (90)\nend\nset [speed x v] to ((Speed X) * (0.8))\nif <([abs v] of (Speed X) ) > [0.9]> then\n    Change Player X by (round (Speed X))\nend\nif <<<<key (up arrow v) pressed?> or <<mouse down?> and <(y position) < (mouse y)>>> or <key (w v) pressed?>> or <key (space v) pressed?>> then\n    if <(In Air) < [4]> then\n        set [speed y v] to [16]\n    end\nend\nif <key (r v) pressed?> then\n    broadcast (Play Game v) and wait\nend\nchange [speed y v] by (-2)\nChange Player Y by (Speed Y)\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) < [-230]> then\n    set [exit v] to [Die]\nend\nchange [game tick v] by (1)\nAnimate\n\ndefine Change Player Y by (speed y)\nchange [y v] by (speed y)\nchange [in air v] by (1)\nPosition\nrepeat until <not <touching (ground v)?>>\n    if <(speed 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 [speed y v] to [0]\nend\n\ndefine Position\ngo to x: ((X) - (Scroll X)) y: ((Y) - (Scroll Y))\n\ndefine Change Player X by (speed x)\nchange [x v] by (speed x)\nPosition\nif <touching (ground v)?> then\n    repeat (20)\n        change [y v] by (1)\n        Position\n        if <not <touching (ground v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-20)\n    repeat until <not <touching (ground v)?>>\n        if <(speed 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 (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\nbroadcast (Stop Game v)\nbroadcast (Level Select v)\nwait (1) seconds\n\nwhen I receive [stop game v]\nhide\nstop [other scripts in sprite v]\ndelete this clone\n\ndefine Animate\nif <(In Air) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to (idle v)\n    else\n        switch costume to ([floor v] of ((4) + ((frame) mod (7))) )\n    end\nelse\n    if <(Speed Y) > [-2]> then\n        switch costume to (jump v)\n    else\n        switch costume to (fall v)\n    end\nend\n\nwhen I receive [hop v]\nset [speed y v] to [16]\n\n@enemies\n\ndefine move enemy\nset rotation style [left-right v]\nset size to (100) %\nnext costume\nset [old x v] to (X)\nset [x v] to (round ((origin x) + ((move x) * ([abs v] of (((((game tick) / (divider)) + (offset)) mod (2)) - (1)) ))))\nset [y v] to (round ((origin y) + ((move y) * ([abs v] of (((((game tick) / (divider)) + (offset)) mod (2)) - (1)) ))))\nif <touching (player v)?> then\n    if <<([y v] of [player v]) > (Y)> and <([speed y v] of [player v]) < [0]>> then\n        broadcast (hop v)\n        delete this clone\n    else\n        set [exit v] to [DIE]\n    end\nend\nposition\nif <(old x) > (X)> then\n    point in direction (-90)\nelse\n    point in direction (90)\nend\n\ndefine enemy at X: (x) and y: (y)\nset rotation style [left-right v]\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nset [origin x v] to (x)\nset [origin y v] to (y)\nset [offset v] to [0]\n\ndefine then glide (n) secs to x: (x) and y: (y)\nset [origin x v] to (x)\nset [origin y v] to (y)\nset [move x v] to ((X) - (x))\nset [move y v] to ((Y) - (y))\nset [divider v] to ((30) * (n))\n\nwhen I receive [reset v]\ndelete this clone\n\nwhen I receive [setup v]\nif <(Level) = [1]> then\n    enemy at X: [1475] and y: [10]\n    then glide [3] secs to x: [1600] and y: [10]\n    enemy at X: [1725] and y: [45]\n    then glide [2] secs to x: [1805] and y: [45]\n    bye bye, screen\nelse\n    if <(Level) = [2]> then\n        enemy at X: [-135] and y: [-9]\n        then glide [2] secs to x: [-57] and y: [-9]\n        enemy at X: [1024] and y: [12]\n        then glide [2] secs to x: [1101] and y: [12]\n        bye bye, screen\n    else\n        if <(Level) = [3]> then\n            enemy at X: [-90] and y: [-82]\n            then glide [2] secs to x: [0] and y: [-82]\n            enemy at X: [785] and y: [-43]\n            then glide [2] secs to x: [889] and y: [-43]\n            enemy at X: [1853] and y: [-13]\n            then glide [2] secs to x: [1954] and y: [-13]\n            bye bye, screen\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\ndefine position\nPosition ((X) - (Scroll X)) ((Y) - (Scroll Y))\n\nwhen I receive [tick v]\nmove enemy\n\ndefine bye bye, screen\nenemy at X: [-99999] and y: [-99999]\nthen glide [9] secs to x: [-99999] and y: [-99999]\n\nwhen I receive [level select v]\ndelete this clone\n\nwhen I receive [menu v]\ndelete this clone\n\n@Credits\n\nwhen flag clicked\nset [id v] to [0]\nDelete\n\ndefine Delete\nhide\ndelete this clone\n\nwhen I receive [menu v]\nDelete\n\nwhen I receive [credits v]\nReset\n\ndefine Reset\ngo to [front v] layer\nset [id v] to [0]\ngo to x: (0) y: (0)\nshow\nclear graphic effects\nswitch costume to (full v)\nrepeat (2)\n    next costume\n    change [id v] by (1)\n    create clone of (_myself_ v)\nend\nhide\n\nwhen I start as a clone\nif <(id) = [1]> then\n    go to x: (0) y: (0)\nelse\n    if <(id) = [2]> then\n        clear graphic effects\n        go to x: (-210) y: (-159)\n        if <touching (mouse-pointer v)?> then\n            change [brightness v] effect by (-10)\n            wait until <not <touching (mouse-pointer v)?>>\n            change [brightness v] effect by (10)\n        end\n    end\nend\n\nwhen this sprite clicked\nif <(id) = [1]> then\n\n@intro\n\nwhen flag clicked\nwait (1) seconds\nbroadcast (text \(intro\) v)\n\nwhen flag clicked\nwait (0.001) seconds\nreset timer\ngo to x: (0) y: (0)\npoint in direction (90)\nstart sound [Intro Music v]\nswitch costume to (star v)\nset [id2 v] to [3]\ncreate clone of (_myself_ v)\nswitch costume to (l v)\nhide\nwait until <(timer) > [4.5]>\nforever\n    repeat until <(timer) > [7.5]>\n        set [id v] to [1]\n        create clone of (_myself_ v)\n        set [id v] to [2]\n        create clone of (_myself_ v)\n        wait (0.2) seconds\n        set [bw v] to [1]\n        set [id v] to [1]\n        create clone of (_myself_ v)\n        set [id v] to [2]\n        create clone of (_myself_ v)\n        set [bw v] to [2]\n        wait (0.2) seconds\n    end\nend\n\nwhen I start as a clone\nshow\ngo to [back v] layer\nset size to (100) %\nif <<(id) = [1]> and <(costume [name v]) = [L]>> then\n    if <(bw) = [1]> then\n        switch costume to (l v)\n    else\n        switch costume to (l2 v)\n    end\n    set x to (-120)\n    wait until <(timer) > [4.5]>\n    set [# v] to [22]\n    repeat (22)\n        set x to (item (#) of [r v])\n        change [# v] by (-1)\n        point in direction (((2) * ([sin v] of ((timer) * (80)) )) + (90))\n        change size by (0)\n    end\n    delete this clone\nend\nif <<(id) = [2]> and <(costume [name v]) = [L]>> then\n    if <(bw) = [1]> then\n        switch costume to (l v)\n    else\n        switch costume to (l2 v)\n    end\n    set x to (120)\n    wait until <(timer) > [4.5]>\n    set [# v] to [22]\n    repeat (22)\n        change size by (0)\n        point in direction (((2) * ([sin v] of ((timer) * (80)) )) + (90))\n        set x to ((item (#) of [r v]) * (-1))\n        change [# v] by (-1)\n    end\n    delete this clone\nend\nif <<(id2) = [2]> and <not <(costume [number v]) = [22]>>> then\n    set x to (500)\n    go to [front v] layer\n    if <<(costume [number v]) < [12]> and <(costume [number v]) > [2]>> then\n        set y to (25)\n        repeat until <(round (x position)) = [0]>\n            change x by (((0) - (x position)) / (4))\n        end\n        wait (0.3) seconds\n        set [# v] to [23]\n        repeat (23)\n            set x to ((item (#) of [r2 \(d2\) v]) + (0))\n            change [# v] by (-1)\n        end\n        delete this clone\n    else\n        set y to (-25)\n        repeat until <(round (x position)) = [0]>\n            change x by (((0) - (x position)) / (4))\n        end\n        wait (0.3) seconds\n        set [# v] to [23]\n        repeat (23)\n            set x to ((item (#) of [r2 \(d2\) v]) - (0))\n            change [# v] by (-1)\n        end\n        delete this clone\n    end\nend\nif <(costume [number v]) = [22]> then\n    switch costume to (dot v)\n    set size to (pick random (10) to (50)) %\n    set [brightness v] effect to (pick random (0) to (100))\n    set [y v] to (pick random (0.) to (20.))\n    set [x v] to (pick random (-10.) to (10.))\n    repeat until <(y position) < [-179]>\n        change y by (y)\n        change x by (x)\n        change [y v] by (-1)\n    end\n    delete this clone\nend\nif <(id2) = [3]> then\n    switch costume to (logo v)\n    hide\n    wait until <(timer) > [4.5]>\n    go to x: (0) y: (0)\n    set size to (0) %\n    go to [front v] layer\n    point in direction (0)\n    switch costume to (logo v)\n    show\n    r\n    repeat until <<(round (size)) = [100]> and <(round (direction)) = [90]>>\n        set [i v] to ((((100) - (size)) * (0.1)) + ((i) * (0.8)))\n        turn right (((90) - (direction)) / (5)) degrees\n        change size by (i)\n    end\n    wait (0.2) seconds\n    set [# v] to [22]\n    repeat (22)\n        set x to (item (#) of [r4 v])\n        change [# v] by (-1)\n    end\n    set x to (-500)\n    repeat until <(round (x position)) = [0]>\n        change x by (((0) - (x position)) / (4))\n    end\n    wait (0.1) seconds\n    set [# v] to [19]\n    repeat (19)\n        set size to (item (#) of [r5 v]) %\n        change [# v] by (-1)\n    end\n    broadcast (Scroll \(Intro\) v)\n    delete this clone\nend\nif <(costume [name v]) = [cover]> then\n    go to [front v] layer\n    point in direction (90)\n    if <(id2) = [4]> then\n        go to x: (500) y: (500)\n        set [brightness v] effect to (100)\n        repeat until <<(round (x position)) = [0]> and <(round (y position)) = [0]>>\n            change x by (((0) - (x position)) / (2))\n            change y by (((0) - (y position)) / (2))\n        end\n    end\n    if <(id2) = [5]> then\n        go to x: (500) y: (500)\n        set [brightness v] effect to (84)\n        repeat until <<(round (x position)) = [0]> and <(round (y position)) = [0]>>\n            change x by (((0) - (x position)) / (3))\n            change y by (((0) - (y position)) / (3))\n        end\n    end\n    if <(id2) = [6]> then\n        go to x: (500) y: (500)\n        set [brightness v] effect to (68)\n        repeat until <<(round (x position)) = [0]> and <(round (y position)) = [0]>>\n            change x by (((0) - (x position)) / (4))\n            change y by (((0) - (y position)) / (4))\n        end\n    end\n    if <(id2) = [7]> then\n        go to x: (500) y: (500)\n        set [brightness v] effect to (52)\n        repeat until <<(round (x position)) = [0]> and <(round (y position)) = [0]>>\n            change x by (((0) - (x position)) / (5))\n            change y by (((0) - (y position)) / (5))\n        end\n    end\n    if <(id2) = [8]> then\n        go to x: (500) y: (500)\n        set [brightness v] effect to (36)\n        repeat until <<(round (x position)) = [0]> and <(round (y position)) = [0]>>\n            change x by (((0) - (x position)) / (6))\n            change y by (((0) - (y position)) / (6))\n        end\n    end\n    if <(id2) = [9]> then\n        go to x: (500) y: (500)\n        set [brightness v] effect to (20)\n        repeat until <<(round (x position)) = [0]> and <(round (y position)) = [0]>>\n            change x by (((0) - (x position)) / (7))\n            change y by (((0) - (y position)) / (7))\n        end\n    end\n    if <(id2) = [10]> then\n        go to x: (500) y: (500)\n        set [brightness v] effect to (0)\n        set size to (101) %\n        repeat until <<(round (x position)) = [0]> and <(round (y position)) = [0]>>\n            change x by (((0) - (x position)) / (8))\n            change y by (((0) - (y position)) / (8))\n        end\n    end\n    wait (0.2) seconds\n    broadcast (delete \(intro\) v)\nend\n\nwhen I receive [text \(intro\) v]\nset [id2 v] to [2]\nswitch costume to (1 v)\nrepeat (14)\n    create clone of (_myself_ v)\n    next costume\nend\nswitch costume to (l v)\n\nswitch costume to (logo v)\nset size to (0) %\nrepeat until <(round (size)) = [100]>\n    add (size) to [r5 v]\n    change size by (((100) - (size)) / (4))\nend\n\ndefine r\nswitch costume to (dot v)\nrepeat (60)\n    create clone of (_myself_ v)\nend\nswitch costume to (logo v)\n\nwhen I receive [scroll \(intro\) v]\ns\n\ndefine s\nswitch costume to (cover v)\nset [id2 v] to [4]\nrepeat (7)\n    create clone of (_myself_ v)\n    change [id2 v] by (1)\nend\nswitch costume to (l v)\n\nwhen I receive [delete \(intro\) v]\nwait (0.3) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nbroadcast (Intro Done v)\nbroadcast (Menu v)\ndelete this clone\n\n