Cloud 9 - A Stickman Platformer

Instructions: Cloud 9 - A Stickman Platformer\n\nArrow Keys to move\n\nNext Game of the series: https://scratch.mit.edu/projects/821104243/\n\nI wanted to make a non generic plaformer so here you go.

@Stage\n\nwhen flag clicked\nforever\n    play sound [Starship v] until done\nend\n\n@Trampoline\n\nwhen flag clicked\nforever\n    if <<<(Level) = [1]> or <(Level) = [2]>> or <(Level) = [3]>> then\n        hide\n    end\n    if <(Level) = [4]> then\n        switch costume to (4 v)\n        show\n        go to x: (12) y: (-73)\n    end\n    if <(Level) = [5]> then\n        switch costume to (5 v)\n        show\n        go to x: (12) y: (-73)\n    end\n    if <(Level) = [6]> then\n        switch costume to (6 v)\n        show\n        go to x: (12) y: (-73)\n    end\n    if <(Level) = [7]> then\n        switch costume to (7 v)\n        show\n        go to x: (12) y: (-73)\n    end\n    if <(Level) = [8]> then\n        switch costume to (8 v)\n        show\n        go to x: (12) y: (-73)\n    end\nend\n\nwhen I receive [end v]\nhide\n\n@Player\n\nwhen flag clicked\nshow\ngo to [front v] layer\ngo to x: (-141) y: (19)\nset [x v] to [0]\nset [y v] to [0]\nset [level v] to [1]\npoint in direction (-90)\nforever\n    Platform (-1) (12) (0.7) (3)\n    if <touching (flag v)?> then\n        go to x: (-141) y: (19)\n        set [x v] to [0]\n        set [y v] to [0]\n        change [level v] by (1)\n    end\n    if <touching (spike v)?> then\n        go to x: (-141) y: (19)\n        set [x v] to [0]\n        set [y v] to [0]\n    end\n    if <touching (trampoline v)?> then\n        set [y v] to [17]\n    end\n    if <(Level) > [8]> then\n        hide\n        broadcast (end v) and wait\n        stop [all v]\n    end\nend\n\ndefine Platform (gravity) (jump height) (friction) (running speed)\nswitch costume to (hibox v)\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [x v] by (running speed)\n    point in direction (90)\nend\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [x v] by ((running speed) * (gravity))\n    point in direction (-90)\nend\nset [x v] to ((x) * (friction))\nchange x by (x)\nif <touching (level v)?> then\n    set [slope v] to [0]\n    repeat until <<(slope) = [8]> or <not <touching (level v)?>>>\n        change [slope v] by (1)\n        change y by (1)\n    end\n    if <touching (level v)?> then\n        change y by ((slope) * (gravity))\n        repeat ([ceiling v] of ([abs v] of (x) ) )\n            if <touching (level v)?> then\n                change x by ((([abs v] of (x) ) / (x)) * (gravity))\n            end\n        end\n        set [x v] to [0]\n    end\nend\nchange y by (y)\nif <touching (level v)?> then\n    repeat ([ceiling v] of ([abs v] of (y) ) )\n        if <touching (level v)?> then\n            change y by ((([abs v] of (y) ) / (y)) * (gravity))\n        end\n    end\n    set [y v] to (<<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <(([abs v] of (y) ) / (y)) = (gravity)>> * (jump height))\nelse\n    change [y v] by (gravity)\nend\nswitch costume to (idle v)\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<key (right arrow v) pressed?> or <key (d v) pressed?>>> then\n    switch costume to (walk)\nend\nif <(y) > [4]> then\n    switch costume to (jump v)\nend\nif <(y) < [-4]> then\n    switch costume to (fall v)\nend\n\nwhen flag clicked\nset [walk v] to [5]\nforever\n    change [walk v] by (1)\n    if <(walk) > [8]> then\n        set [walk v] to [5]\n    end\n    wait (.1) seconds\nend\n\n@Level\n\nwhen flag clicked\nforever\n    switch costume to (Level)\nend\n\n@TB\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\n@Flag\n\nwhen flag clicked\nshow\nforever\n    go to x: (0) y: (0)\n    switch costume to (Level)\nend\n\n@Spike\n\nwhen flag clicked\nforever\n    switch costume to (Level)\nend\n\n