Upside Down Platformer

Instructions: Double click green flag.\nArrow keys to move\nR to reset\nAvoid danger\n17 LEVELS!\nAND\n3 NEW LEVELS!\n\n\nThis took me 2461 seconds/ 41.016 mins/ 0.683 hrs/ 0.028 days/ 0.0009 months/ 0.00007 years/ 0.000007 decades/ 0.0000007 centuries to finish :)\n\nif you like reading, check this out!:\nhttps://scratch.mit.edu/projects/380798028\nif you like fighting games, check this out!\nhttps://scratch.mit.edu/projects/347822840\n\nUpdate Log:\nUpdate 7: Fixed broken text\nUpdate 6: Changed the Time Ranking in the Notes and credits, It was previously really hard to at least get a good\nUpdate 5: New thumbnail (showing the fact that this \n                                          wont get anymore updates)\nUpdate 4: Made new thumbnail (showing how buggy \n                this game is)\nFLIP SWITCH demo UPDATE!: added 3 new levels \n                                                   and a new mechanic!\nUpdate 2: Made new thumbnail (cuz im gettin followers \n                  from thin air)\nSpecial Update for @Aceyyyyyyyyyyyyy :) : Added new code to fix his sad glitch\nUpdate1: Fixed rotation bug\n\n\n\n\n\n[TESTING: TAGS]\n#platformer #platform #stickman #game #speedrun

