ScratchCat Platformer

Instructions: Hey guys, \na new amazing game is out!!\nPlay with the arrow keys.Avoid Lava and Spikes, collect all things you can find like apples, bananas and strawberrys!! Can you get keys to open all doors and to come out of the cave??\nAll levels are possible!!\nHave fun

@Stage\n\nwhen flag clicked\nswitch backdrop to (false v)\n\nwhen I receive [change scene v]\nif <(Scene#) = [205]> then\n    switch backdrop to (bühnenbild1 v)\nelse\n    switch backdrop to (false v)\nend\n\n@Player\n\nwhen flag clicked\nset size to (65) %\nhide\n\ndefine Move - in steps (steps)\nchange [falling v] by (1)\nrepeat (steps)\n    set [last value v] to (x position)\n    change x by ((Speed X) / (steps))\n    Check Touching Solid\n    if <(touching) > [0]> then\n        Collide X - Slope or Wall\n    end\n    set [last value v] to (y position)\n    change y by ((Speed Y) / (steps))\n    Check Touching Solid\n    if <(touching) > [0]> then\n        Collide Y - Ceilling or Floor\n    end\nend\n\ndefine Check Touching Solid\nif <<touching (level v)?> or <touching (platform 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\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 - 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.4)\n    end\nelse\n    change [speed x v] by ((Key X) * (ACCELERATION))\n    point in direction ((Key X) * (90))\n    change [frame v] by (1)\nend\nset [speed x v] to ((Speed X) * (RESISTANCE))\n\ndefine Reset and Begin Level\nset [scene# v] to [1]\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling v] to [99]\nset [ghost v] effect to (0)\ngo to [front v] layer\nBegin Scene # (Spawn Scene) go to x and y: (Spawn X) (Spawn Y)\n\nwhen I receive [game loop v]\nshow\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 and y: [-235] []\nend\nif <(x position) < [-235]> then\n    Begin Scene # ((Scene#) + (-1)) go to x and y: [235] []\nend\nif <(y position) > [180]> then\n    Begin Scene # ((Scene#) + (100)) go to x and y: [] [-180]\nend\nif <(y position) < [-180]> then\n    Begin Scene # ((Scene#) + (-100)) go to x and y: [] [180]\nend\nif <touching (lava v)?> then\n    broadcast (Lose Life durch Lava v)\nend\nif <touching (spikes v)?> then\n    broadcast (Lose Life v)\nend\n\ndefine Begin Scene # (scene #) go to x and 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)\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 (64)\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 <(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 Wllslide\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 (-1)\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 - Ceilling or Floor\nset y to (last value)\nif <(Speed Y) > [0]> then\n    set [speed y v] to [0]\n    stop [this script v]\nend\nif <(falling) > [0]> then\n    set [falling v] to [0]\n    Slip\nend\nset [speed y v] to ((Speed Y) * (0.8))\n\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 Wllslide\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\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 Wllslide\n    if <(Speed Y) < [0]> then\n        set [speed y v] to ((Speed Y) * (0.6))\n    end\nend\n\nwhen I receive [lose life v]\nstop [other scripts in sprite v]\nstart sound [Pluck v]\nrepeat (20)\n    change [ghost v] effect by (5)\nend\nwait (0.5) seconds\nReset and Begin Level\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 durch Platform 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)\npoint in direction (temp)\n\nwhen I receive [change scene v]\ngo to [front v] layer\n\nwhen I receive [lose life durch lava v]\nstop [other scripts in sprite v]\nstart sound [Glug v]\nrepeat (20)\n    change [ghost v] effect by (5)\nend\nwait (0.5) seconds\nReset and Begin Level\n\nwhen I receive [lose life durch platform v]\nstop [other scripts in sprite v]\nstart sound [Pew v]\nrepeat (20)\n    change [ghost v] effect by (5)\nend\nwait (0.5) seconds\nReset and Begin Level\n\nwhen I receive [start game v]\ngo to x: (-140) y: (50)\nset [jump duration v] to [5]\nset [resistance v] to [0.87]\nset [acceleration v] to [1.5]\nset [jump force v] to [15]\nset [gravity v] to [-1.5]\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\n@Level\n\nwhen I receive [change scene v]\nswitch costume to (join [Scene] (Scene#))\ngo to [back v] layer\ngo [forward v] (1) layers\ngo to x: (0) y: (0)\nerase all\nStamp Outline\nStamp Shadow\n\ndefine Stamp Outline\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\ndefine Stamp Shadow\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\nwhen flag clicked\nhide\n\nwhen I receive [start game v]\nwait (0.1) seconds\nshow\n\n@Spikes\n\nwhen I receive [change scene v]\nswitch costume to (join [Scene] (Scene#))\ngo to [back v] layer\n\nwhen flag clicked\nhide\n\nwhen I receive [start game v]\nshow\n\n@Lava\n\nwhen I receive [change scene v]\ngo to [back v] layer\nswitch costume to (join [Scene] (Scene#))\ngo to [back v] layer\nforever\n    go to x: (0) y: (0)\n    set y to ((5) * ([sin v] of ((timer) * (180)) ))\nend\n\nwhen flag clicked\ngo to [back v] layer\nhide\n\nwhen I receive [start game v]\nwait (0.1) seconds\nshow\n\nwhen I receive [win v]\nhide\nstop [other scripts in sprite v]\nstop [this script v]\n\n@Platform\n\nwhen I receive [change scene v]\nhide\ngo to [back v] layer\nif <(Scene#) = [104]> then\n    show\n    Animate Platform\nend\nif <(Scene#) = [101]> then\n    show\n    Animate 2\nend\nif <(Scene#) = [203]> then\n    show\n    Animate3\nend\nif <(Scene#) = [4]> then\n    Door at [126] [-76] Key [Key2]\nend\nif <(Scene#) = [204]> then\n    Door at [111] [-20] Key [Key1]\nend\nif <(Scene#) = [402]> then\n    point in direction (90)\n    Door at [-58] [-64] Key [Key3]\nend\nif <(Scene#) = [304]> then\n    show\n    Animate4\nend\nif <(Scene#) = [401]> then\n    show\n    Animate5\nend\n\ndefine Animate Platform\nswitch costume to (kostüm1 v)\npoint in direction (90)\ngo to x: (-50) y: (-117)\nforever\n    wait (0.5) seconds\n    glide (1) secs to x: (58) y: (-112)\n    wait (0.5) seconds\n    glide (1) secs to x: (69) y: (74)\n    wait (0.5) seconds\n    glide (1.5) secs to x: (-50) y: (-117)\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 <(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    change [platform dx v] by ((new x) - (last x))\n    change [platform dy v] by ((new y) - (last y))\nend\ngo to x: (new x) y: (new y)\n\ndefine Animate 2\nswitch costume to (kostüm1 v)\ngo to x: (162) y: (-49)\npoint in direction (0)\nforever\n    wait (0.5) seconds\n    glide (1) secs to x: (162) y: (40)\n    wait (0.5) seconds\n    glide (1) secs to x: (162) y: (-49)\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 <(Scene#) = [4]> then\n        point in direction (90)\n        if <[collected v] contains [Key2]?> then\n            start sound [Buzz Whir v]\n            repeat (31)\n                change y by (4)\n            end\n            wait (1) seconds\n            start sound [Buzz Whir v]\n            repeat (31)\n                change y by (-4)\n            end\n            start sound [Crunch v]\n        else\n            start sound [Low Squeak v]\n        end\n    end\n    if <(Scene#) = [204]> then\n        point in direction (90)\n        if <[collected v] contains [Key1]?> then\n            start sound [Buzz Whir v]\n            repeat (26)\n                change x by (-4)\n            end\n            wait (1) seconds\n            start sound [Buzz Whir v]\n            repeat (26)\n                change x by (4)\n            end\n            start sound [Crunch v]\n        else\n            start sound [Low Squeak v]\n        end\n    end\n    if <(Scene#) = [402]> then\n        point in direction (90)\n        if <[collected v] contains [Key3]?> then\n            start sound [Buzz Whir v]\n            repeat (26)\n                change y by (4)\n            end\n            wait (1) seconds\n            start sound [Buzz Whir v]\n            repeat (26)\n                change y by (-4)\n            end\n            start sound [Crunch v]\n        else\n            start sound [Low Squeak v]\n        end\n    end\n    wait until <not <touching (player v)?>>\nend\n\nwhen flag clicked\nhide\ngo to [back v] layer\n\ndefine Animate3\nswitch costume to (kostüm2 v)\npoint in direction (90)\ngo to x: (-98) y: (-32)\nforever\n    wait (0.5) seconds\n    glide (1) secs to x: (-98) y: (-120)\n    wait (0.5) seconds\n    glide (1) secs to x: (-98) y: (36)\nend\n\ndefine Animate4\nswitch costume to (kostüm2 v)\npoint in direction (90)\ngo to x: (-118) y: (-45)\nforever\n    wait (0.5) seconds\n    glide (1) secs to x: (-118) y: (-118)\n    wait (0.5) seconds\n    glide (2) secs to x: (-118) y: (47)\nend\n\ndefine Animate5\nswitch costume to (kostüm1 v)\ngo to x: (111) y: (-27)\npoint in direction (0)\nforever\n    wait (0.5) seconds\n    glide (1) secs to x: (112) y: (-59)\n    wait (0.5) seconds\n    glide (1) secs to x: (109) y: (65)\nend\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 ((0.7) * ([sin v] of (frameV2) ))\n    change [framev2 v] by (5)\nend\nset [my scene v] to []\nif <<(costume [name v]) = [Key1]> or <<(costume [name v]) = [Key2]> or <(costume [name v]) = [Key3]>>> then\n    start sound [Wand v]\n    add (costume [name v]) to [collected v]\nelse\n    if <(costume [name v]) = [Green Flag]> then\n        start sound [Connect v]\n        wait (0.1) seconds\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        start sound [Coin v]\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 [ghost v] effect to (0)\nset [framev2 v] to [0]\nhide\nPlace [apple] scene [1] xy [73] [-13]\nPlace [apple] scene [2] xy [62] [98]\nPlace [apple] scene [401] xy [-28] [103]\nPlace [apple] scene [5] xy [102] [-100]\nPlace [apple] scene [302] xy [0] [20]\nPlace [Bananas] scene [1] xy [191] [-16]\nPlace [Bananas] scene [2] xy [-39] [90]\nPlace [Bananas] scene [203] xy [-79] [52]\nPlace [Bananas] scene [105] xy [-158] [-10]\nPlace [Taco] scene [301] xy [53] [84]\nPlace [Strawberry-b] scene [102] xy [-115] [-106]\nPlace [Strawberry-b] scene [303] xy [-5] [40]\nPlace [Key1] scene [104] xy [150] [62]\nPlace [Key2] scene [402] xy [66] [26]\nPlace [Key3] scene [202] xy [85] [-24]\nPlace [Green Flag] scene [102] xy [-150] [37]\nPlace [Green Flag] scene [4] xy [-70] [67]\nPlace [Green Flag] scene [204] xy [102] [-97]\nPlace [Green Flag] scene [301] xy [-42] [-88]\n\ndefine Place (costume) scene (scene) xy (x) (y)\nset [my scene v] to (scene)\ngo to [back v] layer\nswitch costume to (costume)\ngo to x: (x) y: (y)\ncreate clone of (_myself_ v)\nset [my scene v] to []\n\n@Game Button\n\nwhen flag clicked\nwait (0.1) seconds\ngo to [front v] layer\nshow\ngo to x: (-2) y: (-106)\nset size to (10) %\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\n    if <<mouse down?> and <touching (mouse-pointer v)?>> then\n        hide\n        broadcast (Start Game v)\n        stop [this script v]\n    end\nend\n\n@Titel Screen\n\nwhen flag clicked\nshow\ngo to [front v] layer\n\nwhen I receive [start game v]\nhide\n\n