Scratch Online Platformer Game 

Instructions: d-right   a-left  space-jump\nWallSlide\nJump Through Platform \nand more!\n\n*A bit glitch in Jump Through Platform. Be Careful \nA bit lag, because this is cloud game. Make sure your internet is full!

@Stage\n\nwhen flag clicked\n\nwhen [r v] key pressed\nbroadcast (Loading... v)\nwait (3) seconds\nbroadcast (Reset Game  v) and wait\nwait (0) seconds\nbroadcast (Start Game v)\n\nwhen I receive [green flag clicked v]\nswitch backdrop to (wolcome v)\nhide variable [apple v]\nhide variable [lives v]\nhide variable [level v]\n\n@ThumbNail\n\nwhen flag clicked\ngo to x: (0) y: (0)\nforever\n    show\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\n@Intro\n\nwhen flag clicked\ngo to [front v] layer\nset [ghost v] effect to (100)\nswitch costume to (costume1 v)\nwait (0.8) seconds\nrepeat (2)\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\n    wait (3) seconds\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    next costume\n    wait (0.9) seconds\nend\nbroadcast (Green Flag Clicked v)\n\n@Player\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 - Ceiling or Floor?\n    end\nend\n\ndefine Check Touching Solid\nif <<touching (level v)?> or <touching (platform v)?>> then\n    set [touching v] to [1]\n    stop [this script v]\nend\nset [touching v] to [0]\nset [hit costume v] to (costume [name v])\nif <(hit costume) = [hit boxv2]> then\n    switch costume to (hit box feet v)\nend\nif <touching (jump through v)?> then\n    if <(jump through) < [1]> then\n        change y by (-6)\n        if <(hit costume) = [hit boxv2]> then\n            switch costume to (hit box feet2 v)\n        end\n        if <touching (jump through v)?> then\n            set [touching v] to [1]\n        else\n            set [jump through v] to [1]\n        end\n        change y by (6)\n    end\nelse\n    set [jump through v] to [0]\nend\nswitch costume to (hit costume)\n\nwhen I receive [tick-player v]\nMoved by Moving Platformer\nswitch backdrop to <touching (level v)?>\nControls - Up And Down\nControls - Left And Right\nmove - in steps (([abs v] of (speed x) ) + ([abs v] of (speed y) ))\nSet Costume\n\ndefine Controls - Up And Down\nif <<key (space v) pressed?> or <key (up arrow v) pressed?>> then\n    if <<(wall slide) > [0]> and <(Jumping) = [0]>> then\n        start sound [Jump 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 <<(falling) < [3]> and <(Jumping) = [0]>> then\n        start sound [Jump 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 (<<key (d v) pressed?> or <key (right arrow v) pressed?>> - <<key (a v) pressed?> or <key (left arrow v) pressed?>>)\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    if <not <(direction) = ((Key X) * (90))>> then\n        set [wall slide v] to [0]\n    end\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\nshow variable [apple v]\nshow variable [lives v]\nshow variable [level v]\nset [invulnerable v] to [0]\nset [speed y v] to [0]\nset [speed x v] to [0]\nset [falling v] to [99]\nset [wall slide v] to [0]\nset [jumping v] to [0]\nset [long jump v] to [0]\npoint in direction (90)\nBegin Scene # (Spawn Scene) go to x, y: (Spawn X) (Spawn Y)\n\nwhen I receive [game loop v]\nset [ghost v] effect to (0)\nforever\n    broadcast (Tick - First v)\n    broadcast (Tick - Platforms v)\n    broadcast (Tick-Player v)\n    add (x position) to [my values to send v]\n    add (y position) to [my values to send v]\n    add (costume [number v]) to [my values to send v]\n    add (direction) to [my values to send v]\n    add (LEVEL) to [my values to send v]\n    broadcast (Cloud - Tick v)\n    broadcast (Tick-Last v)\nend\n\nwhen I receive [tick-last v]\nif <(x position) > [235]> then\n    Begin Scene # ((LEVEL) + (1)) go to x, y: [-235] []\nend\nif <(x position) < [-235]> then\n    Begin Scene # ((LEVEL) + (-1)) go to x, y: [235] []\nend\nif <(y position) > [180]> then\n    Begin Scene # ((LEVEL) + (100)) go to x, y: [] [-160]\nend\nif <(y position) < [-180]> then\n    Begin Scene # ((LEVEL) + (-100)) go to x, y: [] [160]\nend\nif <touching (danger v)?> then\n    broadcast (Lose Life v)\nend\n\ndefine Begin Scene # (scene #) go to x, y: (x) (y)\nset [level v] to (scene #)\nif <(x) > []> then\n    set x to (x)\nend\nif <(y) > []> then\n    set y to (y)\nend\nbroadcast (About to Change Scene v)\nbroadcast (Change Scene v)\nstop [other scripts in sprite v]\nwait (0) seconds\nswitch costume to (hit boxv2 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 [0]\nset [distance v] to [0]\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 (hit boxv2 v)\nset rotation style [don't rotate v]\nset [platform dx v] to []\nset [platform dy v] to []\n\ndefine Set Costume\nset rotation style [left-right v]\nif <(wall slide) > [0]> then\n    switch costume to (hang on v)\n    stop [this script v]\nend\nif <(falling) > [1]> then\n    if <(speed y) > [0]> then\n        switch costume to (jump3 v)\n    else\n        switch costume to (jump 2 v)\n    end\n    stop [this script v]\nend\nif <(frame) > [0]> then\n    switch costume to ((1) + ([floor v] of ((frame) mod (17)) ))\nelse\n    switch costume to (shb1 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) * (0.8))\nend\nset [speed x v] to ((speed x) * (0.95))\nSlip\n\ndefine Collide Y - Ceiling 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\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 (wall slide v)\nset rotation style [left-right v]\nCheck Touching Solid\nset [wall slide v] to (touching)\nswitch costume to (hit boxv2 v)\nset rotation style [don't rotate v]\n\nwhen I receive [lose life v]\nset [invulnerable v] to [1]\nhide variable [apple v]\nhide variable [lives v]\nhide variable [level v]\nstop [other scripts in sprite v]\nstart sound [Oops v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nwait (0.5) seconds\nchange [lives v] by (-1)\nif <(LIVES) > [0]> then\n    Reset And Begin Level\nelse\n    broadcast (Game Over v)\nend\n\ndefine Moved by Moving Platformer\nchange x by (Platform DX)\nchange y by (Platform DY)\nCheck Touching Solid\nif <(touching) > [0]> then\n    Find Closest Space to (x position) (y position) max [16]\n    if <(touching) > [0]> then\n        broadcast (Lose Life v)\n    end\nend\n\ndefine Find Closest Space to (x) (y) max (max)\nset [temp v] to [0]\nset [distance v] to [0]\npoint in direction (0)\nrepeat (max)\n    repeat (16)\n        go to x: (x) y: (y)\n        move (distance) steps\n        Check Touching Solid\n        if <(touching) < [1]> then\n        turn right (22.5) degrees\n    end\n    change [distance v] by (1)\nend\ngo to x: (x) y: (y)\npoint in direction (temp)\n\nwhen I receive [start game v]\nbroadcast (Loading... v)\nwait (3) seconds\nshow variable [apple v]\nshow variable [lives v]\nshow variable [level v]\nshow variable [username v]\nshow\nset [gravity v] to [-1.5]\nset [jump force v] to [15]\nset [jump duration v] to [6]\nset [acceleration v] to [1.5]\nset [resistance v] to [0.8]\nbroadcast (Reset Game  v) and wait\nbroadcast (Setup v) and wait\nset [lives v] to [3]\nset [spawn scene v] to [1]\nset [spawn x v] to [-125]\nset [spawn y v] to [73]\nReset And Begin Level\n\nwhen I receive [player - bounce v]\nset [speed y v] to [15]\n\nwhen I receive [green flag clicked v]\nset [color v] effect to (18)\nbroadcast (Cloud - Setup v) and wait\nbroadcast (Main Menu v)\nshow list [player uids v]\nhide\n\nwhen flag clicked\nset [username v] to (username)\nhide variable [apple v]\nhide variable [lives v]\nhide variable [level v]\nhide variable [username v]\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]\nhide\nsay (username)\nset [cloud tick v] to [0]\ndelete all of [my values to send v]\ndelete all of [cloud value v]\ndelete all of [player uids v]\ndelete all of [player data v]\nadd (join [c] (☁ Cloud 1)) to [cloud value v]\nadd (join [c] (☁ Cloud 2)) to [cloud value v]\nadd (join [c] (☁ Cloud 3)) to [cloud value v]\nadd (join [c] (☁ Cloud 4)) to [cloud value v]\nadd (join [c] (☁ Cloud 5)) to [cloud value v]\nadd (join [c] (☁ Cloud 6)) to [cloud value v]\nadd (join [c] (☁ Cloud 7)) to [cloud value v]\nadd (join [c] (☁ Cloud 8)) to [cloud value v]\nset [my player uid v] to (pick random (1) to (9999999))\nset [player # v] to []\n\nwhen I receive [cloud - tick v]\nif <(Player #) > []> then\n    Player Clone Tick\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 [4] 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 value 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 value v])> then\n    stop [this script v]\nend\nreplace item (which?) of [cloud value 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    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\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) > [150]> then\n            replace item (Player #) of [player uids v] with []\n            hide\n        end\n        stop [this script v]\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"\npoint in direction (Val)\nval=Read Number from "Encoded String"\nset [clone scene # v] to (Val)\nif <(Clone Scene #) = (LEVEL)> then\n    show\nelse\n    hide\nend\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\nbroadcast (Cloud - Setup v) and wait\nforever\n    add (x position) to [my values to send v]\n    add (y position) to [my values to send v]\n    add (costume [number v]) to [my values to send v]\n    add (direction) to [my values to send v]\n    broadcast (Cloud - Tick v)\nend\n\nwhen I receive [change scene v]\nif <(Player #) = []> then\n    if <(Clone Scene #) = (LEVEL)> then\n        show\n    else\n        hide\n    end\nend\n\n@Level\n\nwhen I receive [change scene v]\nswitch costume to (join [Scene] (LEVEL))\nStamp Outline\nStamp Shadow\n\ndefine Stamp Outline\nset rotation style [don't rotate v]\nset [brightness v] effect to (-100)\nrepeat (8)\n    move (3) steps\n    stamp\n    move (-3) steps\n    turn right (45) degrees\nend\nclear graphic effects\n\ndefine Stamp Shadow\nset [brightness v] effect to (-100)\nset [ghost v] effect to (90)\nchange y by (-20)\nstamp\nchange y by (20)\nclear graphic effects\n\nwhen I receive [start game v]\nshow\n\nwhen I receive [about to change scene v]\nerase all\n\nwhen I receive [green flag clicked v]\ngo to x: (0) y: (0)\ngo to [back v] layer\nerase all\nhide\n\n@Jump Through\n\nwhen flag clicked\n\nwhen I receive [change scene v]\nswitch costume to (blank v)\nswitch costume to (join [Scene] (LEVEL))\nStamp Outline\nStamp Shadow\n\ndefine Stamp Outline\nset rotation style [don't rotate v]\nset [brightness v] effect to (-100)\nrepeat (8)\n    move (3) steps\n    stamp\n    move (-3) steps\n    turn right (45) degrees\nend\nclear graphic effects\n\ndefine Stamp Shadow\nset [brightness v] effect to (-100)\nset [ghost v] effect to (90)\nchange y by (-10)\nstamp\nchange y by (10)\nclear graphic effects\n\nwhen I receive [start game v]\nshow\n\nwhen I receive [green flag clicked v]\ngo to x: (0) y: (0)\ngo to [back v] layer\nerase all\nhide\n\n@Danger\n\nwhen flag clicked\n\nwhen I receive [change scene v]\nswitch costume to (blank v)\nswitch costume to (join [Scene] (LEVEL))\nif <(LEVEL) = [104]> then\n    forever\n        set y to ((3) * ([sin v] of ((timer) * (180)) ))\n    end\nend\nif <(LEVEL) = [2]> then\n    forever\n        set y to ((3) * ([sin v] of ((timer) * (180)) ))\n    end\nend\n\nwhen I receive [green flag clicked v]\ngo to x: (0) y: (0)\ngo to [back v] layer\n\n@Colletable Things\n\nwhen I receive [change scene v]\nif <(LEVEL) = (My Scene)> then\n    show\nelse\n    hide\nend\n\nwhen I start as a clone\nrepeat until <touching (player v)?>\n    change y by ((0.5) * ([sin v] of (frame) ))\n    change [frame v] by (5)\nend\nset [my scene v] to []\nif <(costume [name v]) = [apple]> then\n    start sound [Chomp v]\n    change [apple v] by (1)\nelse\n    if <(costume [name v]) = [Green Flag]> then\n        say [CheckPointed!]\n        start sound [Basketball Bounce v]\n        set [spawn scene v] to (LEVEL)\n        set [spawn x v] to ([x position v] of [player v])\n        set [spawn y v] to ([x position v] of [player v])\n    else\n        start sound [Wand v]\n        add (costume [name v]) to [collected v]\n        change [apple v] by (3)\n    end\nend\nrepeat (20)\n    change y by (2)\n    change [ghost v] effect by (5)\nend\nhide\n\nwhen I receive [setup v]\ndelete all of [collected v]\nset [frame v] to [0]\nset [apple v] to [0]\nPlace [apple] scene [1] xy [177] [10]\nPlace [apple] scene [1] xy [-31] [61]\nPlace [apple] scene [2] xy [18] [21]\nPlace [apple] scene [103] xy [-173] [83]\nPlace [apple] scene [103] xy [173] [83]\nPlace [Key 1] scene [103] xy [179] [-2]\nPlace [Green Flag] scene [3] xy [92] [-59]\nPlace [apple big] scene [5] xy [127] [-10]\nPlace [Green Flag] scene [204] xy [32] [-90]\nPlace [Key 2] scene [206] xy [212] [-92]\nPlace [apple] scene [4] xy [99] [109]\nPlace [apple] scene [6] xy [0] [0]\nPlace [apple] scene [7] xy [32] [101]\nPlace [apple] scene [7] xy [32] [101]\nPlace [apple] scene [205] xy [-200] [-80]\nPlace [apple] scene [205] xy [-100] [-80]\nPlace [apple] scene [205] xy [0] [-80]\nPlace [apple] scene [205] xy [100] [-80]\nPlace [apple] scene [205] xy [200] [-80]\nPlace [Green Flag] scene [7] xy [97] [-74]\nPlace [Green Flag] scene [9] xy [182] [30]\nPlace [apple] scene [9] xy [-16] [26]\nPlace [Key 3] scene [115] xy [171] [-67]\nPlace [Green Flag] scene [117] xy [-149] [-117]\n\ndefine Place (costume name) scene (scene) xy (x) (y)\nset [my scene v] to (scene)\nswitch costume to (costume name)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [my scene v] to []\n\nwhen I receive [reset game  v]\ndelete this clone\n\n@Platform\n\nwhen I receive [change scene v]\nswitch costume to (platform v)\ngo to [back v] layer\nhide\nif <(LEVEL) = [4]> then\n    set size to (100) %\n    Door at [-41] [67] key [Key 1]\nend\nif <(LEVEL) = [7]> then\n    set size to (100) %\n    Door at [-105] [-53] key [Key 2]\nend\nif <(LEVEL) = [105]> then\n    show\n    set size to (100) %\n    Animate 3\nend\nif <(LEVEL) = [104]> then\n    show\n    set size to (100) %\n    Animate Platform\nend\nif <(LEVEL) = [8]> then\n    show\n    set size to (100) %\n    Animate 2\nend\nif <(LEVEL) = [16]> then\n    show\n    set size to (100) %\n    Door at [-61] [-50] key [Key 3]\nend\n\ndefine Animate Platform\ngo to x: (146) y: (-20)\npoint in direction (90)\nforever\n    glide (1) secs to x: (68) y: (-20)\n    wait (0.5) seconds\n    glide (1) secs to x: (146) y: (-20)\n    wait (0.5) seconds\nend\n\nwhen I receive [tick - platforms v]\nTick (x position) (y position)\nset [last x v] to (x position)\nset [last y v] to (y position)\n\ndefine Tick (new x) (new y)\nif <(turn) > []> then\n    change y by (4)\n    if <touching (player v)?> then\n        Rotation Maths CCW ((0) - (turn))\n    end\nelse\n    if <(new y) > (last y)> then\n        change y by (1)\n    else\n        set y to ((last y) + (1))\n    end\n    if <touching (player v)?> then\n        set [platform dx v] to ((new x) - (last x))\n        set [platform dy v] to ((new y) - (last y))\n    end\nend\ngo to x: (new x) y: (new y)\n\ndefine Animate 2\ngo to x: (-89) y: (-36)\npoint in direction (0)\nforever\n    glide (2) secs to x: (92) y: (-36)\n    wait (1) seconds\n    glide (2) secs to x: (-89) y: (-36)\n    wait (1) seconds\nend\n\ndefine Animate 3\ngo to x: (-68) y: (-20)\npoint in direction (90)\nforever\n    glide (1) secs to x: (-146) y: (-20)\n    go to x: (-68) y: (-20)\n    point in direction (90)\n    forever\n        glide (1) secs to x: (-146) y: (-20)\n        wait (0.5) seconds\n        glide (1) secs to x: (-68) y: (-20)\n        wait (0.5) seconds\n    end\nend\n\ndefine Door at (x) (y) key (key name)\nshow\nswitch costume to (key name)\ngo to x: (x) y: (y)\nforever\n    wait until <touching (player v)?>\n    if <[collected v] contains (key name)?> then\n        start sound [Buzz Whir v]\n        repeat (24)\n            change y by (4)\n        end\n        wait (1) seconds\n        start sound [Buzz Whir v]\n        repeat (24)\n            change y by (-4)\n        end\n        start sound [Crunch v]\n        wait (1) seconds\n    else\n        start sound [Low Squeak v]\n    end\n    wait until <not <touching (player v)?>>\nend\n\nwhen flag clicked\n\ndefine Animate 4\nshow\npoint in direction (90)\nforever\n    glide (1) secs to x: (x position) y: ((y position) - (90))\n    wait (0.5) seconds\n    glide (1) secs to x: (x position) y: ((y position) + (90))\n    wait (0.5) seconds\nend\n\nwhen flag clicked\nset rotation style [left-right v]\nhide\n\nwhen I receive [about to change scene v]\ndelete this clone\n\ndefine Spawn (type) at (x) (y) direction (direction) turn (degrees)\nset [turn v] to (degrees)\ngo to x: (x) y: (y)\npoint in direction (direction)\nswitch costume to (type)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nif < (costume [name v]) contains [Key]?> then\n    Door at (x position) (y position) key (costume [name v])\n    Door at (x position) (y position) key (costume [name v])\nend\nif <(turn) > []> then\n    show\n    set rotation style [all around v]\n    forever\n        turn right (turn) degrees\n    end\nend\nAnimate 4\n\ndefine Rotation Maths CCW (ccw)\nset [dx v] to (([x position v] of [player v]) - (x position))\nset [dy v] to (([y position v] of [player v]) - (y position))\nset [sin v] to ([sin v] of (ccw) )\nset [cos v] to ([cos v] of (ccw) )\nset [platform dx v] to ((((dx) * (cos)) - ((dy) * (sin))) - (dx))\nset [platform dy v] to ((((dx) * (sin)) + ((dy) * (cos))) - (dy))\n\nwhen I receive [green flag clicked v]\nhide\n\n@Splash Screen\n\nwhen flag clicked\n\nwhen I receive [game over v]\nstart sound [Boom Cloud v]\ngo to x: (0) y: (0)\nswitch costume to (game over v)\ngo to [front v] layer\nshow\nbroadcast (Main Menu v)\n\nwhen I receive [start game v]\nhide\n\nwhen I receive [change scene v]\nif <(LEVEL) = [21]> then\n    show\n    switch costume to (progress v)\nelse\n    hide\nend\n\nwhen I receive [loading... v]\nshow\nswitch costume to (loading v)\n\nwhen I receive [green flag clicked v]\ngo to x: (0) y: (0)\nswitch costume to (main menu v)\ngo to [front v] layer\nshow\n\n@Main Menu\n\nwhen I receive [main menu v]\nwait (0.1) seconds\nswitch costume to (play button v)\ngo to [front v] layer\nshow\nset size to (10) %\ngo to x: (0) y: (-98)\nforever\n    if <touching (mouse-pointer v)?> then\n        change size by ((0.2) * ((110) - (size)))\n    else\n        change size by ((0.2) * ((100) - (size)))\n    end\nend\n\nwhen flag clicked\n\nwhen this sprite clicked\nhide\nbroadcast (Start Game v)\n\nwhen I receive [green flag clicked v]\nhide\n\n@Enemy\n\nwhen flag clicked\n\nwhen I receive [change scene v]\nif <(LEVEL) = [1]> then\n    Spawn [Red] at [67] [-65] direction [-90]\nend\nif <(LEVEL) = [4]> then\n    Spawn [Red] at [130] [19] direction [90]\nend\nif <(LEVEL) = [206]> then\n    Spawn [Red] at [77] [-94] direction [90]\nend\nif <(LEVEL) = [12]> then\n    Spawn [Red] at [203] [-91] direction [90]\nend\nif <(LEVEL) = [117]> then\n    Spawn [Red] at [0] [-117] direction [90]\nend\n\nwhen I start as a clone\nset [speed y v] to [0]\nset [frame v] to [0]\nshow\nforever\n    switch costume to (red1 v)\n    set rotation style [don't rotate v]\n    Move - Left and Right\n    Move - Down\n    change [frame v] by (0.33)\n    switch costume to ((1) + (([floor v] of (frame) ) mod (4)))\n    set rotation style [don't rotate v]\n    if <<(Invulnerable) = [0]> and <touching (player v)?>> then\n        Touching Player\n    end\nend\n\nwhen I receive [about to change scene v]\ndelete this clone\n\ndefine Move - Down\nchange [speed y v] by (-1)\nchange y by (speed y)\nrepeat until <not <<touching (level v)?> or <touching (jump through v)?>>>\n    change y by (1)\n    set [speed y v] to [0]\nend\n\ndefine Move - Left and Right\nmove (2) steps\nrepeat (4)\n    if <not <<touching (level v)?> or <touching (jump through v)?>>> then\n        if <not <<touching (platform v)?> or <touching (_edge_ v)?>>> then\n            if <not <touching (safe zone v)?>> then\n                stop [this script v]\n            end\n        end\n    end\n    change y by (1)\nend\nchange y by (-4)\nmove (-2) steps\nturn right (180) degrees\n\ndefine Touching Player\nif <([speed y v] of [player v]) < [-3]> then\n    broadcast (Player - Bounce v)\n    start sound [Squish Pop v]\n    switch costume to (red squish v)\n    wait (0.3) seconds\n    change [ghost v] effect by (10)\n    delete this clone\nend\nbroadcast (Lose Life v)\n\ndefine Spawn (type) at (x) (y) direction (direction)\ngo to x: (x) y: (y)\npoint in direction (direction)\ncreate clone of (_myself_ v)\n\nwhen I receive [green flag clicked v]\nset rotation style [left-right v]\nhide\n\n@Safe Zone\n\nwhen flag clicked\n\nwhen I receive [change scene v]\nswitch costume to (blank v)\nswitch costume to (join [Scene] (LEVEL))\n\nwhen I receive [green flag clicked v]\ngo to x: (0) y: (0)\ngo to [back v] layer\nset [ghost v] effect to (100)\n\n@Music\n\nwhen I receive [start game v]\nset volume to (100) %\nchange volume by (-25)\n\nwhen I receive [game over v]\nchange volume by (-100)\n\nwhen I receive [game loop v]\nset volume to (100) %\nchange volume by (-25)\n\nwhen I receive [loading... v]\nset volume to (100) %\nchange volume by (-50)\n\nwhen I receive [green flag clicked v]\ngo to [back v] layer\nset volume to (100) %\nforever\n    play sound [Bossa Nova v] until done\nend\n\n@Random Person\n\nwhen flag clicked\n\nwhen I receive [change scene v]\nif <(LEVEL) = [16]> then\n    Spawn [Pico] at [12] [89] direction [90] saying (join [Never give up, ] (join (username) [!!!]))\nend\n\nwhen I start as a clone\nset [speed y v] to [0]\nset [frame v] to [0]\nshow\nforever\n    change y by ((0.5) * ([sin v] of (frame) ))\n    change [frame v] by (5)\nend\n\nwhen I receive [about to change scene v]\ndelete this clone\n\ndefine Spawn (type) at (x) (y) direction (direction) saying (word)\nsay (word)\ngo to x: (x) y: (y)\npoint in direction (direction)\ncreate clone of (_myself_ v)\n\nwhen I receive [green flag clicked v]\nset rotation style [left-right v]\nhide\n\n@Curtain\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [front v] layer\nset [ghost v] effect to (0)\ngo [backward v] (1) layers\n\nwhen I receive [green flag clicked v]\nset [ghost v] effect to (100)\n\n