EARTH – A Scrolling Platformer

Instructions: Oh no! You're lost in space! Can you find a way back to Earth? Arrow keys to move.\n

@Stage\n\n@blank\n\n@platform\n\ndefine set size to (dimensions)\nswitch costume to (0 v)\nset size to (dimensions) %\nnext costume\n\nwhen flag clicked\nset [xpos v] to [0]\nset [debug y? v] to [false]\nset [platform ypos v] to [0]\nset [jump v] to [0]\nset [jump speed v] to [1]\nset [jump power v] to [15]\nset [jumping? v] to [false]\nset [falling? v] to [false]\ngo to x: (xpos) y: ((platform ypos) - (3))\npoint in direction (90)\nset size to [600]\nshow\nforever\n    if <(y position) > [290]> then\n        broadcast (whoop v)\n    end\nend\n\nwhen I receive [whoop v]\ngo to x: (xpos) y: ((platform ypos) - (3))\n\ndefine debug ypos\nrepeat until <not <touching (toy v)?>>\n    change y by (-0.5)\nend\n\ndefine jump\nset [jumping? v] to [true]\nset [jump v] to (() - (jump power))\nrepeat (jump power)\n    change [jump v] by (jump speed)\n    change y by (jump)\nend\nset [jumping? v] to [false]\nfall\n\n\n    set [jump v] to [0]\nend\n\n\ndefine fall\nset [falling? v] to [true]\nrepeat until <touching (toy v)?>\n    change [jump v] by (() - (jump speed))\n    change y by (() - (jump))\nend\nset [falling? v] to [false]\n\nset [color v] effect to (0)\n\nwhen flag clicked\n\nforever\n    if <<not <key (up arrow v) pressed?>> and <(jumping?) = <[0] = [1]>>> then\n        fall\n    end\nend\n\nfall\n\nwhen flag clicked\nforever\n    if <key (up arrow v) pressed?> then\n        jump\n    end\nend\n\n\n\nwhen flag clicked\nset [speed v] to [1.8]\nforever\n    if <key (left arrow v) pressed?> then\n        change [velocityx v] by (Speed)\n    end\n    if <key (right arrow v) pressed?> then\n        change [velocityx v] by (() - (Speed))\n    end\n    set [velocityx v] to ((VelocityX) * (0.75))\n    change x by (VelocityX)\nend\n\nbroadcast (whoop v)\n\nwhen I receive [end v]\nhide\nstop [other scripts in sprite v]\nstop [this script v]\n\n\n\nwait until <touching (toy v)?>\n\nwhen flag clicked\ndebug ypos\n\nforever\n\ndebug ypos\n\ndefine change size by (var)\nswitch costume to (0 v)\nchange size by (var)\nnext costume\n\nset size to (100) %\n\nset y to (-386)\n\ndebug ypos 2\n\ndefine debug ypos 2\nrepeat until <touching (toy v)?>\n    change y by (0.5)\nend\n\ndebug ypos\n\nwait (0.1) seconds\nfall\n\nwait (0.2) seconds\n\nwait (0.2) seconds\n\nfall\n\ndebug ypos\n\ndebug ypos\n\nwait until <touching (toy v)?>\n\nwhen flag clicked\nforever\n    if <<(jumping?) = <[0] = [1]>> and <(falling?) = <[0] = [1]>>> then\n        debug ypos\n        debug ypos 2\n    end\nend\n\nturn right (() / (6)) degrees\n\n@toy\n\nwhen I receive [start v]\n\nnext costume\n\nif <(costume [number v]) = [1]> then\n    next costume\nend\n\n\n\nset size to (100) %\npoint in direction (90)\nset rotation style [all around v]\nrepeat (10)\n    turn right (1) degrees\n    change size by (-1)\n    move (-0.5) steps\nend\n\nwhen flag clicked\ngo to x: (0) y: (platform ypos)\nset rotation style [left-right v]\npoint in direction (90)\nset size to (75) %\nshow\nforever\n    point in direction ((VelocityX) * (-2))\nend\n\nwait until <touching (platform v)?>\n\nwhen flag clicked\nforever\n    if <touching color (#f38100)?> then\n        broadcast (whoop v)\n    end\nend\n\n\n\ndefine whoop\n\nwhen I receive [end v]\nhide\n\nwhen flag clicked\nwait (5) seconds\nforever\n    if <<touching color (#74b140)?> or <touching color (#0077b8)?>> then\n        broadcast (end v)\n    end\nend\n\n\n\nturn left (15) degrees\n\nwhen flag clicked\nforever\n    if <([floor v] of ([abs v] of (VelocityX) ) ) = [0]> then\n        switch costume to (dot-a v)\n    else\n        wait (0.05) seconds\n        switch costume to ((costume [number v]) + ([floor v] of ([abs v] of ((VelocityX) / (2)) ) ))\n    end\nend\n\n@room\n\nwhen I start as a clone\n\ncreate clone of (_myself_ v)\n\nrepeat (10)\n\nwhen flag clicked\nshow\ngo to [back v] layer\nset [sensitivity v] to [10]\nset size to [200]\nset [brightness v] effect to (0)\nshow\npoint in direction (90)\nforever\n    glide (0) secs to x: (round (([x position v] of [platform v]) / (sensitivity))) y: (round (([y position v] of [platform v]) / (sensitivity)))\nend\n\nturn left (VelocityX) degrees\n\ndefine set size to (dimensions)\nswitch costume to (0 v)\nset size to (dimensions) %\nnext costume\n\nwhen I receive [end v]\nhide\n\npoint in direction (90)\n\n@end\n\ndefine Smooth Glide x: (x) y: (y) speed: (speed)\nrepeat until <<(round (x position)) = (round (x))> and <(round (y position)) = (round (y))>>\n    change x by (((round (x)) - (round (x position))) / (speed))\n    change y by (((round (y)) - (round (y position))) / (speed))\nend\ngo to x: (x) y: (y)\n\nwhen I receive [end v]\nwait (0.6) seconds\ngo to [front v] layer\ngo to [front v] layer\ngo to [front v] layer\nshow\nSmooth Glide x: (0) y: (0) speed: (20)\n\nwhen flag clicked\ngo to x: (0) y: (346)\nhide\n\n@thumbnail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nshow\ngo to [front v] layer\nset [ghost v] effect to (0)\nwait (1.2) seconds\nrepeat (33)\n    change [ghost v] effect by (3)\nend\nset [ghost v] effect to (100)\n\nwhen flag clicked\nforever\n    play sound [Vexento - Masked Heroes\(1\).mp3 v] until done\nend\n\n