Sky brush: a Platformer

Instructions: ★~~~~~~~~~Welcome to Skybrush!~~~~~~~~~~★\n★Wasd and mobile controls, and the rest of the instructions are in the project.\n#61 on trending! Pretty low, but hey! At least I’m there!

@Stage\n\nwhen flag clicked\nforever\n    play sound [Cat v] until done\nend\n\n@Player\n\ndefine Touch Ground <up?>\nchange [falling? v] by (1)\nrepeat until <not <touching color (#000000)?>>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    set [speed y v] to [0]\nend\n\ndefine Walk (direction) (speed)\npoint in direction (direction)\nchange x by (speed)\nset [slope v] to [0]\nrepeat until <<(slope) = [8]> or <not <touching color (#000000)?>>>\n    change y by (1)\n    change [slope v] by (1)\nend\nif <(slope) = [8]> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\n    if <<<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>> and <([abs v] of (speed) ) > [3]>> then\n        if <(wall jump) = [0]> then\n            set [speed x v] to ((-1.2) * (speed))\n            set [speed y v] to [11]\n            set [falling? v] to [6]\n            set [wall jump v] to [15]\n        end\n    else\n        set [speed x v] to [0]\n    end\nend\nif <(speed) < [0]> then\n    change [frame v] by ((speed) / (-8))\nelse\n    change [frame v] by ((speed) / (8))\nend\n\ndefine Set Costume\nswitch costume to (costume1 v)\n\nwhen I receive [green flag clicked v]\nset size to (100) %\nset rotation style [left-right v]\ngo to x: (-241) y: (100)\nshow\nset [speed y v] to [0]\nset [falling? v] to [10]\nforever\n    switch costume to (hitbox v)\n    if <<(speed y) < [4]> or <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>> then\n        change [speed y v] by (-1)\n    else\n        change [speed y v] by (-2)\n    end\n    change y by (speed y)\n    Touch Ground <(speed y) > [0]>\n    if <(wall jump) > [0]> then\n        change [wall jump v] by (-1)\n    else\n        set [speed x v] to ((speed x) * (0.7))\n        if <<key (a v) pressed?> or <<mouse down?> and <(x position) > (mouse x)>>> then\n            change [speed x v] by (-1.5)\n        end\n        if <<key (d v) pressed?> or <<mouse down?> and <(mouse x) > (x position)>>> then\n            change [speed x v] by (1.5)\n        end\n    end\n    if <(speed x) < [-0.5]> then\n        Walk (-90) (speed x)\n    else\n        if <(speed x) > [0.5]> then\n            Walk (90) (speed x)\n        else\n            set [frame v] to [0]\n        end\n    end\n    if <<key (w v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>> then\n        if <<(jump key) = [0]> and <(falling?) < [3]>> then\n            set [speed y v] to [14]\n            set [falling? v] to [6]\n            set [jump key v] to [1]\n        end\n    else\n        set [jump key v] to [0]\n    end\n    if <(y position) < [-180]> then\n        go to x: (-241) y: (100)\n        set [speed y v] to [0]\n        erase all\n    end\n    if <(x position) > [230]> then\n        change [level v] by (1)\n        go to x: (-241) y: (100)\n        set [speed y v] to [0]\n        erase all\n        broadcast (Next level v)\n    end\n    if <touching (saws v)?> then\n        switch costume to (costume1 v)\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        clear graphic effects\n        go to x: (-241) y: (100)\n        set [speed y v] to [0]\n        erase all\n    end\n    Set Costume\nend\n\nwhen flag clicked\nset [level v] to [1]\nbroadcast (Green Flag clicked v)\n\n@Pen ground\n\nwhen flag clicked\nset pen size to (16)\nerase all\nset pen color to (#000000)\nforever\n    pen up\n    if <(Button pressed?) = [1]> then\n        Paint \n    end\nend\n\ndefine Paint \ngo to x: ([x position v] of [player v]) y: (([y position v] of [player v]) - (9))\npen down\n\n@Buttons\n\nwhen flag clicked\ngo to [front v] layer\nset [ghost v] effect to (20)\nset size to (75) %\ngo to x: (171) y: (-50)\nswitch costume to (paint v)\ncreate clone of (_myself_ v)\nset [button pressed? v] to [0]\nforever\n    wait until <<mouse down?> and <touching (mouse-pointer v)?>>\n    wait until <not <<mouse down?> and <touching (mouse-pointer v)?>>>\n    switch costume to (paint \(selected\) v)\n    set [button pressed? v] to [1]\n    wait until <<mouse down?> and <touching (mouse-pointer v)?>>\n    wait until <not <<mouse down?> and <touching (mouse-pointer v)?>>>\n    switch costume to (paint v)\n    set [button pressed? v] to [0]\nend\n\nwhen I start as a clone\nswitch costume to (clear v)\ngo to x: (171) y: (-100)\nforever\n    wait until <<mouse down?> and <touching (mouse-pointer v)?>>\n    wait until <not <<mouse down?> and <touching (mouse-pointer v)?>>>\n    erase all\n    switch costume to (clear \(selected\) v)\n    wait (0.1) seconds\n    switch costume to (clear v)\nend\n\n@Level ground\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen I receive [next level v]\nnext costume\n\n@Text\n\nwhen I receive [next level v]\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\n@Saws\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nshow\nforever\n    turn right (10) degrees\nend\n\nwhen I receive [next level v]\nif <(Level) = [1]> then\n    broadcast (Delete clones v)\nelse\n    if <(Level) = [2]> then\n        broadcast (Delete clones v)\n    else\n        if <(Level) = [3]> then\n            go to x: (-156) y: (43)\n            create clone of (_myself_ v)\n            go to x: (-8) y: (-50)\n            create clone of (_myself_ v)\n            go to x: (184) y: (45)\n            create clone of (_myself_ v)\n        else\n            if <(Level) = [4]> then\n                broadcast (Delete clones v)\n            else\n                if <(Level) = [5]> then\n                    broadcast (Loading v)\n                    Create tunnel with a length of [10] and a gap of [140]\n                else\n                    if <(Level) = [6]> then\n                        broadcast (Delete clones v)\n                        go to x: (152) y: (76)\n                        create clone of (_myself_ v)\n                        go to x: (151) y: (-102)\n                        create clone of (_myself_ v)\n                    else\n                        broadcast (Delete clones v)\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine Create tunnel with a length of (length) and a gap of (gap size)\ngo to x: (-121) y: (237)\nrepeat (length)\n    repeat (3)\n        create clone of (_myself_ v)\n        change y by (-40)\n    end\n    change y by ((0) - (gap size))\n    repeat (3)\n        create clone of (_myself_ v)\n        change y by (-40)\n    end\n    go to x: ((x position) + (40)) y: (237)\nend\nbroadcast (Not loading v)\n\nwhen I receive [delete clones v]\ndelete this clone\n\n@Loading...\n\nwhen flag clicked\nhide\nforever\n    next costume\n    wait (0.5) seconds\nend\n\nwhen I receive [loading v]\nshow\n\nwhen I receive [not loading v]\nhide\n\n@Thumbnail\n\nwhen flag clicked\nforever\n    set [ghost v] effect to (100)\n    go to [front v] layer\nend\n\n