Platformer

Instructions: Arrow keys to move\n___________________________________________\n17/12/21 - added new heart collectables\n___________________________________________\n31/12/21 - added enemies\n___________________________________________\n20/03/2022 - Added moving platforms

@Stage\n\nwhen flag clicked\nforever\n    if <(SCENE #) = [306]> then\n    end\n    if <<(SCENE #) = [206]> and <<([x position v] of [player v]) > [-70]> and <([y position v] of [player v]) > [37]>>> then\n        stop [this script v]\n    end\nend\n\nstart sound [ttsMP2 v]\nwait until <not <(SCENE #) = [206]>>\n\nwhen flag clicked\nforever\n    play sound [Vexento - Smile v] until done\nend\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 (platform v)?> or <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]\nMoved By Moving Platform\nswitch backdrop to <touching (level v)?>\nControls - Up and Down\nControls - Left and Right\nMove In Steps (([abs v] of (speed y) ) + ([abs v] of (speed x) ))\nSet Costume\n\ndefine Controls - Up and Down\nif <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    if <<(Wall slide) > [0]> and <(Jumping) = [0]>> then\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 [long jump v] to [12]\n        set [speed x v] to (((direction) / (90)) * (7))\n    end\n    if <<(falling) < [3]> and <(Jumping) = [0]>> then\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 (right arrow v) pressed?> or <key (d v) pressed?>> - <<key (left arrow v) pressed?> or <key (a 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.8))\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\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    broadcast (Tick - Last v)\nend\n\nwhen I receive [tick - last v]\nif <(x position) > [235]> then\n    Begin Scene # ((SCENE #) + (1)) Go To x, y: [-235] []\nend\nif <(x position) < [-235]> then\n    Begin Scene # ((SCENE #) + (-1)) Go To x, y: [235] []\nend\nif <(y position) > [180]> then\n    Begin Scene # ((SCENE #) + (100)) Go To x, y: [] [-160]\nend\nif <(y position) < [-180]> then\n    Begin Scene # ((SCENE #) + (-100)) Go To x, y: [] [180]\nend\nif <touching (danger v)?> then\n    broadcast (Lose Life v)\nend\n\ndefine Begin Scene # (scene #) Go To x, y: (x) (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)\nbroadcast (leave 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 Collisions in Direction [0]\nelse\n    Fix Collisions in Direction [90]\nend\nSet Costume\nbroadcast (Game Loop v)\n\ndefine Fix Collisions 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]\nset [platform dx v] to [0]\nset [platform dy v] to [0]\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 ((1) + ([floor v] of ((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) * (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 (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 I receive [lose life v]\nset [invulnerable v] to [1]\nstop [other scripts in sprite v]\nstart sound [die 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 Platform\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 (direction)\nset [distance v] to [1]\npoint in direction (0)\nrepeat (max)\n    go to x: (x) y: (y)\n    move (Distance) steps\n    Check Touching Solid\n    if <(Touching) < [1]> then\n        point in direction (Temp)\n        stop [this script v]\n    end\n    turn right (22.5) degrees\n    change [distance v] by (1)\nend\ngo to x: (x) y: (y)\npoint in direction (Temp)\n\nwhen I receive [locked v]\nsay [Locked!] for (0.5) seconds\n\nwhen I receive [start game v]\nshow\ngo to [front v] layer\nset [lives v] to [3]\nset [resistance v] to [0.8]\nset [gravity v] to [-2]\nset [jump force v] to [15]\nset [acceleration v] to [3]\nset [jump duration v] to [6]\nbroadcast (Reset Game v)\nbroadcast (setup v) and wait\nset [spawn scene v] to [1]\nset [spawn x v] to [-150]\nset [spawn y v] to [55]\nReset and Begin level\n\nwhen flag clicked\nbroadcast (Main Menu v)\n\nwhen I receive [player - bounce v]\nset [speed y v] to [20]\n\n@Level\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 flag clicked\ngo to x: (0) y: (0)\ngo to [back v] layer\n\nwhen I receive [change scene v]\nswitch costume to (join [Scene] (SCENE #))\nerase all\nstamp shadow\n\nwhen flag clicked\nshow\nforever\n    if <(costume [number v]) = [1]> then\n        broadcast (Scene1 v)\n    else\n        if <(costume [number v]) = [2]> then\n            broadcast (scene2 v)\n        else\n            if <(costume [number v]) = [3]> then\n                broadcast (scene3 v)\n            else\n                if <(costume [number v]) = [4]> then\n                    broadcast (scene4 v)\n                else\n                    if <(costume [number v]) = [5]> then\n                        broadcast (scene5 v)\n                    else\n                        if <(costume [number v]) = [6]> then\n                            broadcast (scene5 v)\n                        else\n                            if <(costume [name v]) = [scene101]> then\n                                broadcast (scene 101 v)\n                            else\n                                if <(costume [name v]) = [scene102]> then\n                                    broadcast (scene102 v)\n                                else\n                                    if <(costume [name v]) = [scene103]> then\n                                        broadcast (scene103 v)\n                                    else\n                                        if <(costume [name v]) = [scene104]> then\n                                            broadcast (scene104 v)\n                                        else\n                                            if <(costume [name v]) = [scene105]> then\n                                                broadcast (scene105 v)\n                                            else\n                                                if <(costume [name v]) = [scene106]> then\n                                                    broadcast (scene106 v)\n                                                end\n                                            end\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nforever\n\nset volume to (50) %\nplay sound [Trap Beat v] until done\n\nwhen flag clicked\nforever\n\n@tree\n\nwhen I receive [change scene v]\ngo to [back v] layer\nif <(SCENE #) = [2]> then\n    switch costume to (short tree v)\n    go to x: (-7) y: (-9)\n    show\nelse\n    if <(SCENE #) = [103]> then\n        switch costume to (short tree v)\n        go to x: (-168) y: (22)\n        show\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to [back v] layer\nif <(SCENE #) = [2]> then\n    switch costume to (short tree v)\n    go to x: (-7) y: (-9)\n    show\nelse\n    if <(SCENE #) = [103]> then\n        switch costume to (short tree v)\n        go to x: (-168) y: (22)\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [change scene v]\nif <(SCENE #) = [102]> then\n    go to x: (-46) y: (-77)\n    show\nelse\n    hide\nend\n\n@clouds\n\nwhen flag clicked\nset [ghost v] effect to (0)\nforever\n    hide\n    wait (pick random (3) to (5)) seconds\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nshow\nswitch costume to (pick random (1) to (5))\nif <(pick random (1) to (2)) = [2]> then\n    set [d v] to [-250]\nelse\n    set [d v] to [250]\nend\ngo to x: (d) y: (pick random (-50) to (170))\nset [ghost v] effect to (pick random (40) to (70))\nif <(d) = [250]> then\n    repeat until <(x position) < [-267]>\n        change x by (pick random (-1) to (-2))\n        go to [back v] layer\n        go [forward v] (1) layers\n    end\nelse\n    repeat until <(x position) > [267]>\n        change x by (pick random (1) to (2))\n        go to [back v] layer\n        go [forward v] (1) layers\n    end\nend\ndelete this clone\n\nwhen I start as a clone\nif <touching (level v)?> then\n    hide\nelse\n    show\nend\n\n@Thumbnail\n\nwhen flag clicked\nhide\n\nshow\ngo to [front v] layer\n\n@Danger\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [back v] layer\nforever\n    go [backward v] (1) layers\nend\n\nwhen I receive [change scene v]\nswitch costume to (blank v)\nswitch costume to (join [Scene] (SCENE #))\nforever\n    set y to ((5) * ([sin v] of ((timer) * (180)) ))\nend\n\nwhen flag clicked\nhide\ngo to [front v] layer\nforever\n    if <(costume [number v]) = [1]> then\n        broadcast (Scene1 v)\n    else\n        if <(costume [number v]) = [2]> then\n            broadcast (scene2 v)\n        else\n            if <(costume [number v]) = [3]> then\n                broadcast (scene3 v)\n            else\n                if <(costume [number v]) = [4]> then\n                    broadcast (scene4 v)\n                else\n                    if <(costume [number v]) = [5]> then\n                        broadcast (scene5 v)\n                    else\n                        if <(costume [number v]) = [6]> then\n                            broadcast (scene5 v)\n                        else\n                            if <(costume [name v]) = [scene101]> then\n                                broadcast (scene 101 v)\n                            else\n                                if <(costume [name v]) = [scene102]> then\n                                    broadcast (scene102 v)\n                                else\n                                    if <(costume [name v]) = [scene103]> then\n                                        broadcast (scene103 v)\n                                    else\n                                        if <(costume [name v]) = [scene104]> then\n                                            broadcast (scene104 v)\n                                        else\n                                            if <(costume [name v]) = [scene105]> then\n                                                broadcast (scene105 v)\n                                            else\n                                                if <(costume [name v]) = [scene106]> then\n                                                    broadcast (scene106 v)\n                                                end\n                                            end\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nforever\nend\n\nset volume to (20) %\nplay sound [Dance Chill Out v] until done\n\nwhen I receive [start game v]\nshow\n\n@Platform\n\nwhen I receive [change scene v]\nset x to (0)\nhide\nif <(SCENE #) = [3]> then\n    show\n    Animate Platform\nend\nif <(SCENE #) = [6]> then\n    Door at [0] [-74] key [key 1]\nend\nif <(SCENE #) = [103]> then\n    switch costume to (costume2 v)\n    show\n    Animate 2\nend\nif <(SCENE #) = [104]> then\n    switch costume to (costume3 v)\n    show\n    Animate 2\nend\nif <(SCENE #) = [204]> then\n    switch costume to (costume4 v)\n    show\n    Animate 2\nend\nif <(SCENE #) = [205]> then\n    switch costume to (costume5 v)\n    show\n    Animate 2\nend\nif <(SCENE #) = [206]> then\n    switch costume to (costume6 v)\n    show\n    Animate 2\nend\n\ndefine Animate Platform\ngo to x: (-39) y: (-74)\nswitch costume to (costume1 v)\nforever\n    wait (1) seconds\n    glide (2.5) secs to x: (240) y: (-74)\n    wait (1) seconds\n    glide (2.5) secs to x: (-39) y: (-74)\nend\n\ngo to x: (-39) y: (-74)\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 <(new y) > (Last Y)> then\n    change y by (1)\nelse\n    set y to ((Last Y) + (1))\nend\nif <touching (player v)?> then\n    set [platform dx v] to ((new x) - (Last X))\n    set [platform dy v] to ((new y) - (Last Y))\nend\ngo to x: (new x) y: (new y)\n\ndefine Animate 2\nforever\n    set y to ((-30) + (([cos v] of (((timer) - (3)) * (200)) ) * (8)))\nend\n\nAnimate 2\n\ndefine Door at (x) (y) key (key name)\nshow\nswitch costume to (key name)\nshow\ngo to x: (x) y: (y)\nforever\n    wait until <touching (player v)?>\n    if <[collected v] contains (key name)?> then\n        if <(costume [name v]) = [key 1]> then\n            switch costume to (animation? v)\n        end\n        start sound [Door Glass Sliding Open Close Sound Effects v]\n        repeat (24)\n            change y by (5)\n        end\n        wait (0.5) seconds\n        wait (0.5) seconds\n        repeat (22)\n            change y by (-5)\n        end\n        repeat (2)\n            change y by (-5)\n        end\n    else\n        broadcast (Locked v)\n        start sound [Low Squeak v]\n    end\n    wait until <not <touching (player v)?>>\nend\n\nwait (0.01) seconds\nswitch costume to (key 1 v)\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 flag clicked\n\n@Collectable\n\nwhen I receive [change scene v]\nif <(SCENE #) = (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 ((1) * ([sin v] of (frame) ))\n    change [frame v] by (6)\nend\nset [my scene v] to []\nif <(costume [name v]) = [apple]> then\n    start sound [Bite Sound Effect _ Chew Sound Effect _ Human Bite Food \(1\) v]\n    broadcast (collected new apple v)\n    change [apples v] by (1)\n    repeat (20)\n        change y by (2)\n        change [ghost v] effect by (5)\n    end\nelse\n    if <(costume [name v]) = [checkpoint]> then\n        start sound [Coin v]\n        set [spawn scene v] to (SCENE #)\n        set [spawn x v] to ([x position v] of [player v])\n        set [spawn y v] to ([y position v] of [player v])\n    else\n        if <(costume [name v]) = [Heart]> then\n            start sound [Coin v]\n            change [lives v] by (1)\n        else\n            broadcast (costume [name v])\n            start sound [Coin v]\n            add (costume [name v]) to [collected v]\n        end\n    end\nend\nrepeat (20)\n    change y by (2)\n    change [ghost v] effect by (5)\nend\n\nwhen I receive [setup v]\ndelete all of [collected v]\nset [frame v] to [0]\nset [apples v] to [0]\nhide\nPlace [apple] Scene [1] xy [-19] [0]\nPlace [apple] Scene [2] xy [144] [142]\nPlace [apple] Scene [101] xy [-79] [100]\nPlace [apple] Scene [4] xy [0] [0]\nPlace [apple] Scene [6] xy [204] [-50]\nPlace [apple] Scene [103] xy [66] [43]\nPlace [apple] Scene [205] xy [-10] [0]\nPlace [Key 1] Scene [206] xy [68] [64]\nPlace [checkpoint] Scene [3] xy [-200] [70]\nPlace [checkpoint] Scene [103] xy [-190] [10]\nPlace [Heart] Scene [4] xy [-190] [10]\nPlace [Heart] Scene [206] xy [-190] [10]\nPlace [apple] Scene [307] xy [-200] [20]\nPlace [apple] Scene [307] xy [-160] [20]\nPlace [apple] Scene [307] xy [-120] [20]\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@Splash Screen\n\nwhen flag clicked\nset size to (100) %\nhide variable [apples v]\ngo to x: (0) y: (0)\nswitch costume to (main menu v)\ngo to [front v] layer\nshow\n\nwhen I receive [game over v]\ngo to x: (0) y: (0)\nswitch costume to (game over v)\ngo to [front v] layer\nshow\nbroadcast (Main Menu v)\nset size to (0) %\nforever\n    change size by ((0.2) * ((115) - (size)))\nend\n\nwhen I receive [start game v]\nhide\n\n@Main Menu\n\nwhen I receive [main menu v]\ngo to [front v] layer\nshow\ngo to x: (0) y: (-100)\nset size to (0) %\nforever\n    if <touching (mouse-pointer v)?> then\n        change size by ((0.2) * ((125) - (size)))\n    else\n        change size by ((0.2) * ((100) - (size)))\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen this sprite clicked\nhide\nbroadcast (Start Game v)\n\nchange size by ((0.2) * ((125) - (size)))\n\n@Key\n\nwhen flag clicked\nset size to (60) %\ngo to x: (150) y: (150)\nhide\n\nwhen I receive [key 1 v]\nswitch costume to (key1 v)\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nmove (40) steps\nshow\n\nwhen I receive [game over v]\ndelete this clone\n\n@Platform2\n\nwhen I receive [change scene v]\nset x to (0)\nhide\nif <(SCENE #) = [3]> then\n    show\n    go to x: (-39) y: (-74)\n    Animate Platform\nend\nif <(SCENE #) = [6]> then\n    Door at [0] [-74] key [key 1]\nend\nif <(SCENE #) = [103]> then\n    switch costume to (costume2 v)\n    show\n    Animate 2\nend\nif <(SCENE #) = [104]> then\n    switch costume to (costume3 v)\n    show\n    Animate 2\nend\nif <(SCENE #) = [204]> then\n    switch costume to (costume4 v)\n    show\n    Animate 2\nend\nif <(SCENE #) = [205]> then\n    switch costume to (costume5 v)\n    show\n    Animate 2\nend\nif <(SCENE #) = [206]> then\n    switch costume to (costume6 v)\n    show\n    Animate 2\nend\n\ndefine Animate Platform\ngo to x: (-39) y: (-74)\nswitch costume to (costume1 v)\nforever\n    go to x: (-39) y: (-74)\nend\n\nglide (2.5) secs to x: (240) y: (-74)\nwait (1) seconds\nglide (2.5) secs to x: (-39) y: (-74)\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 <(new y) > (Last Y)> then\n    change y by (1)\nelse\n    set y to ((Last Y) + (1))\nend\nif <touching (player v)?> then\n    set [platform dx v] to ((new x) - (Last X))\n    set [platform dy v] to ((new y) - (Last Y))\nend\ngo to x: (new x) y: (new y)\n\ndefine Animate 2\nforever\n    set y to ((-30) + (([cos v] of (((timer) - (3)) * (200)) ) * (8)))\nend\n\nAnimate 2\n\ndefine Door at (x) (y) key (key name)\nshow\nswitch costume to (key name)\nshow\ngo to x: (x) y: (y)\nforever\n    wait until <touching (player v)?>\n    if <[collected v] contains (key name)?> then\n        if <(costume [name v]) = [key 1]> then\n            switch costume to (animation? v)\n        end\n        start sound [Door Glass Sliding Open Close Sound Effects v]\n        repeat (24)\n            change y by (5)\n        end\n        wait (0.5) seconds\n        wait (0.5) seconds\n        repeat (22)\n            change y by (-5)\n        end\n        repeat (2)\n            change y by (-5)\n        end\n        switch costume to (key 1 v)\n    else\n        broadcast (Locked v)\n        start sound [Low Squeak v]\n    end\n    wait until <not <touching (player v)?>>\nend\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 flag clicked\n\n@Hearts\n\nwhen flag clicked\nforever\n    switch costume to (LIVES)\nend\n\n@1 \n\nwhen flag clicked\nsetup\n\nwhen I start as a clone\nset y to (150)\nshow\nforever\n    change costume to (join [1-] (letter (index) of (Apples)))\n    set x to (((((index) - (0.5)) - ((length of (Apples)) / (2))) * ((size) / (2))) / (1.1))\n    change size by ((0.2) * ((100) - (size)))\nend\n\ndefine setup\nhide\nswitch costume to (1-9 v)\nset size to (50) %\nset [index v] to [1]\nrepeat (9)\n    create clone of (_myself_ v)\n    change x by ((size) / (4))\n    change [index v] by (1)\nend\n\ndefine change costume to (costume)\nif <not <(costume) = (costume [name v])>> then\n    switch costume to (costume)\n    set size to (60) %\nend\n\nwhen flag clicked\nset [score v] to [0]\n\nwhen I receive [start game v]\ngo to [front v] layer\n\n@enemy\n\nwhen flag clicked\nset rotation style [left-right v]\nhide\n\nwhen I receive [change scene v]\nif <(SCENE #) = [101]> then\n    spawn [enemy] at [0] [-102] dir [90]\nend\nif <(SCENE #) = [102]> then\n    spawn [enemy] at [0] [-102] dir [-90]\nend\n\nwhen I start as a clone\nshow\nset [frame v] to [0]\nset [speed y v] to [0]\nforever\n    switch costume to (1 v)\n    set rotation style [don't rotate v]\n    move - left or right\n    move down\n    change [frame v] by (0.8)\n    switch costume to ((1) + (([floor v] of (frame) ) mod (12)))\n    set rotation style [left-right v]\n    if <<(INVULNERABLE) = [0]> and <touching (player v)?>> then\n        Touching Player\n    end\nend\n\nwhen I receive [leave scene v]\ndelete this clone\n\ndefine move down\nchange y by (speed y)\nchange [speed y v] by (-1)\nrepeat until <not <touching (level v)?>>\n    change y by (1)\n    set [speed y v] to [0]\nend\n\ndefine move - left or right\nmove (2) steps\nrepeat (4)\n    if <not <<<<touching (level v)?> or <touching (_edge_ v)?>> or <touching (safe zones v)?>> or <touching (platform v)?>>> then\n        stop [this script v]\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 [Pop sound effect v]\n    switch costume to (squash v)\n    wait (0.3) seconds\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    delete this clone\nend\nbroadcast (Lose Life v)\n\ndefine spawn (type) at (x) (y) dir (dir)\ngo to x: (x) y: (y)\npoint in direction (dir)\ncreate clone of (_myself_ v)\n\n@safe zones\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\ngo to [back v] layer\nforever\n    go [backward v] (1) layers\nend\n\nwhen I receive [change scene v]\nswitch costume to (blank v)\nswitch costume to (join [Scene] (SCENE #))\n\nwhen I receive [start game v]\nshow\n\nwhen flag clicked\nforever\n    play sound [Vexento - Smile v] until done\nend\n\n