Online Platformer

Instructions: ---------------- Open World Online Platformer ------------\nWASD or arrow keys to control. press up while on a wall to perform a wall jump. 35 different scenes to play in. Feel free to say what features you want to be added! Press C to open safe chat. 

@Stage\n\nwhen flag clicked\nforever\n    wait (1) seconds\n    Calculate Players Online\nend\n\ndefine Calculate Players Online\nset [players online: v] to [1]\nset [countscene v] to [1]\nrepeat (length of [player uids v])\n    if <not <(item (countscene) of [player uids v]) = []>> then\n        change [players online: v] by (1)\n    end\n    change [countscene v] by (1)\nend\n\n@Player\n\nwhen flag clicked\nbroadcast (Cloud - Setup  v)\nhide variable [scene# v]\nshow list [player pos v]\nset [color v] effect to (50)\nset [brightness v] effect to (-8)\nset [visible v] to [0]\nshow list [safe chat v]\nset [gravity v] to [-1.5]\n\n    set [gravity v] to [0]\nend\nset [jump force v] to [12]\nset [acceleration v] to [1.5]\nset [jump duration v] to [6]\nset [resistance v] to [0.8]\nReset and Begin Level\n\ndefine Move - in steps (steps)\nchange [falling v] by (1)\nrepeat (steps)\n    set [last value v] to (x position)\n    change x by ((speed x) / (steps))\n    Check Touching Solid\n    if <(touching) > [0]> then\n        Collide X - Slope or Wall\n    end\n    set [last value v] to (y position)\n    change y by ((speed y) / (steps))\n    Check Touching Solid\n    if <(touching) > [0]> then\n        Collide Y - Ceilling or Floor\n    end\nend\n\ndefine Check Touching Solid\nif <touching (level v)?> then\n    set [touching v] to [1]\nelse\n    set [touching v] to [0]\nend\n\nwhen I receive [tick - player v]\nswitch backdrop to <touching (level v)?>\nControl - Up and Down\nControls - Left and Right\nMove - in steps (([abs v] of (speed y) ) + ([abs v] of (speed x) ))\nSet Costume\n\ndefine Control - Up and Down\nif <<[0] < (STICK BUTTON)> or <<key (w v) pressed?> or <key (up arrow v) pressed?>>> then\n    if <<(wall slide) > [0]> and <(jumping) = [0]>> then\n        start sound [6 v]\n        set [jumping v] to [1]\n        set [falling v] to [3]\n        set [wall slide v] to [0]\n        turn right (180) degrees\n        set [speed x v] to (((direction) / (90)) * (7))\n        set [long jump v] to [12]\n    end\n    if <<[3] > (falling)> and <(jumping) = [0]>> then\n        start sound [6 v]\n        set [jumping v] to [1]\n        set [falling v] to [3]\n    end\n    if <<(jumping) > [0]> and <(jumping) < (JUMP DURATION)>> then\n        change [jumping v] by (1)\n        set [speed y v] to (JUMP FORCE)\n    end\nelse\n    set [jumping v] to [0]\nend\nchange [speed y v] by (GRAVITY)\nif <(wall slide) > [0]> then\n    Check Can Wall Slide\n    if <(speed y) < [0]> then\n        set [speed y v] to ((speed y) * (0.6))\n    end\nend\n\ndefine Controls - Left and Right\nif <(long jump) > [0]> then\n    change [long jump v] by (-1)\n    stop [this script v]\nend\nset [key x v] to (STICK X)\nif <(KEY X) = [0]> then\n    if <<(falling) > [2]> and <(wall slide) < [1]>> then\n        set [speed x v] to ((speed x) * (0.98))\n        stop [this script v]\n    end\n    if <([abs v] of (speed x) ) < [1]> then\n        set [frame v] to [0]\n        set [speed x v] to [0]\n    else\n        change [frame v] by (0.5)\n    end\nelse\n    change [speed x v] by ((KEY X) * (ACCELERATION))\n    point in direction ((KEY X) * (90))\n    change [frame v] by (1)\nend\nset [speed x v] to ((speed x) * (RESISTANCE))\n\ndefine Reset and Begin Level\nset [scene# v] to [1]\nset [speed y v] to [0]\nset [speed x v] to [0]\nset [falling v] to [99]\nset [wall slide v] to [0]\nset [long jump v] to [0]\nset [touching v] to [0]\ngo to x: (-150) y: (50)\nbroadcast (Change Scene v)\nbroadcast (Game Loop v)\n\nwhen I receive [game loop v]\nforever\n    broadcast (Tick - First v)\n    broadcast (Tick - Player v)\n    broadcast (Tick - Last v)\n    say (item (chat) of [safe chat v])\nend\n\nwhen I receive [tick - last v]\nif <(x position) > [235]> then\n    start sound (pick random (1) to (5))\n    Begin Scene # ((SCENE#) + (1)) Go to x: [-235] Go to y: []\nend\nif <(x position) < [-235]> then\n    start sound (pick random (1) to (5))\n    Begin Scene # ((SCENE#) - (1)) Go to x: [235] Go to y: []\nend\nif <(y position) > [180]> then\n    start sound (pick random (1) to (5))\n    Begin Scene # ((SCENE#) + (100)) Go to x: [] Go to y: [-160]\nend\nif <(y position) < [-180]> then\n    start sound (pick random (1) to (5))\n    Begin Scene # ((SCENE#) - (100)) Go to x: [] Go to y: [160]\nend\nadd (x position) to [my values to send v]\nadd (y position) to [my values to send v]\nadd (costume [number v]) to [my values to send v]\nif <(direction) > [0]> then\n    add [1] to [my values to send v]\nelse\n    add [-1] to [my values to send v]\nend\nadd (SCENE#) to [my values to send v]\nadd (chat) to [my values to send v]\nbroadcast (Cloud - Tick v)\n\ndefine Begin Scene # (scene #) Go to x: (x) Go to y: (y)\nset [scene# v] to (scene #)\nif <(x) > []> then\n    set x to (x)\nend\nif <(y) > []> then\n    set y to (y)\nend\nbroadcast (Change Scene v)\nstop [other scripts in sprite v]\nwait (0) seconds\nswitch costume to (hitbox v2 v)\nset rotation style [don't rotate v]\nif <(x) > []> then\n    Fix Collision in Direction [0]\nelse\n    Fix Collision in Direction [90]\nend\nSet Costume\nbroadcast (Game Loop v)\n\ndefine Fix Collision in Direction (dir)\nset [temp v] to (direction)\nset [distance v] to [1]\npoint in direction (dir)\nrepeat (128)\n    Check Touching Solid\n    if <(touching) < [1]> then\n        point in direction (temp)\n        stop [this script v]\n    end\n    move (distance) steps\n    turn right (180) degrees\n    change [distance v] by (1)\nend\n\nwhen I receive [tick - first v]\nswitch costume to (hitbox v2 v)\nset rotation style [don't rotate v]\n\ndefine Set Costume\nset rotation style [left-right v]\nif <(wall slide) > [0]> then\n    switch costume to (hangon01 v)\n    stop [this script v]\nend\nif <(falling) > [1]> then\n    if <(speed y) > [0]> then\n        switch costume to (jump01 v)\n    else\n        switch costume to (run_j2 v)\n    end\n    stop [this script v]\nend\nif <(frame) > [0]> then\n    switch costume to ([floor v] of ((1) + ((frame) mod (16))) )\nelse\n    switch costume to (hit angle 0 v)\n    repeat (5)\n        Check Touching Solid\n        if <(touching) < [1]> then\n            switch costume to ((costume [number v]) + (5))\n            stop [this script v]\n        end\n        next costume\n    end\n    switch costume to (stand v)\nend\n\ndefine Collide X - Slope or Wall\nCheck Can Wall Slide\nchange y by (1)\nCheck Touching Solid\nif <(touching) > [0]> then\n    change y by (1)\n    Check Touching Solid\n    if <(touching) > [0]> then\n        change y by (-2)\n        set x to (last value)\n        set [speed x v] to [0]\n        stop [this script v]\n    end\n    set [speed x v] to ((speed x) * (8))\nend\nset [speed x v] to ((speed x) * (0.95))\nSlip\n\ndefine Slip\nchange y by (-2)\nchange x by (1)\nCheck Touching Solid\nif <(touching) < [1]> then\n    set [falling v] to [9]\n    change [speed x v] by (1)\n    stop [this script v]\nend\nchange x by (-2)\nCheck Touching Solid\nif <(touching) < [1]> then\n    set [falling v] to [9]\n    change [speed x v] by (-1)\n    stop [this script v]\nend\nchange y by (2)\nchange x by (1)\n\ndefine Check Can Wall Slide\nif <(falling) < [2]> then\n    set [wall slide v] to [0]\n    stop [this script v]\nend\nswitch costume to (hitbox wallslide v)\nset rotation style [left-right v]\nCheck Touching Solid\nset [wall slide v] to (touching)\nswitch costume to (hitbox v2 v)\nset rotation style [don't rotate v]\n\nwhen [c v] key pressed\nset [visible v] to ((1) - (visible))\nif <(visible) = [1]> then\n    hide list [safe chat v]\n    if <(username) = [kycklingkycklingj]> then\n        hide list [player pos v]\n        show variable [scene# v]\n    end\nelse\n    show list [safe chat v]\n    show list [player pos v]\n    hide variable [scene# v]\nend\n\nwhen [1 v] key pressed\nset [chat v] to [1]\nwait (3) seconds\nset [chat v] to [0]\n\nwhen [2 v] key pressed\nset [chat v] to [2]\nwait (3) seconds\nset [chat v] to [0]\n\nwhen [3 v] key pressed\nset [chat v] to [3]\nwait (3) seconds\nset [chat v] to [0]\n\nwhen [4 v] key pressed\nset [chat v] to [4]\nwait (3) seconds\nset [chat v] to [0]\n\ndefine Collide Y - Ceilling or Floor\nset y to (last value)\nif <(speed y) > [0]> then\n    set [speed y v] to [0]\n    stop [this script v]\nend\nif <(falling) > [0]> then\n    set [falling v] to [0]\n    Slip\nend\nset [speed y v] to ((speed y) * (0.8))\n\nwhen [5 v] key pressed\nset [chat v] to [5]\nwait (3) seconds\nset [chat v] to [0]\n\nwhen [6 v] key pressed\nset [chat v] to [6]\n\n\n\ndefine Encode String: (str)\nset [output v] to []\nset [i v] to [1]\nrepeat (length of (str))\n    set [output v] to (join (output) (item # of (letter (i) of (str)) in [encoding table v]))\n    change [i v] by (1)\nend\n\nEncode String: (username)\nadd (output) to [my values to send v]\n\ndefine Decode String: (str)\nset [output v] to []\nset [i v] to [1]\nrepeat (length of (str))\n    set [output v] to (join (output) (item (join (letter (i) of (str)) (letter ((i) + (1)) of (str))) of [encoding table v]))\n    change [i v] by (2)\nend\n\nDecode String: [10222010]\n\n@Cloud Player\n\ndefine Write Number (val ) to encoded string\nset [val v] to (round (val ))\nif <(val) < [0]> then\n    set [val v] to (join [0] ([abs v] of (val) ))\nend\nset [encoded string v] to (join (encoded string) (join (length of (val)) (val)))\n\ndefine val = READ NUMBER from "encoded string"\nset [val v] to []\nrepeat (letter (encoded idx) of (encoded string))\n    change [encoded idx v] by (1)\n    set [val v] to (join (val) (letter (encoded idx) of (encoded string)))\nend\nchange [encoded idx v] by (1)\nif <(letter (1) of (val)) = [0]> then\n    set [val v] to ((0) - (val))\nend\n\nwhen I receive [cloud - setup  v]\nset [cloud tick v] to [0]\nhide\ndelete all of [my values to send v]\ndelete all of [cloud values v]\ndelete all of [player uids v]\ndelete all of [player data v]\nadd (join [c] (☁ CLOUD 1)) to [cloud values v]\nadd (join [c] (☁ CLOUD 2)) to [cloud values v]\nadd (join [c] (☁ CLOUD 3)) to [cloud values v]\nadd (join [c] (☁ CLOUD 4)) to [cloud values v]\nadd (join [c] (☁ CLOUD 5)) to [cloud values v]\nadd (join [c] (☁ CLOUD 6)) to [cloud values v]\nadd (join [c] (☁ CLOUD 7)) to [cloud values v]\nadd (join [c] (☁ CLOUD 8)) to [cloud values v]\nset [my player uid v] to (pick random (1) to (99999999))\nset [player # v] to []\n\nwhen I receive [cloud - tick v]\nif <(player #) > []> then\n    Player Clone Tick\n    if <(SCENE#) = (scene)> then\n        if <(inactive) < [201]> then\n            show\n        else\n            hide\n        end\n    else\n        hide\n    end\n    stop [this script v]\nend\nchange [cloud tick v] by (1)\nProcess Cloud Item [1] value (join [c] (☁ CLOUD 1))\nProcess Cloud Item [2] value (join [c] (☁ CLOUD 2))\nProcess Cloud Item [3] value (join [c] (☁ CLOUD 3))\nProcess Cloud Item [4] value (join [c] (☁ CLOUD 4))\nProcess Cloud Item [5] value (join [c] (☁ CLOUD 5))\nProcess Cloud Item [6] value (join [c] (☁ CLOUD 6))\nProcess Cloud Item [7] value (join [c] (☁ CLOUD 7))\nProcess Cloud Item [8] value (join [c] (☁ CLOUD 8))\nSend my Cloud Data after [12] ticks\n\ndefine Send my Cloud Data after (count) ticks\nif <((CLOUD TICK) mod (count)) > [0]> then\n    stop [this script v]\nend\nset [encoded string v] to []\nWrite Number (MY PLAYER UID) to encoded string\nrepeat (length of [my values to send v])\n    Write Number (item (1) of [my values to send v]) to encoded string\n    delete (1) of [my values to send v]\nend\nset [my channel v] to (pick random (1) to (length of [cloud values v]))\nif <(MY CHANNEL) < [5]> then\n    if <(MY CHANNEL) < [3]> then\n        if <(MY CHANNEL) < [2]> then\n            set [☁ cloud 1 v] to (encoded string)\n        else\n            set [☁ cloud 2 v] to (encoded string)\n        end\n    else\n        if <(MY CHANNEL) < [4]> then\n            set [☁ cloud 3 v] to (encoded string)\n        else\n            set [☁ cloud 4 v] to (encoded string)\n        end\n    end\nelse\n    if <(MY CHANNEL) < [7]> then\n        if <(MY CHANNEL) < [6]> then\n            set [☁ cloud 5 v] to (encoded string)\n        else\n            set [☁ cloud 6 v] to (encoded string)\n        end\n    else\n        if <(MY CHANNEL) < [8]> then\n            set [☁ cloud 7 v] to (encoded string)\n        else\n            set [☁ cloud 8 v] to (encoded string)\n        end\n    end\nend\n\ndefine Process Cloud Item (which?) value (new value)\nif <(new value) = (item (which?) of [cloud values v])> then\n    stop [this script v]\nend\nreplace item (which?) of [cloud values v] with (new value)\nset [encoded string v] to (new value)\nset [encoded idx v] to [2]\nval = READ NUMBER from "encoded string"\nif <<(val) < [1]> or <(val) = (MY PLAYER UID)>> then\n    stop [this script v]\nend\nset [player # v] to (item # of (val) in [player uids v])\nif <(player #) = [0]> then\n    if <(username) = [kycklingkycklingj]> then\n        add [] to [player pos v]\n    end\n    set [player # v] to (item # of [] in [player uids v])\n    if <(player #) = [0]> then\n        add (val) to [player uids v]\n        add [] to [player data v]\n        set [player # v] to (length of [player data v])\n        create clone of (_myself_ v)\n    else\n        replace item (player #) of [player uids v] with (val)\n    end\nend\nreplace item (player #) of [player data v] with (new value)\nset [player # v] to []\n\nbroadcast (Player Joined v)\n\ndefine Player Clone Tick\nif <(encoded idx) > (length of (encoded string))> then\n    Get Next Data Packet\n    if <(encoded string) = []> then\n        change [inactive v] by (1)\n        if <(inactive) > [200]> then\n            replace item (player #) of [player uids v] with []\n            hide\n        end\n        stop [this script v]\n    end\n    show\n    if <touching (mouse-pointer v)?> then\n        say (username) for (1) seconds\n    end\nend\nset [inactive v] to [0]\nval = READ NUMBER from "encoded string"\nset x to (val)\nval = READ NUMBER from "encoded string"\nset y to (val)\nval = READ NUMBER from "encoded string"\nswitch costume to (val)\nval = READ NUMBER from "encoded string"\nset rotation style [left-right v]\npoint in direction ((val) * (90))\nval = READ NUMBER from "encoded string"\nset [scene v] to (val)\nreplace item (player #) of [player pos v] with (val)\nval = READ NUMBER from "encoded string"\nsay (item (val) of [safe chat v])\n\ndefine Get Next Data Packet\nset [encoded string v] to (item (player #) of [player data v])\nreplace item (player #) of [player data v] with []\nset [encoded idx v] to [2]\nval = READ NUMBER from "encoded string"\n\nwhen flag clicked\ndelete all of [player pos v]\n\ndefine Decode String: (str)\nset [output v] to []\nset [i v] to [1]\nrepeat (length of (str))\n    set [output v] to (join (output) (item (join (letter (i) of (str)) (letter ((i) + (1)) of (str))) of [encoding table v]))\n    change [i v] by (2)\nend\n\nval = READ NUMBER from "encoded string"\nDecode String: (val)\nset [username v] to (output)\n\n@Level\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [back v] layer\n\ndefine outline\nif <[Disabled] = []> then\n    set [brightness v] effect to (-100)\n    set rotation style [don't rotate v]\n    go to x: (0) y: (0)\n    point in direction (90)\n    repeat (20)\n        move (2.5) steps\n        stamp\n        move (-2.5) steps\n        turn right (18) degrees\n    end\n    clear graphic effects\nend\n\nwhen I receive [change scene v]\nerase all\nswitch costume to (join [Scene] (SCENE#))\noutline\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\n@Stick\n\nwhen flag clicked\ngo to [front v] layer\nset size to (80) %\nset [ghost v] effect to (80)\nshow\nset [range v] to ((size) / (2.5))\nbroadcast (restart v)\n\ndefine Keyboard Controls\nset [stick x v] to <<key (right arrow v) pressed?> or <key (d v) pressed?>>\nchange [stick x v] by ((0) - <<key (left arrow v) pressed?> or <key (a v) pressed?>>)\nset [stick y v] to <<key (up arrow v) pressed?> or <key (w v) pressed?>>\nchange [stick y v] by ((0) - <<key (down arrow v) pressed?> or <key (s v) pressed?>>)\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    hide\n    change [stick button v] by (1)\nelse\n    set [stick button v] to [0]\nend\n\ndefine Stick Activated\ngo to (mouse-pointer v)\nswitch costume to (ready v)\ncreate clone of (_myself_ v)\nswitch costume to (stick v)\ncreate clone of (_myself_ v)\nswitch costume to (base active v)\nset [stick button v] to []\nrepeat until <(distance to [mouse-pointer v]) > ((size) * (1.5))>\n    Detect Stick Movement\n    Detect Stick Button\nend\nbroadcast (Deactivate Stick v)\n\ndefine Detect Stick Movement\nset [stick x v] to (((mouse x) - (x position)) / (range))\nset [stick y v] to (((mouse y) - (y position)) / (range))\nif <([abs v] of (STICK X) ) > [1]> then\n    set [stick x v] to ((STICK X) / ([abs v] of (STICK X) ))\nend\nif <([abs v] of (STICK Y) ) > [1]> then\n    set [stick y v] to ((STICK Y) / ([abs v] of (STICK Y) ))\nend\nif <not <([abs v] of (STICK X) ) > [0.3]>> then\n    set [stick x v] to [0]\nend\nif <not <([abs v] of (STICK Y) ) > [0.3]>> then\n    set [stick y v] to [0]\nend\n\ndefine Detect Stick Button\nif <mouse down?> then\n    if <(STICK BUTTON) > []> then\n        change [stick button v] by (1)\n    end\nelse\n    set [stick button v] to [0]\nend\n\nwhen I receive [deactivate stick v]\ndelete this clone\n\nwhen I start as a clone\nif <(costume [name v]) = [Stick]> then\n    go [forward v] (1) layers\n    set [ghost v] effect to (0)\n    forever\n        go to (stick v)\n        change x by ((STICK X) * (range))\n        change y by ((STICK Y) * (range))\n    end\nend\ngo to x: (155) y: (-106)\nwait until <not <mouse down?>>\nswitch costume to (base active v)\nforever\n    if <mouse down?> then\n        set [ghost v] effect to (25)\n    else\n        set [ghost v] effect to (75)\n    end\nend\n\nwhen flag clicked\nforever\n    if <mouse down?> then\n        reset timer\n    end\n    if <<not <(lx) = (mouse x)>> or <not <(ly) = (mouse y)>>> then\n        reset timer\n    end\n    set [lx v] to (mouse x)\n    set [ly v] to (mouse y)\n    if <(timer) > [0.5]> then\n        stop [other scripts in sprite v]\n        broadcast (restart v)\n    end\nend\n\nwhen I receive [restart v]\nreset timer\nforever\n    switch costume to (base v)\n    go to x: (-155) y: (-106)\n    repeat until <not <mouse down?>>\n        Keyboard Controls\n    end\n    repeat until <mouse down?>\n        Keyboard Controls\n    end\n    if <(distance to [mouse-pointer v]) < (size)> then\n        Stick Activated\n    end\n    if <mouse down?> then\n        show\n    end\nend\n\nwhen I receive [restart v]\ndelete this clone\n\n