@Stage\n\nwhen flag clicked\nforever\n    play sound [Upbeat and Happy Background Music v] until done\nend\n\n@reyalP\n\nwhen flag clicked\nforever\n    if <touching (latrop v)?> then\n        start sound [Teleport2 v]\n        go to x: (-204) y: (90)\n        change [level v] by (1)\n        set [x velocity v] to [0]\n        set [y velocity v] to [0]\n        set [slope v] to [0]\n    end\nend\n\nwhen [r v] key pressed\ngo to x: (-204) y: (90)\nset [your time: v] to [0]\nset [x velocity v] to [0]\nset [y velocity v] to [0]\nset [slope v] to [0]\n\nwhen flag clicked\n\nif <[USERNAME] = [Aceyyyyyyyyyyyyy]> then\n    set [☁ world best time: v] to [19.69]\n    say [Hello Aceyyyyyyyyyyyyy!] for (2) seconds\n    say [I hope that worked!] for (2) seconds\n    say [but I'll remove the code later] for (3) seconds\nend\n\ndefine Platform (jump height) (gravity) (friction) (running speed)\nswitch costume to (hitbox v)\nif <key (right arrow v) pressed?> then\n    change [x velocity v] by (running speed)\n    point in direction (90)\nend\nif <key (left arrow v) pressed?> then\n    point in direction (-90)\n    change [x velocity v] by ((running speed) * (-1))\nend\nset [x velocity v] to ((X Velocity) * (friction))\nchange x by (X Velocity)\nif <touching (dnuorg v)?> then\n    set [slope v] to [0]\n    repeat until <<(Slope) = [8]> or <not <touching (dnuorg v)?>>>\n        change [slope v] by (1)\n        change y by (1)\n    end\n    if <touching (dnuorg v)?> then\n        change y by ((Slope) * (-1))\n        repeat ([ceiling v] of ([abs v] of (X Velocity) ) )\n            if <touching (dnuorg v)?> then\n                change x by (([abs v] of (X Velocity) ) / ((X Velocity) * (-1)))\n            end\n        end\n        set [x velocity v] to [0]\n    end\nend\nchange [y velocity v] by (-1)\nchange y by (Y Velocity)\nif <touching (dnuorg v)?> then\n    repeat ([ceiling v] of ([abs v] of (Y Velocity) ) )\n        if <touching (dnuorg v)?> then\n            change y by (([abs v] of (Y Velocity) ) / ((Y Velocity) * (-1)))\n        end\n    end\n    if <<(([abs v] of (Y Velocity) ) / (Y Velocity)) = [-1]> and <key (up arrow v) pressed?>> then\n        start sound [C Trumpet \[Jump\]2 v]\n        set [y velocity v] to (jump height)\n    else\n        set [y velocity v] to [0]\n    end\nelse\n    change [y velocity v] by (-1)\nend\nset [idle v] to [1]\nswitch costume to (idle? v)\nif <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>> then\n    set [idle v] to [0]\n    switch costume to (join [Running?] (Running Costume 2))\nend\nif <(Y Velocity) > [2]> then\n    set [idle v] to [0]\n    switch costume to (jumping? v)\nend\n\nwhen flag clicked\nshow\n\nwhen flag clicked\nforever\n    set [running costume v] to [1]\n    wait (0.05) seconds\n    set [running costume v] to [2]\n    wait (0.05) seconds\nend\n\ndefine Platform2 (jump height) (gravity) (friction) (running speed)\nswitch costume to (hitbox v)\nif <<[11] > (Level)> or <<(Level) > [17]> or <(Level) = [17]>>> then\n    set rotation style [left-right v]\n    if <key (right arrow v) pressed?> then\n        change [x velocity v] by (running speed)\n        point in direction (90)\n    end\n    if <key (left arrow v) pressed?> then\n        point in direction (-90)\n        change [x velocity v] by ((running speed) * (-1))\n    end\nend\nif <<(Level) > [10]> and <[17] > (Level)>> then\n    set rotation style [all around v]\n    if <key (left arrow v) pressed?> then\n        change [x velocity v] by (running speed)\n        point in direction (-120)\n    end\n    if <key (right arrow v) pressed?> then\n        point in direction (90)\n        change [x velocity v] by ((running speed) * (-1))\n    end\nend\nset [x velocity v] to ((X Velocity) * (friction))\nchange x by (X Velocity)\nif <touching (dnuorg v)?> then\n    set [slope v] to [0]\n    repeat until <<(Slope) = [8]> or <not <touching (dnuorg v)?>>>\n        change [slope v] by (1)\n        change y by (-1)\n    end\n    if <touching (dnuorg v)?> then\n        change y by ((Slope) * (-1))\n        repeat ([ceiling v] of ([abs v] of (X Velocity) ) )\n            if <touching (dnuorg v)?> then\n                change x by (([abs v] of (X Velocity) ) / ((X Velocity) * (-1)))\n            end\n        end\n        set [x velocity v] to [0]\n    end\nend\nchange [y velocity v] by (1)\nchange y by (Y Velocity)\nif <touching (dnuorg v)?> then\n    repeat ([ceiling v] of ([abs v] of (Y Velocity) ) )\n        if <touching (dnuorg v)?> then\n            change y by (([abs v] of (Y Velocity) ) / ((Y Velocity) * (-1)))\n        end\n    end\n    if <<[11] > (Level)> or <<(Level) > [17]> or <(Level) = [17]>>> then\n        if <<(([abs v] of (Y Velocity) ) / (Y Velocity)) = [1]> and <key (up arrow v) pressed?>> then\n            start sound [C Trumpet \[Jump\]2 v]\n            set [y velocity v] to (jump height)\n        else\n            set [y velocity v] to [0]\n        end\n    end\n    if <<(Level) > [10]> and <[17] > (Level)>> then\n        if <<(([abs v] of (Y Velocity) ) / (Y Velocity)) = [1]> and <key (down arrow v) pressed?>> then\n            start sound [C Trumpet \[Jump\]2 v]\n            set [y velocity v] to (jump height)\n        else\n            set [y velocity v] to [0]\n        end\n    end\nelse\n    change [y velocity v] by (1)\nend\nif <<(Level) > [10]> and <[17] > (Level)>> then\n    set [idle v] to [1]\n    switch costume to (placeholder v)\n    if <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>> then\n        set [idle v] to [0]\n        switch costume to (placeholder v)\n    end\n    if <[-2] > (Y Velocity)> then\n        set [idle v] to [0]\n        switch costume to (placeholder v)\n    end\nend\nif <<[11] > (Level)> or <<(Level) > [17]> or <(Level) = [17]>>> then\n    set [idle v] to [1]\n    switch costume to (idle1 v)\n    if <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>> then\n        set [idle v] to [0]\n        switch costume to (join [Running] (Running Costume))\n    end\n    if <[-2] > (Y Velocity)> then\n        set [idle v] to [0]\n        switch costume to (jumping v)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (sdrazah v)?> then\n        start sound [Wobble v]\n        go to x: (-204) y: (90)\n        set [x velocity v] to [0]\n        set [y velocity v] to [0]\n        set [slope v] to [0]\n    end\nend\n\nwhen flag clicked\n\nwhen flag clicked\ngo to x: (-204) y: (90)\nset [x velocity v] to [0]\nset [y velocity v] to [0]\nset [slope v] to [0]\nforever\n    if <(FLIP) = [1]> then\n        Platform2 (-20) (1) (0.7) (5)\n    end\n    if <(FLIP) = [-1]> then\n        Platform (20) (1) (0.7) (5)\n    end\nend\n\nwhen I receive [flip! v]\npoint in direction ((direction) * (-1))\n\nwhen flag clicked\nforever\n    set [running costume 2 v] to [1]\n    wait (0.05) seconds\n    set [running costume 2 v] to [2]\n    wait (0.05) seconds\nend\n\n@dnuorG\n\nwhen flag clicked\ngo to x: (0) y: (0)\n\nwhen flag clicked\npoint in direction (90)\nforever\n    switch costume to (Level)\nend\n\nwhen I receive [shake v]\nrepeat (10)\n    go to x: ((x position) + (pick random (-2) to (2))) y: ((y position) + (pick random (-2) to (2)))\nend\ngo to x: (0) y: (0)\n\nwhen flag clicked\nif <(A) = [1]> then\n    if <(☁ World Best Time:) > (Your Time:)> then\n        set [☁ world best time: v] to (Your Time:)\n    end\n    broadcast (END v) and wait\nend\nif <(A) = [0]> then\n    set [your time: v] to [0]\nend\nset [a v] to [0]\n\nwhen flag clicked\nwait until <(Level) = [20]>\nset [a v] to [1]\n\n\n\nwhen flag clicked\nforever\n    if <(A) = [0]> then\n        set [your time: v] to (timer)\n    end\nend\n\nforever\n\nwhen I receive [flip! v]\npoint in direction ((direction) * (-1))\n\nset [world best time: v] to [It's broken]\n\n@snoislloC oN\n\nwhen flag clicked\nforever\n    switch costume to (Level)\n    go to [back v] layer\n    go to (dnuorg v)\nend\n\n@sdrazaH\n\nwhen flag clicked\nshow\npoint in direction (90)\nset [level v] to [1]\nforever\n    switch costume to (Level)\nend\n\nwhen I receive [flip! v]\npoint in direction ((direction) * (-1))\n\n@latroP\n\nwhen flag clicked\nshow\nwait until <(Level) = [20]>\nhide\n\nwhen flag clicked\nforever\n    if <(Level) < [20]> then\n        show\n    end\nend\n\n@DNE\n\nwhen I receive [end v]\nswitch costume to (costume1 v)\nshow\nif <(☁ World Best Time:) = (Your Time:)> then\n    switch costume to (costume2 v)\nend\n\nwhen flag clicked\ngo to [front v] layer\nhide\n\n@1etirpS\n\nwhen flag clicked\nhide\nshow variable [world best time: v]\nshow variable [your time: v]\n\nset [a v] to [0]\nset [flip v] to [1]\nset [your time: v] to [0]\nhide variable [world best time: v]\nhide variable [your time: v]\ngo to [front v] layer\nshow\n\n@hctiwS pilF\n\ndefine previous costume\nswitch costume to ((costume [number v]) - (1))\n\nwhen this sprite clicked\nif <(costume [number v]) = [1]> then\n    broadcast (FLIP! v)\n    switch costume to (costume1 v)\n    repeat (6)\n        next costume\n    end\nelse\n    broadcast (FLIP! v)\n    switch costume to (costume6 v)\n    repeat (6)\n        previous costume\n    end\nend\n\nwhen flag clicked\nset [flip v] to [1]\n\nwhen I receive [flip! v]\nset [flip v] to ((FLIP) * (-1))\n\nwhen flag clicked\nhide\nwait until <(Level) = [18]>\nshow\n\n