Space Adventure - a platformer

Instructions: Oh no! You've crash-landed on the moon. Help the astronaut get back to Earth!\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n★ Use arrow or W A D keys to move or click for mobile.\n\n★ Avoid falling in craters, black holes, and touching spikes. Also, beware of aliens...\n\n★ Purple is bouncy\n\n★ Click the Sound Button or the M key to mute / unmute the music.\n\n★ Press the S key or the Skip Button to skip a level\n\n★ Press the R key or the Redo Button to save the astronaut from falling through the mysterious crater\n\nMobile Script: @qucchia\nMusic: Fireflies - Owl City 8bit version\n\nUpdate Log:\n3/31/19  @DANISON loved and faved!\n3/31/19  @Deathstriding loved!\n3/31/19 @Strongdude66 loved!\n4/1/19   Deleted the option to go to the previous level\n4/2/19   @-Imagineer- loved!\n4/2/19   Fixed the finished screen glitch\n4/3/19   Fixed animation glitches\n4/7/19   Removed my logo because of hateful comments\n4/11/19 @ChristianKid5 loved!  \n\nTags: #Space #Adventure #Games #Platformer #Mobile

@Stage\n\nwhen flag clicked\nswitch backdrop to (sky v)\n\nwhen I receive [start v]\nwait until <(Level) = [25]>\nswitch backdrop to (last level sky v)\n\n@Player\n\nwhen I receive [start v]\ngo to x: (-220) y: (-70)\npoint in direction (90)\nset [x v] to [0]\nset [y v] to [0]\nset [deaths v] to [0]\nset [level v] to [1]\nwait (0.5) seconds\nshow\nrepeat until <(Level) = [26]>\n    set size to (100) %\n    point in direction (90)\n    if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(mouse x) < (x position)>>> then\n        change [x v] by (-1)\n    end\n    if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(x position) < (mouse x)>>> then\n        change [x v] by (1)\n    end\n    set [x v] to ((X) * (0.85))\n    change x by (X)\n    if <touching (ground v)?> then\n        change y by (-2)\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 (-5)\n                                change x by ((-1) * (X))\n                                if <<<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(y position) < (mouse y)>>>> and <not <(X) = [0]>>> then\n                                    set [mode v] to [walljump]\n                                    set [y v] to [8]\n                                    set [x v] to (((X) / ([abs v] of (X) )) * (-10))\n                                else\n                                    set [mode v] to [wallslide]\n                                    set [x v] to [0]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n        change y by (2)\n    end\n    change y by (-3)\n    if <touching (ground v)?> then\n        if <(Y) = [-3]> then\n            if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<key (right arrow v) pressed?> or <<key (d v) pressed?> or <<<mouse down?> and <(y position) < (mouse y)>> or <<<mouse down?> and <(mouse x) > (x position)>> or <<mouse down?> and <(mouse x) < (x position)>>>>>>> then\n                set [mode v] to [run]\n            else\n                if <([abs v] of (X) ) > [.1]> then\n                    set [mode v] to [skid]\n                else\n                    set [mode v] to [stand]\n                end\n            end\n        end\n        if <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <<mouse down?> and <(y position) < (mouse y)>>>> then\n            set [mode v] to [jump]\n            set [y v] to [10]\n        end\n    end\n    if <<<<(Mode) = [jump]> or <(Mode) = [walljump]>> and <(Y) < [0]>> or <<<(Mode) = [run]> or <(Mode) = [skid]>> and <(Y) < [-3]>>> then\n        set [mode v] to [fall]\n    end\n    change y by (3)\n    if <(Y) > [-15]> then\n        change [y v] by (-0.5)\n    end\n    change y by (-2)\n    if <not <touching (ground v)?>> then\n        change y by (-1)\n        if <not <touching (ground v)?>> then\n            change y by (-1)\n            if <not <touching (ground v)?>> then\n                change y by (-1)\n                if <not <touching (ground v)?>> then\n                    change y by (-1)\n                    if <not <touching (ground v)?>> then\n                        change y by (-1)\n                        if <not <touching (ground v)?>> then\n                            change y by (5)\n                        end\n                    end\n                end\n            end\n        end\n    end\n    if <<<(y position) < [-150]> or <touching (obstacles v)?>> or <touching (alien v)?>> then\n        change [deaths v] by (1)\n        go to x: (-220) y: (-70)\n        set [x v] to [0]\n        set [y v] to [0]\n    end\n    if <<(x position) = [240]> or <(x position) > [240]>> then\n        broadcast (Next Level v)\n        go to x: (-220) y: (-95)\n        hide\n        wait (1) seconds\n        go to x: (-220) y: (-70)\n        show\n    end\n    if <touching (jump v)?> then\n        set [y v] to [15]\n    end\n    change y by (1)\n    change y by (Y)\n    if <touching (ground v)?> then\n        change y by (-2)\n        if <touching (ground v)?> then\n            change y by ((-1) * (Y))\n            set [y v] to [-3]\n        end\n        change y by (1)\n    end\nend\ngo to x: (-220) y: (-95)\nbroadcast (You did it! v)\n\nwhen flag clicked\ngo to x: (200) y: (0)\nhide\nwait (3) seconds\nset size to (200) %\nshow\nrepeat (100)\n    change size by (-5)\nend\n\nwhen flag clicked\ngo to x: (200) y: (0)\nhide\nwait (2) seconds\nglide (2) secs to x: (210) y: (-50)\n\nwhen this sprite clicked\nif <(Deaths) = [1]> then\n    say (join (Deaths) [ death]) for (1.5) seconds\nelse\n    say (join (Deaths) [ deaths]) for (1.5) seconds\nend\n\nwhen [space v] key pressed\nif <(Deaths) = [1]> then\n    say (join (Deaths) [ death]) for (1.5) seconds\nelse\n    say (join (Deaths) [ deaths]) for (1.5) seconds\nend\n\nwhen I receive [intro 2 v]\nhide\n\nwhen I receive [start v]\nforever\n    if <key (s v) pressed?> then\n        if <not <(Level) = [26]>> then\n            broadcast (Next Level v)\n            wait (0.5) seconds\n        end\n    end\n    if <key (r v) pressed?> then\n        broadcast (Restart Level v)\n        wait (0.5) seconds\n    end\nend\n\nwhen I receive [restart level v]\nif <not <(Level) = [26]>> then\n    go to x: (-220) y: (-70)\n    wait (0.5) seconds\nend\n\nwhen [r v] key pressed\nif <not <(Level) = [26]>> then\n    go to x: (-220) y: (-70)\n    wait (0.5) seconds\nend\n\nwhen I receive [next level v]\ngo to x: (-220) y: (0)\n\n@Ground\n\nwhen I receive [next level v]\nif <not <(Level) = [26]>> then\n    wait (0.3) seconds\n    next costume\nend\n\nwhen I receive [start v]\nswitch costume to (1 v)\nshow\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nforever\n    set [level v] to (costume [number v])\nend\n\nwhen flag clicked\nswitch costume to (1 v)\n\n@Obstacles\n\nwhen I receive [next level v]\nif <not <(Level) = [26]>> then\n    wait (0.3) seconds\n    next costume\nend\n\nwhen I receive [start v]\ngo to x: (0) y: (0)\nswitch costume to (1 v)\nshow\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nswitch costume to (1 v)\n\n@Jump\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\ngo to x: (0) y: (0)\nswitch costume to (1 v)\nshow\n\nwhen I receive [next level v]\nif <not <(Level) = [26]>> then\n    wait (0.3) seconds\n    next costume\nend\n\nwhen flag clicked\nswitch costume to (1 v)\n\n@Alien\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nif <<(Level) = [21]> or <(Level) = [23]>> then\n    if <(Level) = [21]> then\n        repeat until <(Level) = [22]>\n            go to x: (-80) y: (108)\n            show\n            switch costume to (right v)\n            glide (5) secs to x: (140) y: (108)\n            switch costume to (left v)\n            glide (5) secs to x: (-80) y: (108)\n        end\n        delete this clone\n    end\n    if <(Level) = [23]> then\n        repeat until <(Level) = [24]>\n            go to x: (-150) y: (-95)\n            show\n            switch costume to (right v)\n            glide (5) secs to x: (240) y: (-95)\n            switch costume to (left v)\n            glide (5) secs to x: (-150) y: (-95)\n        end\n        delete this clone\n    end\n    delete this clone\nelse\n    delete this clone\nend\ndelete this clone\n\nwhen I receive [next level v]\nwait (0.8) seconds\nif <(Level) = [20]> then\n    repeat until <(Level) = [21]>\n        go to x: (10) y: (-95)\n        show\n        switch costume to (left v)\n        glide (5) secs to x: (-240) y: (-95)\n        switch costume to (right v)\n        glide (5) secs to x: (10) y: (-95)\n    end\nend\nif <(Level) = [21]> then\n    repeat until <(Level) = [22]>\n        create clone of (_myself_ v)\n        go to x: (160) y: (-95)\n        show\n        switch costume to (left v)\n        glide (5) secs to x: (-160) y: (-95)\n        switch costume to (right v)\n        glide (5) secs to x: (190) y: (-95)\n    end\nend\nif <(Level) = [22]> then\n    repeat until <(Level) = [23]>\n        go to x: (10) y: (-95)\n        show\n        switch costume to (right v)\n        glide (3) secs to x: (150) y: (-95)\n        switch costume to (left v)\n        glide (3) secs to x: (10) y: (-95)\n    end\nend\nif <(Level) = [23]> then\n    repeat until <(Level) = [24]>\n        go to x: (-50) y: (-95)\n        show\n        switch costume to (left v)\n        glide (6) secs to x: (-240) y: (-95)\n        switch costume to (right v)\n        glide (6) secs to x: (-50) y: (-95)\n    end\nend\nif <(Level) = [24]> then\n    repeat until <(Level) = [25]>\n        go to x: (140) y: (-62)\n        show\n        switch costume to (left v)\n        glide (6) secs to x: (-80) y: (-62)\n        switch costume to (right v)\n        glide (6) secs to x: (140) y: (-62)\n    end\nend\nif <(Level) = [25]> then\n    repeat until <(Level) = [26]>\n        go to x: (50) y: (-115)\n        show\n        switch costume to (left v)\n        glide (3) secs to x: (-140) y: (-115)\n        switch costume to (right v)\n        glide (3) secs to x: (50) y: (-115)\n    end\nend\nhide\n\nwhen I receive [next level v]\ndelete this clone\n\n@Stars\n\nwhen I start as a clone\ngo to [back v] layer\nset size to (100) %\nset [brightness v] effect to (0)\nset [ghost v] effect to (100)\ngo to (random position v)\nshow\nrepeat (10)\n    change [ghost v] effect by (-7)\n    change [brightness v] effect by (10)\n    change size by (-1)\nend\nwait (0.4) seconds\ndelete this clone\n\nwhen flag clicked\nhide\nforever\n    switch costume to (pick random (1) to (3))\n    create clone of (_myself_ v)\n    wait (pick random (0.1) to (0.03)) seconds\nend\n\n@Transition\n\nwhen I receive [next level v]\ngo to x: (0) y: (0)\nshow\nglide (0.5) secs to x: (1000) y: (0)\nhide\n\nwhen flag clicked\nhide\n\n@Rocketship\n\nwhen flag clicked\nplay sound [Space Noise v] until done\nplay sound [Space Noise v] until done\nplay sound [Space Noise v] until done\nplay sound [Space Noise v] until done\n\nwhen flag clicked\nrepeat (40)\n    turn right (1) degrees\n    change size by (1)\n    wait (0.05) seconds\nend\n\nwhen flag clicked\nswitch costume to (1 v)\nrepeat (3)\n    switch costume to (2 v)\n    start sound [Alarm v]\n    wait (0.5) seconds\n    stop all sounds\n    switch costume to (1 v)\n    wait (0.5) seconds\nend\n\nwhen flag clicked\nshow\nswitch costume to (1 v)\ngo to x: (-200) y: (-100)\nset size to (50) %\npoint in direction (135)\nglide (5) secs to x: (300) y: (0)\nstop all sounds\nstart sound [Boom v]\nhide\nwait (0.05) seconds\nbroadcast (Intro 2 v)\n\n@Fire\n\nwhen flag clicked\nswitch costume to (intro v)\nclear graphic effects\nhide\nwait (0.1) seconds\nforever\n    create clone of (_myself_ v)\n    wait (0.08) seconds\nend\n\nwhen I start as a clone\ngo to (rocketship v)\nwait (0.1) seconds\nshow\nrepeat (10)\n    change size by (-3.25)\n    change x by (-10)\n    change y by (pick random (4) to (-4))\n    change [brightness v] effect by (1)\nend\nrepeat (26)\n    change size by (-3.25)\n    change x by (-10)\n    change y by (pick random (4) to (-4))\n    change [brightness v] effect by (0.5)\nend\ndelete this clone\n\nwhen I receive [intro 2 v]\nstop [other scripts in sprite v]\ndelete this clone\n\n@Intro 2\n\nwhen I receive [intro 2 v]\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nswitch costume to (1 v)\nshow\nrepeat (100)\n    change [ghost v] effect by (-1)\nend\nswitch costume to (2 v)\nwait (0.5) seconds\nswitch costume to (3 v)\nwait (0.5) seconds\nswitch costume to (4 v)\nwait (0.5) seconds\nswitch costume to (5 v)\n\nwhen flag clicked\nhide\n\nwhen I receive [start v]\nhide\n\n@Start Button\n\nwhen I receive [intro 2 v]\nwait until <([costume name v] of [intro 2 v]) = [5]>\nset [ghost v] effect to (100)\nshow\nrepeat (100)\n    change [ghost v] effect by (-1)\nend\n\nwhen I receive [start v]\nhide\n\nwhen this sprite clicked\nif <mouse down?> then\n    start sound [Click v]\n    broadcast (Start v)\n    hide\nend\n\nwhen I receive [intro 2 v]\nforever\n    if <not <mouse down?>> then\n        if <touching (mouse-pointer v)?> then\n            if <not <(size) = [120]>> then\n                repeat until <(size) = [120]>\n                    change size by (1)\n                end\n            end\n        else\n            if <not <(size) = [100]>> then\n                repeat until <(size) = [100]>\n                    change size by (-1)\n                end\n            end\n        end\n    end\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        if <(size) = [120]> then\n            repeat until <(size) = [100]>\n                change size by (-1)\n            end\n        else\n            wait until <(size) = [120]>\n            repeat until <(size) = [100]>\n                change size by (-1)\n            end\n        end\n    end\nend\n\nwhen flag clicked\nhide\n\n@Skip / Previous Level\n\nwhen I start as a clone\nswitch costume to (redo v)\ngo to x: (-130) y: (-162)\nset size to (100) %\nshow\nforever\n    if <touching (mouse-pointer v)?> then\n        repeat until <(size) = [120]>\n            change size by (1)\n        end\n    else\n        repeat until <(size) = [100]>\n            change size by (-1)\n        end\n    end\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        if <(size) = [120]> then\n            repeat until <(size) = [100]>\n                change size by (-1)\n            end\n        else\n            wait until <(size) = [120]>\n            repeat until <(size) = [100]>\n                change size by (-1)\n            end\n        end\n    end\nend\n\nwhen I receive [start v]\ngo to x: (-180) y: (-162)\nswitch costume to (skip v)\nshow\ncreate clone of (_myself_ v)\nforever\n    if <touching (mouse-pointer v)?> then\n        repeat until <(size) = [120]>\n            change size by (1)\n        end\n    else\n        repeat until <(size) = [100]>\n            change size by (-1)\n        end\n    end\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        if <(size) = [120]> then\n            repeat until <(size) = [100]>\n                change size by (-1)\n            end\n            start sound [Click v]\n        else\n            wait until <(size) = [120]>\n            repeat until <(size) = [100]>\n                change size by (-1)\n            end\n            start sound [Click v]\n        end\n    end\nend\n\nwhen this sprite clicked\nif <<touching (mouse-pointer v)?> and <mouse down?>> then\n    if <(costume [name v]) = [Skip]> then\n        broadcast (Next Level v)\n    else\n        broadcast (Restart Level v)\n    end\n    wait (0.1) seconds\nend\n\nwhen flag clicked\nhide\n\n@Sound Button\n\nwhen I receive [start v]\ngo to x: (-230) y: (-162)\nset [sound v] to [On]\nswitch costume to (on v)\nshow\n\nwhen I receive [start v]\nforever\n    if <not <<(Sound) = [Off]> and <(costume [name v]) = [Off]>>> then\n        play sound [Owl-City-Fireflies-Instrumental-\(Remake-by-Mike-Kalombo\)-for-Spoofers-Parodies-Youtubecovers\[www.savevid.com\]\(1\) v] until done\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen [m v] key pressed\nif <(costume [name v]) = [On]> then\n    set [sound v] to [Off]\n    switch costume to (off v)\n    stop all sounds\n    wait (0.1) seconds\nelse\n    set [sound v] to [On]\n    switch costume to (on v)\n    wait (0.1) seconds\nend\n\nwhen I receive [start v]\nforever\n    if <touching (mouse-pointer v)?> then\n        repeat until <(size) = [120]>\n            change size by (1)\n        end\n    else\n        repeat until <(size) = [100]>\n            change size by (-1)\n        end\n    end\nend\n\nwhen I receive [start v]\nforever\n    switch costume to (Sound)\nend\n\nwhen I receive [start v]\nforever\n    if <<touching (mouse-pointer v)?> and <mouse down?>> then\n        if <(costume [name v]) = [On]> then\n            set [sound v] to [Off]\n            stop all sounds\n            switch costume to (off v)\n            wait (0.1) seconds\n        else\n            set [sound v] to [On]\n            switch costume to (on v)\n            wait (0.1) seconds\n        end\n    end\nend\n\n@Finished\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\n\nwhen I receive [start v]\nclear graphic effects\nhide\n\nwhen I receive [you did it! v]\nset [ghost v] effect to (100)\nshow\nrepeat (80)\n    change [ghost v] effect by (-1)\nend\n\n@Moon/Earth\n\nwhen flag clicked\nswitch costume to (moon v)\nset size to (100) %\nshow\ngo to x: (240) y: (-190)\nglide (3) secs to x: (200) y: (-170)\n\nwhen I receive [start v]\nswitch costume to (earth v)\nset size to (100) %\ngo to x: (0) y: (0)\nshow\n\nwhen I receive [intro 2 v]\nhide\n\nwhen flag clicked\nrepeat (100)\n    change size by (1)\nend\n\n@Thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\n