Simple Platformer

Instructions: Move with the arrow keys. Avoid spikes and lava. Get keys to get through lock doors.\n\nEXTRA: I based myself in Super Mario Odyssey that when you tried to run through a wall you started pushing it. That is the reason why I added a slight change to @griffpatch's tutorial; try to push a 90 degrees wall. B)

@Stage\n\nwhen flag clicked\nforever\n    play sound [Happy Robot v] until done\nend\n\n@Thumbnail\n\nwhen flag clicked\nshow\ngo to [front v] layer\nset [ghost v] effect to (100)\n\nwhen [m v] key pressed\nif <(username) = [SalesianosSant1]> then\n    show\n    go to [front v] layer\n    clear graphic effects\n    hide variable [apples v]\n    hide variable [lives v]\n    hide variable [scene # v]\nend\n\n@Player\n\nwhen flag clicked\ndelete all of [collected v]\nset [spawn scene v] to [1]\nset [spawn x v] to [-150]\nset [spawn y v] to [55]\nbroadcast (Main Menu v)\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) = [hitbox v2]> then\n    switch costume to (hitbox feet v)\nend\nif <<touching (jump through v)?> and <not <key (down arrow v) pressed?>>> then\n    if <(jump through) < [1]> then\n        change y by (-6)\n        if <(hit costume) = [hitbox v2]> then\n            switch costume to (hitbox feet 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 Platform\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 (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 (right arrow v) pressed?> - <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\nset drag mode [not draggable v]\nhide variable [scene # v]\nset [invunerable 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 (About to Change Scene v)\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]\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 (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 <<([abs v] of (speed x) ) < [0.1]> and <([abs v] of (KEY X) ) > [0]>> then\n    switch costume to (push v)\nelse\n    if <(frame) > [0]> then\n        switch costume to ((1) + ([floor v] of ((frame) mod (16)) ))\n    else\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)\n    end\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))\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))\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 I receive [lose life v]\nif <not <(LIVES) = [999]>> then\n    set [invunerable v] to [1]\n    stop [other scripts in sprite v]\n    start sound [Oops v]\n    repeat (10)\n        change [ghost v] effect by (10)\n    end\n    wait (0.5) seconds\n    change [lives v] by (-1)\n    if <(LIVES) > [0]> then\n        Reset and Begin Level\n    else\n        broadcast (Game Over v)\n    end\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    repeat (16)\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    end\n    change [distance v] by (1)\nend\ngo to x: (x) y: (y)\nmove (distance) steps\npoint in direction (temp)\n\nwhen I receive [start game v]\nset [gravity v] to [-1.5]\nset [jump force v] to [12]\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]\nReset and Begin Level\n\nwhen I receive [player - bounce v]\nset [speed y v] to [10]\nset [falling v] to [0]\n\nwhen [r v] key pressed\nif <(username) = [SalesianosSant1]> then\n    if <(LIVES) > [998]> then\n        set [lives v] to [900]\n    else\n        show variable [scene # v]\n        set [lives v] to [999]\n        add [Key 1] to [collected v]\n        add [Key 2] to [collected v]\n        set drag mode [draggable v]\n    end\nend\n\nwhen [space v] key pressed\nif <(username) = [SalesianosSant1]> then\n    if <(LIVES) > [998]> then\n        set [spawn scene v] to (SCENE #)\n        set [spawn x v] to (x position)\n        set [spawn y v] to (y position)\n    end\nend\n\n@Level\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 #))\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 [about to change scene v]\nerase all\n\n@Danger\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 (blank v)\nswitch costume to (join [Scene] (SCENE #))\nif <[lava scenes v] contains (SCENE #)?> then\n    forever\n        set y to ((3) * ([sin v] of ((timer) * (180)) ))\n    end\nend\n\n@Platform\n\nwhen I receive [change scene v]\ngo to [back v] layer\nFind Animation [n]\nif <(SCENE #) = [106]> then\n    create clone of (_myself_ v)\nend\n\ndefine Animate Platform\nset [follow platform? v] to [y]\nforever\n    glide (5) secs to x: (18) y: (-130)\n    wait (1) seconds\n    glide (5) secs to x: (-14) y: (100)\n    wait (1) 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    set [platform changing x v] to (((new x) - (last x)) + (join (letter (2) of (follow platform?)) (letter (3) of (follow platform?))))\n    set [platform changing y v] to ((new y) - (last y))\n    if <touching (player v)?> then\n        if <(letter (1) of (follow platform?)) = [y]> then\n            set [platform dx v] to (PLATFORM CHANGING X)\n        end\n        set [platform dy v] to (PLATFORM CHANGING Y)\n    end\nend\ngo to x: (new x) y: (new y)\n\ndefine Animate 2\nset [follow platform? v] to [y]\nwait (3) seconds\nforever\n    repeat (4)\n        glide (pick random (0.5) to (3.0)) secs to x: (pick random (23) to (93)) y: (pick random (-84) to (84))\n        wait (1) seconds\n    end\n    glide (pick random (0.5) to (3.0)) secs to x: (23) y: (-84)\n    wait (1) seconds\nend\n\ndefine Find Animation (clone?)\nshow\nif <(SCENE #) = [4]> then\n    Spawn [Platform 5] at [0] [0] dir [90] turn []\nend\nif <(SCENE #) = [5]> then\n    Spawn [Platform 1] at [-26] [86] dir [90] turn []\nend\nif <(SCENE #) = [6]> then\n    Spawn [Platform 2] at [0] [0] dir [90] turn []\nend\nif <(SCENE #) = [104]> then\n    Spawn [Key 1] at [0] [10] dir [90] turn []\nend\nif <(SCENE #) = [105]> then\n    Spawn [Platform 3] at [-14] [100] dir [90] turn []\nend\nif <(SCENE #) = [106]> then\n    Spawn [Key 2] at [0] [0] dir [90] turn []\n    Spawn [Platform 4] at [23] [-84] dir [90] turn []\nend\nif <(SCENE #) = [10]> then\n    if <([x position v] of [player v]) < [0]> then\n        Spawn [Platform 6] at [-20] [0] dir [90] turn [-1]\n        Spawn [Platform 7] at [-20] [191] dir [135] turn [-1.5]\n        Spawn [Platform 8] at [-109] [-74] dir [180] turn [-1.3]\n        Spawn [Platform 8] at [76] [-76] dir [225] turn [-2]\n        Spawn [Platform 7] at [149] [162] dir [0] turn [-1.7]\n    else\n        Spawn [Platform 6] at [-20] [0] dir [90] turn [1]\n        Spawn [Platform 7] at [-20] [191] dir [135] turn [1.5]\n        Spawn [Platform 8] at [-109] [-74] dir [180] turn [1.3]\n        Spawn [Platform 8] at [76] [-76] dir [225] turn [2]\n        Spawn [Platform 7] at [149] [162] dir [0] turn [1.7]\n    end\nend\nif <(SCENE #) = [11]> then\n    if <([x position v] of [player v]) < [0]> then\n        Spawn [Platform 9] at [0] [-150] dir [0] turn [-2]\n    else\n        Spawn [Platform 9] at [0] [-150] dir [0] turn [2]\n    end\nend\nhide\n\ndefine Animate 3\nset [follow platform? v] to [n]\nforever\n    glide (3) secs to x: (-26) y: (20)\n    glide (2) secs to x: (-120) y: (20)\n    glide (1) secs to x: (-120) y: (-50)\n    glide (3) secs to x: (81) y: (-49)\n    wait (2) seconds\n    glide (2) secs to x: (-26) y: (86)\nend\n\ndefine Animate 4\nforever\n    if <([x position v] of [player v]) < [0]> then\n        set [follow platform? v] to [y-3]\n    else\n        set [follow platform? v] to [y03]\n    end\nend\n\ndefine Door at (x) (y) key (key name)\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    else\n        start sound [Low Squeak v]\n    end\n    wait until <not <touching (player v)?>>\nend\n\nwhen I receive [change scene v]\ndelete this clone\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) dir (dir) turn (degrees)\nset [turn v] to (degrees)\ngo to x: (x) y: (y)\npoint in direction (dir)\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])\nend\nif <(turn) > []> then\n    show\n    set rotation style [all around v]\n    forever\n        turn right (turn) degrees\n    end\nend\nif <(SCENE #) = [4]> then\n    wait (1.5) seconds\n    forever\n        glide (2) secs to x: (-100) y: (-300)\n        wait (1.5) seconds\n        glide (2) secs to x: (0) y: (0)\n        wait (1.5) seconds\n    end\nend\nif <(SCENE #) = [5]> then\n    Animate 3\nend\nif <(SCENE #) = [6]> then\n    Animate 4\nend\nif <(SCENE #) = [105]> then\n    Animate Platform\nend\nif <(SCENE #) = [106]> then\n    Animate 2\nend\nif <(SCENE #) = [208]> then\n    Animate 2\nend\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\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\ngo to [back v] layer\nrepeat until <touching (player v)?>\n    change y by ((0.5) * ([sin v] of (frame) ))\n    if < (costume [name v]) contains [Key]?> then\n        turn right ([sin v] of (frame) ) degrees\n    end\n    if <(SCENE #) = (my scene)> then\n        if <(follow platform?) = [y]> then\n            change x by (PLATFORM CHANGING X)\n            change y by (PLATFORM CHANGING Y)\n        end\n    end\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 [apples v] by (1)\n    if <(APPLES) = [30]> then\n        start sound [Wand v]\n        change [lives v] by (1)\n        set [apples v] to [0]\n    end\nelse\n    if < (costume [name v]) contains [Green Flag]?> then\n        start sound [Wand 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        if <(LIVES) < [3]> then\n            set [lives v] to [3]\n        end\n    else\n        if <(costume [name v]) = [Heart]> then\n            start sound [Whiz v]\n            change [lives v] by (1)\n        else\n            if <(costume [name v]) = [End]> then\n                start sound [Wand v]\n                broadcast (Win v)\n            else\n                start sound [Wand v]\n                add (costume [name v]) to [collected v]\n            end\n        end\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]\nset [frame v] to [0]\nset [apples v] to [0]\nhide\nPlace [apple] scene [1] xy [124] [9] follow [n]\nPlace [apple] scene [1] xy [82] [-27] follow [n]\nPlace [apple] scene [2] xy [93] [133] follow [n]\nPlace [apple] scene [3] xy [-173] [95] follow [n]\nPlace [apple] scene [101] xy [60] [-114] follow [n]\nPlace [apple] scene [103] xy [96] [-123] follow [n]\nPlace [apple] scene [104] xy [34] [96] follow [n]\nPlace [Green Flag] scene [104] xy [126] [67] follow [n]\nPlace [Green Flag] scene [8] xy [0] [-30] follow [n]\nPlace [Heart] scene [106] xy [-79] [128] follow [n]\nPlace [apple] scene [6] xy [90] [-10] follow [n]\nPlace [apple] scene [6] xy [-90] [-10] follow [n]\nPlace [apple] scene [11] xy [0] [130] follow [n]\nPlace [Heart] scene [6] xy [0] [0] follow [n]\nPlace [End] scene [208] xy [-175] [-15] follow [n]\nif <not <[collected v] contains [Key 1]?>> then\n    Place [Key 1] scene [101] xy [-141] [-30] follow [n]\nend\nif <not <[collected v] contains [Key 2]?>> then\n    Place [Key 2] scene [12] xy [0] [-30] follow [n]\nend\n\ndefine Place (costume name) scene (scene) xy (x) (y) follow (follow)\nset [my scene v] to (scene)\nswitch costume to (costume name)\ngo to x: (x) y: (y)\nset [follow platform? v] to (follow)\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\ngo to x: (0) y: (0)\nswitch costume to (main menu v)\ngo to [front v] layer\nshow\nhide variable [apples v]\nhide variable [lives v]\n\nwhen I receive [game over v]\ngo to x: (0) y: (0)\ngo to [front v] layer\nswitch costume to (game over v)\ngo to [front v] layer\nshow\nbroadcast (Main Menu v)\n\nwhen I receive [start game v]\nshow variable [apples v]\nshow variable [lives v]\nhide\n\nwhen I receive [win v]\ngo to [front v] layer\nswitch costume to (win v)\nset [ghost v] effect to (100)\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nstop [all v]\n\n@Main Menu\n\nwhen I receive [main menu v]\nwait (0.1) seconds\ngo to [front v] layer\nshow\nset size to (10) %\ngo to x: (0) y: (-120)\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\nhide\n\nwhen this sprite clicked\nhide\nbroadcast (Start Game v)\n\n@Enemy\n\nwhen flag clicked\nset rotation style [left-right v]\nhide\n\nwhen I receive [change scene v]\nif <(SCENE #) = [1]> then\n    if <([x position v] of [player v]) < [0]> then\n        Spawn [1] at [178] [38] dir [-90]\n    else\n        Spawn [1] at [-11] [-25] dir [90]\n    end\nend\nif <(SCENE #) = [3]> then\n    Spawn [13] at [124] [61] dir [-90]\nend\nif <(SCENE #) = [101]> then\n    Spawn [7] at [26] [11] dir [-90]\nend\nif <(SCENE #) = [7]> then\n    Spawn [7] at [127] [-55] dir [-90]\n    Spawn [7] at [-85] [-55] dir [90]\n    Spawn [7] at [0] [-55] dir [90]\nend\nif <(SCENE #) = [9]> then\n    Spawn [19] at [115] [35] dir [90]\n    Spawn [19] at [-115] [35] dir [-90]\n    if <([x position v] of [player v]) < [0]> then\n        Spawn [19] at [0] [89] dir [-90]\n    else\n        Spawn [19] at [0] [89] dir [90]\n    end\nend\nif <(SCENE #) = [107]> then\n    Spawn [20] at [-70] [35] dir [-90]\nend\nif <(SCENE #) = [108]> then\n    Spawn [20] at [-28] [-46] dir [-90]\n    Spawn [20] at [28] [16] dir [-90]\n    Spawn [20] at [68] [86] dir [-90]\nend\n\nwhen I start as a clone\nshow\nset [speed y v] to [0]\nset [frame v] to [0]\nif <(type) = [20]> then\n    switch costume to (round stand v)\n    Move - Down\n    set rotation style [left-right v]\n    repeat until <<([abs v] of ((y position) - ([y position v] of [player v])) ) < [15]> and <<<((0) - ((x position) - ([x position v] of [player v]))) > [0]> and <(direction) > [0]>> or <<((0) - ((x position) - ([x position v] of [player v]))) < [0]> and <(direction) < [0]>>>>\n        turn right (3) degrees\n        Move - Down\n        if <<(INVUNERABLE) = [0]> and <touching (player v)?>> then\n            Touching Player\n        end\n    end\n    switch costume to (round stand ashtonished v)\n    wait (0.5) seconds\n    change y by (5)\n    point towards (player v)\nend\nforever\n    if <(type) = [20]> then\n        switch costume to (red 1 v)\n        set rotation style [don't rotate v]\n        Move - Left or Right\n        Move - Down\n        switch costume to (round v)\n        set rotation style [all around v]\n        turn right (3) degrees\n    else\n        if <<(type) = [1]> or <(type) = [19]>> then\n            switch costume to (red 1 v)\n        else\n            switch costume to (red flying sleep v)\n        end\n        set rotation style [don't rotate v]\n        Move - Left or Right\n        Move - Down\n        change [frame v] by (0.33)\n        Set Costume\n        set rotation style [left-right v]\n    end\n    if <<(INVUNERABLE) = [0]> and <touching (player v)?>> then\n        if <(type) = [19]> then\n            set [type v] to [1]\n        else\n            Touching Player\n        end\n    end\n    if <touching (danger v)?> then\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n        delete this clone\n    end\nend\n\nwhen I receive [about to change scene v]\ndelete this clone\n\ndefine Move - Down\nif <(type) = [13]> then\n    set [speed y v] to [0]\nelse\n    if <(type) = [19]> then\n        change y by (-2)\n        repeat until <not <<<touching (level v)?> or <touching (safe zones v)?>> or <touching (jump through v)?>>>\n            change y by (1)\n            set [speed y v] to [0]\n            set [type v] to [1]\n        end\n    else\n        change [speed y v] by (-1)\n        change y by (speed y)\n        repeat until <not <<<touching (level v)?> or <touching (safe zones v)?>> or <touching (jump through v)?>>>\n            change y by (1)\n            set [speed y v] to [0]\n        end\n    end\nend\n\ndefine Move - Left or Right\nif <(type) = [20]> then\n    move (3) steps\n    repeat (4)\n        if <not <<touching (level v)?> or <touching (_edge_ v)?>>> then\n            if <not <<touching (safe zones v)?> or <touching (platform v)?>>> then\n                if <not <touching (jump through v)?>> then\n                    stop [this script v]\n                end\n            end\n        end\n        change y by (1)\n    end\n    change y by (-4)\n    move (-2) steps\n    turn right (180) degrees\n    set [frame v] to [0]\nelse\n    if <not <(type) = [19]>> then\n        if <(type) = [13]> then\n            point towards (player v)\n            move (1) steps\n            if <not <<touching (level v)?> or <touching (_edge_ v)?>>> then\n                if <not <<touching (safe zones v)?> or <touching (platform v)?>>> then\n                    stop [this script v]\n                end\n            end\n            move (-1) steps\n            set [frame v] to [0]\n            stop [this script v]\n        end\n        move (2) steps\n        repeat (4)\n            if <not <<touching (level v)?> or <touching (_edge_ v)?>>> then\n                if <not <<touching (safe zones v)?> or <touching (platform v)?>>> then\n                    stop [this script v]\n                end\n            end\n            change y by (1)\n        end\n        change y by (-4)\n        move (-2) steps\n        turn right (180) degrees\n        set [frame v] to [0]\n    end\nend\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    if <(type) = [20]> then\n        point in direction (90)\n        change y by (6)\n        switch costume to (round squish v)\n    else\n        switch costume to ((type) + (4))\n    end\n    wait (0.3) seconds\n    go to [back v] layer\n    repeat (10)\n        change [ghost v] effect by (10)\n        change y by (-1)\n    end\n    delete this clone\nend\nbroadcast (Lose Life v)\n\ndefine Spawn (type) at (x) (y) dir (dir)\nset [type v] to (type)\nswitch costume to (type)\ngo to x: (x) y: (y)\npoint in direction (dir)\ncreate clone of (_myself_ v)\n\ndefine Set Costume\nif <(type) = [20]> then\n    switch costume to (red squish v)\nelse\n    if <(type) = [19]> then\n        switch costume to (red parachute v)\n    else\n        if <(frame) < [1]> then\n            switch costume to ((type) + (5))\n            stop [this script v]\n        end\n        switch costume to ((type) + (([floor v] of (frame) ) mod (4)))\n    end\nend\n\nswitch costume to (red 1 v)\nset rotation style [don't rotate v]\nMove - Left or Right\nMove - Down\nswitch costume to (round v)\nset rotation style [all around v]\nturn right (3) degrees\n\n@Safe Zones\n\nwhen flag clicked\ngo to x: (0) y: (0)\ngo to [back v] layer\nset [ghost v] effect to (100)\n\nwhen I receive [change scene v]\nswitch costume to (blank v)\nswitch costume to (join [Scene] (SCENE #))\n\nclear graphic effects\n\n@Jump Through\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 (blank v)\nswitch costume to (join [Scene] (SCENE #))\nStamp Shadow\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\n