50stage!!超LONG!! PLATFORMER
@Stage\n\n@player\n\ndefine Controls - Left and Right\nset [speed x v] to ((speed x) * (0.7))\nif <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n    change [speed x v] by (-1.5)\nend\nif <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n    change [speed x v] by (1.5)\nend\n\ndefine Walk (direction) (speed) max step (step)\npoint in direction (direction)\nchange x by (speed)\nchange [frame v] by (([abs v] of (speed) ) / (8))\nset [slope v] to [0]\nGet Touching <(in platforrm) = [1]>\nrepeat until <<(slope) = (step)> or <(touch) = [0]>>\n    change y by (1)\n    change [slope v] by (1)\n    Get Touching <(in platforrm) = [1]>\nend\nif <(slope) = (step)> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\n    if <<(touch) = [1]> and <(in platforrm) = [1]>> then\n        set [in platforrm v] to [2]\n        Walk (direction) (speed) max step (step)\n        if <(speed x) = [0]> then\n            set [in platforrm v] to [1]\n        end\n    else\n        if <<<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <([abs v] of (speed) ) > [3.5]>> and <(touch) > [1]>> 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        else\n            set [speed x v] to [0]\n        end\n    end\nend\n\ndefine Controls - Jump, Crouch\nif <<key (w v) pressed?> or <key (up arrow v) pressed?>> 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\nelse\n    set [jump key v] to [0]\nend\nif <key (s v) pressed?> then\n    set [in platforrm v] to [2]\nend\n\ndefine Gravity\nif <<(speed y) < [4]> or <<key (w v) pressed?> or <key (up arrow v) pressed?>>> then\n    if <<key (u v) pressed?> and <(username) = [dn_scrtch]>> then\n        change [speed y v] by (1)\n    else\n        change [speed y v] by (-1)\n    end\nelse\n    change [speed y v] by (-2)\nend\nchange y by (speed y)\nchange [falling? v] by (1)\n\ndefine Get Touching <check platform?>\nif <touching (finish v)?> then\n    if <not <(f) = [1]>> then\n        set [f v] to [1]\n        set [timer v] to (timer)\n        broadcast (hohohohohoho v)\n        stop [other scripts in sprite v]\n        stop [this script v]\n    end\nelse\n    if <touching (trampoline v)?> then\n        set [speed y v] to [30]\n    else\n        if <touching (ground v)?> then\n            set [touch v] to [9]\n        else\n            if <<check platform?> and <touching (platforms v)?>> then\n                set [touch v] to [1]\n            else\n                set [touch v] to [0]\n            end\n        end\n    end\nend\n\ndefine Reset Level\nset size to (25) %\nset rotation style [left-right v]\ngo to x: (0) y: (0)\nreset timer\nshow\nset [scrollx v] to [881]\nset [scrolly v] to [-400]\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling? v] to [10]\nset [in platforrm v] to [1]\nset [frame v] to [0]\nset [wall jump v] to [0]\nset [f v] to [0]\n\ndefine Check Hit Ceiling / Floor <up?>\nGet Touching \nif <(touch) = [0]> then\n    set [in platforrm v] to [1]\nelse\n    if <<up?> and <(touch) = [1]>> then\n        set [in platforrm v] to [2]\n    end\nend\nrepeat until <(touch) < (in platforrm)>\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    Get Touching <not <up?>>\n    set [speed y v] to [0]\nend\n\nwhen flag clicked\nReset Level\nforever\n    switch costume to (hitbox v)\n    if <<touching (spikes v)?> or <touching (saw v)?>> then\n        Reset Level\n    end\n    Controls - Jump, Crouch\n    Gravity\n    Check Hit Ceiling / Floor <(speed y) > [0]>\n    if <(wall jump) > [0]> then\n        change [wall jump v] by (-1)\n    else\n        Controls - Left and Right\n    end\n    if <(speed x) < [-0.5]> then\n        Walk (-90) (speed x) max step (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n    else\n        if <(speed x) > [0.5]> then\n            Walk (90) (speed x) max step (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n        else\n            set [frame v] to [0]\n        end\n    end\n    switch costume to (costume2 v)\n    change [scrollx v] by (() - (round ((x position) / (10))))\n    change x by ((0) - (round ((x position) / (10))))\n    change [scrolly v] by (() - (round ((y position) / (10))))\n    change y by ((0) - (round ((y position) / (10))))\n    broadcast (tick v) and wait\nend\n\ndefine write (val) to encoded\nset [letter# v] to [1]\nrepeat (length of (val))\n    set [encoded v] to (join (encoded) (item # of (letter (letter#) of (val)) in [code v]))\n    change [letter# v] by (1)\nend\nset [encoded v] to (join (encoded) [00])\n\nwhen flag clicked\nset [my player # v] to [0]\nset [max players v] to [5]\nbroadcast (setup - opponents v) and wait\nset [cloud v] to [2]\nbroadcast (join game v) and wait\nif <(MY PLAYER #) > [0]> then\n    set [cloud v] to [4]\nelse\n    set [cloud v] to [3]\nend\nbroadcast (begin v)\n\ndefine set cloud # (player) to (value)\nif <(player) = [1]> then\n    set [☁ p1 v] to (value)\nelse\n    if <(player) = [2]> then\n        set [☁ p2 v] to (value)\n    else\n        if <(player) = [3]> then\n            set [☁ p3 v] to (value)\n        else\n            if <(player) = [4]> then\n                set [☁ p4 v] to (value)\n            else\n                set [☁ p5 v] to (value)\n            end\n        end\n    end\nend\n\ndefine send cloud data\nset [encoded v] to []\nwrite (username) to encoded\nwrite (round ((timer) * (10))) to encoded\nwrite (ScrollX) to encoded\nwrite (ScrollY) to encoded\nset cloud # (MY PLAYER #) to (encoded)\n\nwhen I receive [begin v]\nforever\n    send cloud data\nend\n\n@Ground\n\ndefine Hack Zoom to (percent)\nif <(percent) > [100]> then\n    set [#costume v] to (costume [number v])\n    switch costume to (dot v)\n    set size to (percent) %\n    switch costume to (#costume)\nelse\n    set size to (percent) %\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\ngo [backward v] (100) layers\nHack Zoom to (500)\nset [id_ v] to [1]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [2]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [3]\ncreate clone of (_myself_ v)\n\nshow\n\nwhen I start as a clone\nswitch costume to (costume2 v)\nif <(id_) = [1]> then\n    forever\n        go to x: (ScrollX) y: (ScrollY)\n        if <[-150] > (ScrollY)> then\n            hide\n        else\n            show\n        end\n    end\nelse\n    if <(id_) = [2]> then\n        forever\n            go to x: (ScrollX) y: (ScrollY)\n            if <[192] > (ScrollY)> then\n                show\n            else\n                hide\n            end\n            switch costume to (costume4 v)\n        end\n    else\n        forever\n            go to x: (ScrollX) y: (ScrollY)\n            if <<(ScrollX) > [160]> or <(ScrollY) > [193]>> then\n                hide\n            else\n                show\n            end\n            switch costume to (costume5 v)\n        end\n    end\nend\n\nswitch costume to (costume2 v)\n\nif <(ScrollX) > [160]> then\n    hide\nelse\n    show\nend\n\n\n    show\nelse\n    hide\nend\n\n@water\n\ndefine Hack Zoom to (percent)\nif <(percent) > [100]> then\n    set [#costume v] to (costume [number v])\n    switch costume to (dot v)\n    set size to (percent) %\n    switch costume to (#costume)\nelse\n    set size to (percent) %\nend\n\nwhen flag clicked\nswitch costume to (costume1 v)\nshow\ngo [backward v] (100) layers\nHack Zoom to (500)\ngo to x: (0) y: (0)\nforever\n    go to x: (ScrollX) y: (ScrollY)\n    hide\nend\n\nif <[-95] > (ScrollY)> then\nelse\n    show\nend\n\n@Sprite1\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nset [id v] to [1]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id v] to [2]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id v] to [5]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\n\nwhen I start as a clone\ngo to [back v] layer\nset size to (108) %\nshow\nswitch costume to (costume3 v)\nif <(id) = [1]> then\n    forever\n        set [current_dir v] to (direction)\n        point in direction ((90) + (([speed x v] of [player v]) * ((([speed x v] of [player v]) * (-2)) * ([sin v] of ((timer) * (500)) ))))\n        if <not <([falling? v] of [player v]) = [0]>> then\n            point in direction ((45) - (([speed y v] of [player v]) * (-2)))\n        end\n        go to (player v)\n    end\nend\nif <(id) = [2]> then\n    forever\n        set [current_dir v] to (direction)\n        point in direction ((90) + (([speed x v] of [player v]) * ((([speed x v] of [player v]) * (2)) * ([sin v] of ((timer) * (500)) ))))\n        if <not <([falling? v] of [player v]) = [0]>> then\n            point in direction ((135) - (([speed y v] of [player v]) * (2)))\n        end\n        go to (player v)\n    end\nend\nif <(id) = [3]> then\n    forever\n        set [current_dir v] to (direction)\n        go to (player v)\n        change y by (25)\n        if <<<(m) = [jump]> or <(m) = [fall]>> or <(m) = [walljump]>> then\n            point in direction ((45) + ((vy) * (2)))\n            go to (player v)\n            change y by (25)\n        end\n        if <(m) = [stand]> then\n            point in direction ((65) + ((5) * ([sin v] of ((timer) * (100)) )))\n            go to (player v)\n            change y by (25)\n        end\n        if <<(m) = [run]> or <(m) = [slide]>> then\n            point in direction ((90) + ((vx) * (((vx) * (-2)) * ([sin v] of ((timer) * (500)) ))))\n            go to (player v)\n            change y by (25)\n        end\n    end\nend\nif <(id) = [4]> then\n    forever\n        set [current_dir v] to (direction)\n        go to (player v)\n        change y by (25)\n        if <<<(m) = [jump]> or <(m) = [fall]>> or <(m) = [walljump]>> then\n            point in direction ((135) - ((vy) * (2)))\n            go to (player v)\n            change y by (25)\n        end\n        if <(m) = [stand]> then\n            point in direction ((115) + ((-5) * ([sin v] of ((timer) * (100)) )))\n            go to (player v)\n            change y by (25)\n        end\n        if <<(m) = [run]> or <(m) = [slide]>> then\n            point in direction ((90) + ((vx) * (((vx) * (2)) * ([sin v] of ((timer) * (500)) ))))\n            go to (player v)\n            change y by (25)\n        end\n    end\nend\nif <(id) = [5]> then\n    set size to (108) %\n    switch costume to (costume2 v)\n    go to [front v] layer\n    forever\n        go to x: ((([x position v] of [player v]) + ()) + (([speed x v] of [player v]) * (0.7))) y: ((([y position v] of [player v]) + (1)) + (([speed y v] of [player v]) * (0.5)))\n    end\nend\n\n@sign\n\ndefine Hack Zoom to (percent)\nif <(percent) > [100]> then\n    set [#costume v] to (costume [number v])\n    switch costume to (dot v)\n    set size to (percent) %\n    switch costume to (#costume)\nelse\n    set size to (percent) %\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\ngo [backward v] (10000) layers\nHack Zoom to (500)\nset [id_ v] to [1]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [2]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [3]\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nshow\nswitch costume to (costume2 v)\nif <(id_) = [1]> then\n    forever\n        go to [back v] layer\n        go to x: (ScrollX) y: (ScrollY)\n    end\nelse\n    if <(id_) = [2]> then\n        forever\n            go to [back v] layer\n            go to x: (ScrollX) y: (ScrollY)\n            switch costume to (costume4 v)\n        end\n    else\n        forever\n            go to [back v] layer\n            go to x: (ScrollX) y: (ScrollY)\n            switch costume to (costume5 v)\n        end\n    end\nend\n\nif <touching (_edge_ v)?> then\n    hide\nelse\n    show\nend\nif <touching (_edge_ v)?> then\n    hide\nelse\n    show\nend\nif <touching (_edge_ v)?> then\n    hide\nelse\n    show\nend\n\n@spikes\n\ndefine Hack Zoom to (percent)\nif <(percent) > [100]> then\n    set [#costume v] to (costume [number v])\n    switch costume to (dot v)\n    set size to (percent) %\n    switch costume to (#costume)\nelse\n    set size to (percent) %\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\ngo [backward v] (100) layers\nHack Zoom to (500)\nset [id_ v] to [1]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [2]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [3]\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nswitch costume to (costume2 v)\nif <(id_) = [1]> then\n    forever\n        go to x: (ScrollX) y: (ScrollY)\n        if <[-150] > (ScrollY)> then\n            hide\n        else\n            show\n        end\n    end\nelse\n    if <(id_) = [2]> then\n        forever\n            go to x: (ScrollX) y: (ScrollY)\n            if <[192] > (ScrollY)> then\n                show\n            else\n                hide\n            end\n            switch costume to (costume4 v)\n        end\n    else\n        forever\n            go to x: (ScrollX) y: (ScrollY)\n            if <<(ScrollX) > [160]> or <(ScrollY) > [193]>> then\n                hide\n            else\n                show\n            end\n            switch costume to (costume5 v)\n        end\n    end\nend\n\n@Sprite2\n\nwhen flag clicked\ngo to [front v] layer\n\n@trampoline\n\ndefine Hack Zoom to (percent)\nif <(percent) > [100]> then\n    set [#costume v] to (costume [number v])\n    switch costume to (dot v)\n    set size to (percent) %\n    switch costume to (#costume)\nelse\n    set size to (percent) %\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\ngo [backward v] (100) layers\nHack Zoom to (500)\nset [id_ v] to [1]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [2]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [3]\ncreate clone of (_myself_ v)\n\nshow\n\nwhen I start as a clone\nswitch costume to (costume2 v)\nif <(id_) = [1]> then\n    forever\n        go to x: (ScrollX) y: (ScrollY)\n        if <[-150] > (ScrollY)> then\n            hide\n        else\n            show\n        end\n    end\nelse\n    if <(id_) = [2]> then\n        forever\n            go to x: (ScrollX) y: (ScrollY)\n            if <[192] > (ScrollY)> then\n                show\n            else\n                hide\n            end\n            switch costume to (costume4 v)\n        end\n    else\n        forever\n            go to x: (ScrollX) y: (ScrollY)\n            if <<(ScrollX) > [160]> or <(ScrollY) > [193]>> then\n                hide\n            else\n                show\n            end\n            switch costume to (costume5 v)\n        end\n    end\nend\n\nswitch costume to (costume2 v)\n\nif <(ScrollX) > [160]> then\n    hide\nelse\n    show\nend\n\n\n    show\nelse\n    hide\nend\n\n@finish\n\ndefine Hack Zoom to (percent)\nif <(percent) > [100]> then\n    set [#costume v] to (costume [number v])\n    switch costume to (dot v)\n    set size to (percent) %\n    switch costume to (#costume)\nelse\n    set size to (percent) %\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\ngo [backward v] (100) layers\nHack Zoom to (500)\nset [id_ v] to [1]\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nshow\nswitch costume to (costume4 v)\nforever\n    go to x: (ScrollX) y: (ScrollY)\n    next costume\n    if <(costume [number v]) > [17]> then\n        switch costume to (costume4 v)\n    end\nend\n\nswitch costume to (costume2 v)\n\nif <(ScrollX) > [160]> then\n    hide\nelse\n    show\nend\n\n\n    show\nelse\n    hide\nend\n\n@endscreen\n\nwhen flag clicked\nhide variable [timer v]\nhide variable [☁ highscore v]\nhide\n\nwhen I receive [hohohohohoho v]\nshow variable [timer v]\nshow variable [☁ highscore v]\nif <(timer) < (☁ highscore)> then\n    set [☁ highscore v] to (timer)\nend\nshow\nset size to (0) %\nset [ghost v] effect to (100)\nset [dd v] to [1]\nrepeat (10)\n    change size by (dd)\n    change [ghost v] effect by ((dd) * (-1))\n    change [dd v] by ((dd) / (2.1))\nend\nforever\n    go to [front v] layer\nend\n\n@saw\n\ndefine Hack Zoom to (percent)\nif <(percent) > [100]> then\n    set [#costume v] to (costume [number v])\n    switch costume to (dot v)\n    set size to (percent) %\n    switch costume to (#costume)\nelse\n    set size to (percent) %\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\ngo [backward v] (100) layers\nHack Zoom to (500)\nset [id_ v] to [1]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\n\nwhen I start as a clone\nshow\nswitch costume to (costume2 v)\nif <(id_) = [1]> then\n    forever\n        go to x: (ScrollX) y: (ScrollY)\n        next costume\n        if <(costume [number v]) > [4]> then\n            switch costume to (costume2 v)\n        end\n    end\nend\n\nswitch costume to (costume2 v)\n\nif <(ScrollX) > [160]> then\n    hide\nelse\n    show\nend\n\n\n    show\nelse\n    hide\nend\n\n@Sprite3\n\ndefine setup players\nhide\nset [offline v] to [100]\nset [player # v] to [1]\nrepeat ((MAX PLAYERS) - (1))\n    create clone of (_myself_ v)\n    change [player # v] by (1)\nend\n\nwhen I receive [setup - opponents v]\nsetup players\n\nwhen I receive [begin v]\nforever\n    if <(MY PLAYER #) = (player #)> then\n        set [offline v] to [100]\n        hide\n    else\n        tick\n    end\nend\n\ndefine value = cloud # (player)\nif <(player) = [1]> then\n    set [value v] to (☁ P1)\nelse\n    if <(player) = [2]> then\n        set [value v] to (☁ P2)\n    else\n        if <(player) = [3]> then\n            set [value v] to (☁ P3)\n        else\n            if <(player) = [4]> then\n                set [value v] to (☁ P4)\n            else\n                set [value v] to (☁ P5)\n            end\n        end\n    end\nend\n\ndefine tick\nvalue = cloud # (player #)\nif <(join [A] (value)) = (last value)> then\n    change [offline v] by (1)\n    if <(offline) = [100]> then\n        hide\n    end\nelse\n    set [last value v] to (join [A] (value))\n    if <(offline) > [99]> then\n        show\n    end\n    set [offline v] to [0]\nend\nbegin decode of (value)\nvalue = read from encoded\nsay (join (player #) (join [: ] (value)))\nvalue = read from encoded\nvalue = read from encoded\nset x to ((ScrollX) - (value))\nvalue = read from encoded\nset y to ((ScrollY) - (value))\n\ndefine begin decode of (encoded)\nset [encoded v] to (encoded)\nset [letter # v] to [1]\n\ndefine value = read from encoded\nset [value v] to []\nforever\n    set [idx v] to (join (letter (letter #) of (encoded)) (letter ((letter #) + (1)) of (encoded)))\n    change [letter # v] by (2)\n    if <(idx) < [1]> then\n        stop [this script v]\n    end\n    set [value v] to (join (value) (item (idx) of [code v]))\nend\n\nwhen I receive [join game v]\nvalue = cloud # (player #)\nset [last value v] to (join [A] (value))\nwait (3) seconds\nvalue = cloud # (player #)\nif <(join [A] (value)) = (last value)> then\n    set [my player # v] to (player #)\nend\n\n@Sprite4\n\nwhen flag clicked\nset [cloud v] to [2]\nset [ghost v] effect to (0)\nshow\ngo to [front v] layer\nrepeat until <(cloud) = [4]>\n    switch costume to (cloud)\n    go to [front v] layer\n    if <(cloud) = [3]> then\n        switch costume to (full v)\n        stop [all v]\n    end\nend\nswitch costume to (joined v)\nwait (0.5) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nhide\n\nforever\nend\n\n@Sprite5\n\nwhen flag clicked\nhide\nforever\n    wait (pick random (10) to (35)) seconds\n    show\n    go to x: (0) y: (0)\n    go to [front v] layer\n    wait (5) seconds\n    hide\nend\n\n@Sprite6\n\nwhen flag clicked\nhide\n\nshow\ngo to [front v] layer\n\n@Ground2\n\ndefine Hack Zoom to (percent)\nif <(percent) > [100]> then\n    set [#costume v] to (costume [number v])\n    switch costume to (dot v)\n    set size to (percent) %\n    switch costume to (#costume)\nelse\n    set size to (percent) %\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\ngo [backward v] (100) layers\nHack Zoom to (500)\nset [id_ v] to [1]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [2]\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nset [id_ v] to [3]\ncreate clone of (_myself_ v)\n\nshow\n\nwhen I start as a clone\nswitch costume to (costume2 v)\nif <(id_) = [1]> then\n    forever\n        go to [back v] layer\n        go [backward v] (100) layers\n        go to x: (ScrollX) y: (ScrollY)\n        if <[-150] > (ScrollY)> then\n            hide\n        else\n            show\n        end\n    end\nelse\n    if <(id_) = [2]> then\n        forever\n            go to [back v] layer\n            go [backward v] (100) layers\n            go to x: (ScrollX) y: (ScrollY)\n            if <[192] > (ScrollY)> then\n                show\n            else\n                hide\n            end\n            switch costume to (costume4 v)\n        end\n    else\n        forever\n            go to [back v] layer\n            go [backward v] (100) layers\n            go to x: (ScrollX) y: (ScrollY)\n            if <<(ScrollX) > [160]> or <(ScrollY) > [193]>> then\n                hide\n            else\n                show\n            end\n            switch costume to (costume5 v)\n        end\n    end\nend\n\nswitch costume to (costume2 v)\n\nif <(ScrollX) > [160]> then\n    hide\nelse\n    show\nend\n\n\n    show\nelse\n    hide\nend\n\n