Multiplayer Scrolling Platformer Engine                       #games

Instructions: ❅ Multiplayer Scrolling Platformer Engine ❅\n\nMerry Christmas everyone! To celebrate, I decided to make a Multiplayer Scrolling Platformer Engine. But that's not all, it's 100% made by me.\n\nNOTE: THIS IS AN ENGINE, NOT A FULL GAME!\n\nFeel free to use with credit!\n\nHow to use:\nDon't put it in your backpack, that doesn't work. Instead click on file and choose save to computer. Then upload it in a new project that you have created. You can also do the easy way and just remix.\n\nNews:\n30/12/20: Added slope detection and die from falling.\n\n\n\n100% code and art by me. Both Scrolling and Multiplayer engine.\nSome inspiration from @griffpatch\n\n\n\n\n\n\n\n\nplease love and fave if you enjoy\n\n\n\n\n\n\n\n\n\n\n\n\nI know it's short

@Stage\n\n@Player\n\nwhen flag clicked\nbroadcast (Reset v)\nbroadcast (Start v)\n\ndefine tick\nshow\ngo to x: (0) y: (0)\nswitch costume to (3 v)\nset size to (100) %\nset [y v] to (round (y))\ninsert (x position) at (1) of [wall v] \ndelete (5) of [wall v]\nchange [y v] by (-5)\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    change [y v] by (-5)\n    Position\n    if <<touching (ground v)?> or <touching (water v)?>> then\n        if <(jump) < [6]> then\n            change [jump v] by (5)\n            set [yv v] to [25]\n        end\n    end\n    change [y v] by (5)\nend\nif <(xv) < [10]> then\n    if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n        set [cos v] to [1]\n        change [xv v] by (1.8)\n    else\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            set [cos v] to [2]\n            change [xv v] by (-1.8)\n        else\n            set [cos v] to [3]\n        end\n    end\nend\nif <(yv) < [-10]> then\n    set [yv v] to [-10]\nend\nchange [yv v] by (-1.5)\nset [xv v] to ((xv) * (0.9))\nset [yv v] to ((yv) * (0.99))\nyv (yv)\nxv (xv)\nif <touching (bounce pad v)?> then\n    set [yv v] to [40]\nend\nif <<<(y) < [-500]> or <touching (spikes v)?>> or <key (r v) pressed?>> then\n    set [die v] to [Die]\nend\nswitch costume to (Cos)\nif <<(x) > [-490]> and <(x) < [1060]>> then\n    change [scrollx v] by (round (((x) - (ScrollX)) / (10)))\nend\nchange [scrolly v] by (round (((y) - (ScrollY)) / (10)))\nPosition\nif <touching (win v)?> then\n    set [win v] to [win]\n    stop [all v]\nend\n\ndefine yv (yv)\nif <not <touching (water v)?>> then\n    change [y v] by (yv)\nelse\n    if <not <key (up arrow v) pressed?>> then\n        change [y v] by ((yv) / (6))\n    else\n        change [y v] by (10)\n    end\n    set [jump v] to [0]\nend\nPosition\nrepeat until <not <touching (ground v)?>>\n    if <(yv) > [0]> then\n        set [yv v] to [5]\n        change [y v] by (-1)\n    else\n        set [jump v] to [0]\n        change [y v] by (1)\n    end\n    Position\nend\n\ndefine xv (xv)\nchange [x v] by (xv)\nPosition\nif <touching (ground v)?> then\n    repeat (10)\n        change [y v] by (1)\n        Position\n        if <not <touching (ground v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-10)\nend\nrepeat until <not <touching (ground v)?>>\n    change [x v] by ((([abs v] of (xv) ) / (xv)) * (-1))\n    if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <<not <(xv) = [0]>> and <(item (1) of [wall v]) = (item (3) of [wall v])>>> then\n        set [yv v] to [23]\n        if <touching (ground v)?> then\n            if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n                change [xv v] by (-10)\n            else\n                if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n                    change [xv v] by (10)\n                end\n            end\n        end\n        set [xv v] to ((xv) * (0.95))\n        change [x v] by (xv)\n    end\n    Position\nend\n\nwhen I receive [platformer: die v]\nbroadcast (Start v)\n\ndefine Position\ngo to x: ((x) - (ScrollX)) y: ((y) - (ScrollY))\n\ndefine Reset\ngo to x: (-220) y: (-90)\nset [win v] to [0]\nset [x v] to [0]\nset [y v] to [50]\nset [scrollx v] to [0]\nset [scrolly v] to [0]\nset [xv v] to [0]\nset [yv v] to [0]\nset [ghost v] effect to (0)\n\nwhen I receive [start v]\nforever\n    Reset\n    set [die v] to []\n    repeat until <not <(Die) = []>>\n        tick\n        broadcast (Game Loop v)\n    end\n    Die\nend\n\ndefine Die\nrepeat (20)\n    change [ghost v] effect by (5)\nend\nset [die v] to []\n\ndefine Joining\ndelete all of [join v]\ninsert (☁ P1) at (1) of [join v] \ninsert (☁ P2) at (2) of [join v] \ninsert (☁ P3) at (3) of [join v] \ninsert (☁ P4) at (4) of [join v] \nbroadcast (Setup v)\nbroadcast (Connecting v)\nwait (3) seconds\nif <(item (1) of [join v]) = (☁ P1)> then\n    set [p# v] to [1]\n    broadcast (Connected v)\nelse\n    if <(item (2) of [join v]) = (☁ P2)> then\n        set [p# v] to [2]\n        broadcast (Connected v)\n    else\n        if <(item (3) of [join v]) = (☁ P3)> then\n            set [p# v] to [3]\n            broadcast (Connected v)\n        else\n            if <(item (4) of [join v]) = (☁ P4)> then\n                set [p# v] to [4]\n                broadcast (Connected v)\n            else\n                broadcast (Server Full v)\n            end\n        end\n    end\nend\n\nwhen I receive [connected v]\nforever\n    Send Cloud\nend\n\nwhen flag clicked\nJoining\n\ndefine Write (value)\nset [letter # v] to [1]\nrepeat (length of (value))\n    set [encoded v] to (join (encoded) (item # of (letter (letter #) of (value)) in [code v]))\n    change [letter # v] by (1)\nend\nset [encoded v] to (join (encoded) [99])\n\ndefine Send (encoded) to (player #)\nif <(player #) = [1]> then\n    set [☁ p1 v] to (encoded)\nelse\n    if <(player #) = [2]> then\n        set [☁ p2 v] to (encoded)\n    else\n        if <(player #) = [3]> then\n            set [☁ p3 v] to (encoded)\n        else\n            if <(player #) = [4]> then\n                set [☁ p4 v] to (encoded)\n            end\n        end\n    end\nend\n\ndefine Send Cloud\nset [encoded v] to []\nWrite (timer)\nWrite (username)\nWrite (x)\nWrite (y)\nWrite (Cos)\nSend (encoded) to (P#)\n\n@Multiplayer\n\ndefine Decode\nset [value v] to []\nrepeat (round ((length of (cloud encoded)) / (2)))\n    set [value v] to (join (value) (item (join (letter (letter number) of (cloud encoded)) (letter ((letter number) + (1)) of (cloud encoded))) of [code v]))\n    change [letter number v] by (2)\n    if <(letter (letter number) of (cloud encoded)) = [9]> then\n        stop [this script v]\n    end\nend\n\ndefine Load Encoded (clone #)\nif <(clone #) = [1]> then\n    set [cloud encoded v] to (☁ P1)\nelse\n    if <(clone #) = [2]> then\n        set [cloud encoded v] to (☁ P2)\n    else\n        if <(clone #) = [3]> then\n            set [cloud encoded v] to (☁ P3)\n        else\n            if <(clone #) = [4]> then\n                set [cloud encoded v] to (☁ P4)\n            end\n        end\n    end\nend\n\nwhen I receive [connected v]\nforever\n    broadcast (Multiplayer v)\nend\n\ndefine Multiplayer\nLoad Encoded (Multiplayer ID)\nif <(online?) = (join [U] (cloud encoded))> then\n    change [offline v] by (2)\n    if <(offline) > [100]> then\n        set [offline v] to [101]\n        hide\n    end\nelse\n    if <not <(P#) = (Multiplayer ID)>> then\n        show\n        set [online? v] to (join [U] (cloud encoded))\n        set [offline v] to [0]\n    else\n        hide\n    end\nend\nset [letter number v] to [1]\nDecode\nDecode\nsay (value)\nDecode\nset x to ((value) - (ScrollX))\nDecode\nset y to ((value) - (ScrollY))\nDecode\nif <<<(x position) > [200]> or <(x position) < [-200]>> or <<(y position) > [160]> or <(y position) < [-160]>>> then\n    set rotation style [all around v]\n    switch costume to (arrow v)\n    point towards (player v)\n    if on edge, bounce\nelse\n    switch costume to (value)\n    point in direction (90)\nend\n\nwhen I receive [connected v]\nLoad Encoded (Multiplayer ID)\nset [online? v] to (join [U] (cloud encoded))\n\nwhen I receive [multiplayer v]\nMultiplayer\n\nwhen I receive [setup v]\nSetup\n\ndefine Setup\nset [multiplayer id v] to [1]\nrepeat (3)\n    hide\n    create clone of (_myself_ v)\n    change [multiplayer id v] by (1)\nend\n\nset [☁ p1 v] to []\nset [☁ p2 v] to []\nset [☁ p3 v] to []\nset [☁ p4 v] to []\n\n@Ground\n\nwhen I receive [start v]\nswitch costume to (nothing v)\nset size to (100) %\nset [x v] to [0]\nset [y v] to [0]\nClone x: [0] y: [0]\nClone x: [560] y: [-150]\nClone x: [-1150] y: [-300]\nClone x: [1700] y: [-100]\n\ndefine Clone x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nset [y v] to (y)\nnext costume\n\nwhen I receive [game loop v]\nPosition ((x) - (ScrollX)) ((y) - (ScrollY))\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\n@Spikes\n\nwhen I receive [start v]\nswitch costume to (nothing v)\nset size to (100) %\nset [x v] to [0]\nset [y v] to [0]\nClone x: [0] y: [0]\nClone x: [560] y: [-150]\nClone x: [-1150] y: [-300]\n\ndefine Clone x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nset [y v] to (y)\nnext costume\n\nwhen I receive [game loop v]\nPosition ((x) - (ScrollX)) ((y) - (ScrollY))\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\n@Water\n\nwhen I receive [start v]\nswitch costume to (nothing v)\nset [x v] to [0]\nset [y v] to [0]\nWater Clone x: [-500] y: [-130]\n\ndefine Water Clone x: (x) y: (y)\nset [water v] to [0]\nrepeat (3)\n    create clone of (_myself_ v)\n    set [x v] to (x)\n    set [y v] to (y)\n    change [water v] by (1)\n    switch costume to (1 v)\nend\n\nnext costume\n\nwhen I receive [game loop v]\nPosition ((x) - (ScrollX)) ((y) - (ScrollY))\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nchange [y2 v] by (([sin v] of (((days since 2000) * (10000000)) * (join [1.] (Water))) ) / (1.7))\nset [ghost v] effect to (50)\nset size to (100) %\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\n@Bounce Pad\n\nwhen I receive [start v]\nclear graphic effects\nswitch costume to (nothing v)\nset [x v] to [0]\nset [y v] to [0]\nClone x: [760] y: [-130]\n\ndefine Clone x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nswitch costume to (1 v)\n\nwhen I receive [game loop v]\nPosition ((x) - (ScrollX)) ((y) - (ScrollY))\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nset size to (100) %\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\n@Win\n\nwhen I receive [start v]\nclear graphic effects\nswitch costume to (nothing v)\nset [x v] to [0]\nset [y v] to [0]\nClone x: [1100] y: [115]\n\ndefine Clone x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [x v] to (x)\nset [y v] to (y)\nswitch costume to (1 v)\n\nwhen I receive [game loop v]\nPosition ((x) - (ScrollX)) ((y) - (ScrollY))\n\ndefine Position (x) (y)\ngo to x: (x) y: (y)\nchange [y v] by (([cos v] of ((days since 2000) * (10000000)) ) / (3))\nset size to (100) %\nif <<(x position) = (x)> and <(y position) = (y)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\n@Server Messages\n\nwhen I receive [connected v]\nshow\nswitch costume to (connected v)\nclear graphic effects\nwait (1) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen I receive [connecting v]\nshow\nswitch costume to (connecting v)\n\nwhen I receive [server full v]\nshow\nswitch costume to (server full v)\nclear graphic effects\nwait (1) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen flag clicked\nhide\ngo to x: (185) y: (160)\n\n@Tn\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nforever\n    reset timer\nend\n\nwhen [timer v] > (0.1)\ngo to [front v] layer\nif <(Win) = [win]> then\n    switch costume to (win v)\n    show\n    set [ghost v] effect to (100)\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\nelse\n    switch costume to (tn v)\n    show\n    set [ghost v] effect to (100)\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\nend\n\n