Platformer

Instructions: Arrow Keys to move,\nAvoid spikes and lava,\n\nS AND R TO SKIP AND RESTART\n

@Stage\n\n@Sprite1\n\nwhen flag clicked\nshow\nset [level v] to [1]\nbroadcast (Start level v)\n\nwhen I receive [start level v]\nset [jumping v] to [false]\nset [x velocity v] to [0]\nset [y velocity v] to [0]\nforever\n    change [y velocity v] by (-1)\n    if <key (left arrow v) pressed?> then\n        if <(X Velocity) > [-10]> then\n            change [x velocity v] by (-2)\n        end\n        if <(costume [number v]) = [1]> then\n            switch costume to (2 v)\n        else\n            switch costume to (1 v)\n        end\n    end\n    if <key (right arrow v) pressed?> then\n        if <(X Velocity) < [10]> then\n            change [x velocity v] by (2)\n        end\n        if <(costume [number v]) = [3]> then\n            switch costume to (4 v)\n        else\n            switch costume to (3 v)\n        end\n    end\n    if <(X Velocity) < [0]> then\n        change [x velocity v] by (1)\n    end\n    if <(X Velocity) > [0]> then\n        change [x velocity v] by (-1)\n    end\n    change x by (X Velocity)\n    Move Verticle\n    Move Horizontally\n    if <touching color (#000000)?> then\n        broadcast (Next Level v)\n    end\n    if <<(y position) < [-179]> or <touching color (#ff0000)?>> then\n        broadcast (Start level v)\n    end\nend\n\ndefine Move Verticle\nchange y by (Y Velocity)\nif <touching color (#00ff5f)?> then\n    if <(Y Velocity) > [0]> then\n        repeat until <not <touching color (#00ff5f)?>>\n            change y by (-1)\n        end\n    else\n        repeat until <not <touching color (#00ff5f)?>>\n            change y by (1)\n        end\n        set [jumping v] to [false]\n    end\n    set [y velocity v] to [0]\nend\n\ndefine Move Horizontally\nif <touching color (#00ff5f)?> then\n    if <(X Velocity) > [0]> then\n        repeat until <not <touching color (#00ff5f)?>>\n            change x by (-2)\n        end\n    else\n        repeat until <not <touching color (#00ff5f)?>>\n            change x by (2)\n        end\n    end\n    set [x velocity v] to [0]\nend\n\nwhen [up arrow v] key pressed\nif <(Jumping) = [false]> then\n    set [y velocity v] to [15]\n    set [jumping v] to [true]\nend\n\nwhen I receive [start level v]\nif <(Level) = [1]> then\n    go to x: (-163) y: (-115)\n    switch backdrop to (backdrop1 v)\nend\nif <(Level) = [2]> then\n    go to x: (155) y: (-113)\n    switch backdrop to (backdrop2 v)\nend\nif <(Level) = [3]> then\n    go to x: (-196) y: (152)\n    switch backdrop to (backdrop3 v)\nend\nif <(Level) = [4]> then\n    go to x: (-181) y: (150)\n    switch backdrop to (backdrop4 v)\nend\nif <(Level) = [5]> then\n    go to x: (-188) y: (145)\n    switch backdrop to (backdrop5 v)\nend\nif <(Level) = [6]> then\n    go to x: (-208) y: (-139)\n    switch backdrop to (backdrop6 v)\nend\nif <(Level) = [7]> then\n    go to x: (-213) y: (-143)\n    switch backdrop to (backdrop7 v)\nend\nif <(Level) = [8]> then\n    go to x: (-206) y: (-140)\n    switch backdrop to (backdrop8 v)\nend\nif <(Level) = [9]> then\n    hide\n    switch backdrop to (end v)\n    wait (0.1) seconds\n    stop [all v]\nend\n\nwhen I receive [next level v]\nchange [level v] by (1)\nstop [other scripts in sprite v]\nbroadcast (Start level v)\n\nwhen [s v] key pressed\nbroadcast (Next Level v)\n\nwhen [r v] key pressed\nbroadcast (Start level v)\n\nwhen I receive [start level v]\nforever\n    change [color v] effect by (25)\nend\n\nwhen I receive [start level v]\nplay sound [Kalimba v] until done\nchange [pan left/right v] effect by (10)\n\n@Sprite2\n\nwhen flag clicked\nhide\n\nwhen I receive [start level v]\nstop [other scripts in sprite v]\nif <(Level) = [3]> then\n    show\nelse\n    hide\nend\nMove\n\ndefine Move\ngo to x: (26) y: (-186)\nforever\n    glide (1) secs to x: (10) y: (36)\n    glide (1) secs to x: (26) y: (-186)\nend\n\n