Colour - A platformer

Instructions: Arrow keys to move, and try to get to the end!

@Stage\n\nwhen flag clicked\nforever\n    play sound [song \(1\) v] until done\nend\n\n@Sprite1\n\ndefine y\nchange y by (y)\nif <touching color (#000000)?> then\n    if <(y) < [0]> then\n        if <(y) < [-2]> then\n            set [y v] to ((0) - ((y) * (0.2)))\n        else\n            set [y v] to [0]\n        end\n        repeat until <not <touching color (#000000)?>>\n            change y by (1)\n        end\n        change y by (0)\n        if <key (up arrow v) pressed?> then\n            if <(y) < [15]> then\n                change [y v] by (15)\n            end\n        end\n    else\n        set [y v] to [0]\n        repeat until <not <touching color (#000000)?>>\n            change y by (-1)\n        end\n    end\nelse\n    change [y v] by (-1)\nend\n\ndefine x\nchange x by (x)\nif <touching color (#000000)?> then\n    change x by ((0) - ((x) * (1.2)))\n    set [x v] to ((0) - (x))\n    set [y v] to [15]\nend\nif <key (right arrow v) pressed?> then\n    change [x v] by (1.5)\nend\nif <key (left arrow v) pressed?> then\n    change [x v] by (-1.5)\nend\nset [x v] to ((x) * (0.88))\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\nset [y v] to [0]\ngo to x: (-200) y: (-100)\nforever\n    x\n    y\n    if <<(y position) < [-179]> or <<touching color (#ffffff)?> or <touching color (#ff0000)?>>> then\n        go to x: (-200) y: (-100)\n        broadcast (delete AI clones v)\n    end\n    if <(x position) > [239]> then\n        go to x: (-200) y: (-100)\n        next backdrop\n    end\nend\n\n@Sprite2\n\nwhen flag clicked\nhide\n\nwhen backdrop switches to [backdrop4 v]\nswitch costume to (costume1 v)\nshow\ngo to x: (-5) y: (0)\nset size to (100) %\nset [sin v] to [0]\nrepeat until <touching (sprite1 v)?>\n    change [sin v] by (7)\n    change size by ([cos v] of (sin) )\n    change y by ([sin v] of (sin) )\n    turn right (5) degrees\nend\nrepeat (10)\n    change [sin v] by (7)\n    change size by ([cos v] of (sin) )\n    change y by ([sin v] of (sin) )\n    turn right (5) degrees\n    change [brightness v] effect by (10)\n    change [ghost v] effect by (10)\nend\nhide\nclear graphic effects\n\nwhen backdrop switches to [backdrop9 v]\nswitch costume to (costume2 v)\nshow\ngo to x: (5) y: (0)\nset size to (75) %\nset [sin v] to [0]\nrepeat until <touching (sprite1 v)?>\n    change [sin v] by (7)\n    change size by ([cos v] of (sin) )\n    change y by ([sin v] of (sin) )\n    turn right (5) degrees\nend\nrepeat (10)\n    change [sin v] by (7)\n    change size by ([cos v] of (sin) )\n    change y by ([sin v] of (sin) )\n    turn right (5) degrees\n    change [brightness v] effect by (10)\n    change [ghost v] effect by (10)\nend\nhide\nclear graphic effects\n\n@Sprite3\n\nwhen flag clicked\nhide\n\nwhen backdrop switches to [backdrop18 v]\ngo to x: (135) y: (-104)\nrepeat until <not <(backdrop [number v]) = [18]>>\n    wait (pick random (0.1) to (0.5)) seconds\n    go to x: (pick random (130) to (140)) y: (-104)\n    create clone of (_myself_ v)\n    set size to (pick random (10) to (100)) %\nend\nbroadcast (delete fire clones v)\n\nwhen I start as a clone\nshow\npoint in direction (0)\nrepeat (20)\n    move (2) steps\n    turn right (pick random (-3) to (3)) degrees\n    change [brightness v] effect by (5)\n    change [ghost v] effect by (5)\nend\ndelete this clone\n\nwhen backdrop switches to [backdrop19 v]\ngo to x: (135) y: (-104)\nrepeat until <not <(backdrop [number v]) = [19]>>\n    wait (pick random (0.1) to (0.5)) seconds\n    go to x: (pick random (130) to (140)) y: (-104)\n    create clone of (_myself_ v)\n    set size to (pick random (10) to (100)) %\nend\nbroadcast (delete fire clones v)\n\nwhen I receive [delete fire clones v]\ndelete this clone\n\nwhen backdrop switches to [backdrop20 v]\ngo to x: (147) y: (46)\nrepeat until <not <(backdrop [number v]) = [20]>>\n    wait (pick random (0.1) to (0.5)) seconds\n    go to x: (pick random (140) to (150)) y: (46)\n    create clone of (_myself_ v)\n    set size to (pick random (10) to (200)) %\nend\nbroadcast (delete fire clones v)\n\n@Sprite4\n\nwhen flag clicked\nhide\n\nwhen backdrop switches to [backdrop21 v]\ngo to x: (0) y: (-130)\nshow\nwait until <touching (sprite1 v)?>\nhide\nbroadcast (halo v)\n\n@Sprite5\n\nwhen flag clicked\nhide\n\nwhen I receive [halo v]\nshow\nset [sin v] to [0]\nswitch costume to (costume2 v)\nset size to (300) %\nswitch costume to (costume1 v)\nrepeat until <(backdrop [number v]) = [31]>\n    go to (sprite1 v)\nend\nhide\n\n@Sprite6\n\ndefine y\nchange y by (AI y)\nif <touching color (#000000)?> then\n    if <(AI y) < [0]> then\n        if <(AI y) < [-2]> then\n            set [ai y v] to ((0) - ((AI y) * (0.2)))\n        else\n            set [ai y v] to [0]\n        end\n        repeat until <not <touching color (#000000)?>>\n            change y by (1)\n        end\n        change y by (1)\n        if <<[0] = [0]> and <([y position v] of [sprite1 v]) > (y position)>> then\n            set [ai y v] to [10]\n        end\n    else\n        set [ai y v] to [0]\n        repeat until <not <touching color (#000000)?>>\n            change y by (-1)\n        end\n    end\nelse\n    change [ai y v] by (-1)\nend\n\ndefine x\nchange x by (AI x)\nif <touching color (#000000)?> then\n    change x by ((0) - ((AI x) * (1.2)))\n    set [ai x v] to ((0) - (AI x))\n    set [ai y v] to [15]\nend\nif <([x position v] of [sprite1 v]) > ((x position) + (pick random (-100) to (0)))> then\n    change [ai x v] by (pick random (0.1) to (0.6))\nend\nif <([x position v] of [sprite1 v]) < ((x position) + (pick random (0) to (100)))> then\n    change [ai x v] by (pick random (-0.1) to (-0.6))\nend\nset [ai x v] to ((AI x) * (0.92))\nif <([y position v] of [sprite1 v]) < (y position)> then\n    if <([x position v] of [sprite1 v]) > ((x position) + (pick random (-100) to (0)))> then\n        change [ai x v] by (pick random (0.4) to (0.8))\n    end\n    if <([x position v] of [sprite1 v]) < ((x position) + (pick random (0) to (100)))> then\n        change [ai x v] by (pick random (-0.4) to (-0.8))\n    end\nend\n\nwhen I start as a clone\nshow\nset [ai y v] to [0]\nset [ai x v] to [0]\nrepeat until <not <touching color (#000000)?>>\n    change y by (1)\nend\nrepeat until <not <([backdrop # v] of [_stage_ v]) = (level ID)>>\n    y\n    x\nend\ndelete this clone\n\nwhen backdrop switches to [backdrop32 v]\ngo to x: (183) y: (0)\nset [level id v] to ([backdrop # v] of [_stage_ v])\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nhide\n\nwhen backdrop switches to [backdrop33 v]\ngo to x: (35) y: (-122)\nset [level id v] to ([backdrop # v] of [_stage_ v])\ncreate clone of (_myself_ v)\n\nwhen backdrop switches to [backdrop34 v]\ngo to x: (150) y: (-40)\nset [level id v] to ([backdrop # v] of [_stage_ v])\ncreate clone of (_myself_ v)\n\nwhen backdrop switches to [backdrop35 v]\nset [level id v] to ([backdrop # v] of [_stage_ v])\ngo to x: (104) y: (-7)\ncreate clone of (_myself_ v)\ngo to x: (101) y: (-107)\ncreate clone of (_myself_ v)\ngo to x: (-11) y: (-113)\ncreate clone of (_myself_ v)\n\nwhen backdrop switches to [backdrop36 v]\nset [level id v] to ([backdrop # v] of [_stage_ v])\ngo to x: (181) y: (107)\ncreate clone of (_myself_ v)\n\nwhen backdrop switches to [backdrop37 v]\ngo to x: (10) y: (0)\nset [level id v] to ([backdrop # v] of [_stage_ v])\ncreate clone of (_myself_ v)\n\nwhen backdrop switches to [backdrop38 v]\nset [level id v] to ([backdrop # v] of [_stage_ v])\nrepeat (10)\n    wait (3) seconds\n    go to x: (-50) y: (106)\n    create clone of (_myself_ v)\nend\n\nwhen I receive [delete ai clones v]\nif <(backdrop [number v]) = [38]> then\n    delete this clone\nend\n\nwhen backdrop switches to [backdrop39 v]\nstop [other scripts in sprite v]\nset [level id v] to ([backdrop # v] of [_stage_ v])\nrepeat (75)\n    wait (0.1) seconds\n    go to x: (pick random (10) to (40)) y: (pick random (-150) to (-179))\n    create clone of (_myself_ v)\nend\n\n