Platformer

Instructions: Use the arrow keys to move, mobile friendly!\n\nto make work click sprite1and then click when i reiceive green flag clicked script.

@Stage\n\n@Ground\n\nwhen flag clicked\nswitch costume to (color pallete v)\n\nwhen flag clicked\nif <color (#1a1a1a) is touching (portal)?> then\n    next costume\nend\n\nwhen flag clicked\nforever\n    switch costume to (Level)\nend\n\nwhen flag clicked\nwait (5) seconds\nstart sound [Happy Music v]\n\n@Sprite1\n\ndefine Reset\npoint in direction (90)\nset size to (20) %\nset rotation style [left-right v]\nif <(Level) = [9]> then\n    go to x: (-200) y: (-100)\nelse\n    go to x: (-200) y: (0)\nend\nshow\nset [speed y v] to [0]\nset [falling? v] to [10]\n\nwhen I receive [green flag clicked v]\nbroadcast (Retry v)\nReset\nset [level v] to [1]\nforever\n    Platforming Engine\n    if <<touching (moving spikes up/down v)?> or <<touching (spikes v)?> or <touching (right/left v)?>>> then\n        switch costume to (die  v)\n        start sound [whoop v]\n        Go down\n        repeat (11)\n            next costume\n        end\n        repeat (20)\n            change [ghost v] effect by (5)\n        end\n        broadcast (Retry v)\n        set [ghost v] effect to (0)\n        go to x: (-200) y: (0)\n    end\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 (ground v)?>>>\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 <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>> and <([abs v] of (speed) ) > [3]>> then\n        start sound [Jump v]\n        if <(wall jump) = [0]> then\n            set [speed x v] to ((-1.2) * (speed))\n            set [max bounce v] to [11]\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\nwhen I receive [retry v]\nReset\n\nwhen I receive [next level v]\nReset\n\ndefine Set Costume\nif <(falling?) < [6]> then\n    if <(frame) = [0]> then\n        switch costume to ([floor v] of ((13) + ((Idle Frame) mod (15))) )\n        change [idle frame v] by (0.5)\n        set [frame v] to [0]\n    else\n        switch costume to ([floor v] of ((29) + ((frame) mod (15))) )\n    end\nelse\n    switch costume to ([floor v] of ((((15) / ((Max Bounce) * (2))) * ((speed y) + (Max Bounce))) + (45)) )\nend\n\ndefine Touch Ground <up?>\nchange [falling? v] by (1)\nrepeat until <not <touching (ground v)?>>\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 Go down\nrepeat until <touching (ground v)?>\n    change y by (-2)\nend\n\nwhen flag clicked\nset [level v] to [1]\n\ndefine Platforming Engine\nswitch costume to (hitbox v)\nif <<(speed y) < [4]> or <<key (w v) pressed?> or <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>>> then\n    change [speed y v] by (-1)\nelse\n    change [speed y v] by (-2)\nend\nchange y by (speed y)\nTouch Ground <(speed y) > [0]>\nif <(wall jump) > [0]> then\n    change [wall jump v] by (-1)\nelse\n    set [speed x v] to ((speed x) * (0.7))\n    if <<key (left arrow v) pressed?> or <<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 (right arrow v) pressed?> or <<key (d v) pressed?> or <<mouse down?> and <(mouse x) > (x position)>>>> then\n        change [speed x v] by (1.5)\n    end\nend\nif <(speed x) < [-0.5]> then\n    Walk (-90) (speed x)\nelse\n    if <(speed x) > [0.5]> then\n        Walk (90) (speed x)\n    else\n        set [frame v] to [0]\n    end\nend\nif <<key (w v) pressed?> or <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>> then\n    if <<(jump key) = [0]> and <(falling?) < [3]>> then\n        start sound [Jump v]\n        set [max bounce v] to [14]\n        set [speed y v] to [14]\n        set [falling? v] to [6]\n        set [jump key v] to [1]\n    end\nelse\n    set [jump key v] to [0]\nend\nif <(y position) < [-180]> then\n    go to x: (-200) y: (0)\n    broadcast (Retry v)\n    set [speed y v] to [0]\nend\nif <touching (portal v)?> then\n    start sound [Connect v]\n    go to x: (-200) y: (0)\n    change [level v] by (1)\n    Reset\n    broadcast (Next level v)\nend\nif <touching (bounce v)?> then\n    start sound [Jump v]\n    set [max bounce v] to [25]\n    set [speed y v] to [25]\nend\nif <(x position) < [-190]> then\n    set x to (-190)\nend\nif <<<key (w v) pressed?> or <<key (space v) pressed?> or <<key (up arrow v) pressed?> or <<mouse down?> and <(mouse y) > (y position)>>>>> and <touching (ladder v)?>> then\n    set [speed y v] to [5]\nend\nSet Costume\n\nwhen flag clicked\nforever\n    go to [front v] layer\nend\n\nwhen flag clicked\nshow\n\nwhen flag clicked\nforever\n    broadcast (shrink v)\nend\n\n@Spikes\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nwhen flag clicked\nif <color (#1a1a1a) is touching (portal)?> then\n    next costume\nend\n\nwhen flag clicked\nforever\n    switch costume to (Level)\nend\n\n@Portal\n\nwhen flag clicked\ncreate clone of (_myself_ v)\nforever\n    broadcast (Position Portal v)\n    turn left (10) degrees\nend\n\nwhen I start as a clone\nforever\n    turn right (10) degrees\nend\n\nwhen I receive [position portal v]\nPosition (((Level) mod (5)) + (0))\n\ndefine Position (level)\nshow\nif <(level) = [1]> then\n    go to x: (180) y: (-84)\nend\nif <(level) = [2]> then\n    go to x: (180) y: (-84)\nend\nif <(level) = [3]> then\n    go to x: (156) y: (21)\nend\nif <(level) = [5]> then\n    go to x: (200) y: (100)\n    show\nend\n\nif <(level) = [0]> then\n    go to x: (180) y: (40)\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [5]> then\n        hide\n    end\nend\n\n@Decor\n\nwhen flag clicked\nforever\n    switch costume to (Level)\nend\n\nwhen flag clicked\nif <color (#1a1a1a) is touching (portal)?> then\n    next costume\nend\n\n@Background for intro\n\nwhen flag clicked\nforever\n    show\n    go to [back v] layer\nend\n\nwhen I receive [green flag clicked v]\nhide\n\nwhen flag clicked\nbroadcast (Green Flag clicked v)\n\n@Sprite2\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\n    show\nend\n\n@Water\n\nwhen flag clicked\nclear graphic effects\ngo to x: (0) y: (0)\nset [me v] to [1]\nrepeat (3)\n    create clone of (_myself_ v)\n    change y by (-5)\n    change [brightness v] effect by (-10)\n    change [me v] by (1)\nend\n\nwhen I start as a clone\nshow\nforever\n    set [ghost v] effect to (50)\n    go to [back v] layer\n    switch costume to (Level)\n    set y to ((([sin v] of (((timer) + (me)) * (300)) ) * (8)) - ((me) * (5)))\nend\n\nwhen flag clicked\nif <[level] = [4]> then\n    go to [front v] layer\nend\n\n