Scratch - Platformer

Instructions: Arrow keys to play\nr to reset\nFav and like\nGoal is 100 likes and favourites\nDon't touch the lava/Red Block

@Stage\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 - Celling or Floor\n    end\nend\n\ndefine Check Touching Solid\nif <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]\nswitch backdrop to <touching (level v)?>\nControls - Up/Down\nControl - Left/Right\nMove - in steps (([abs v] of (Speed x) ) + ([abs v] of (Speed y) ))\nSet Costume\n\ndefine Controls - Up/Down\nif  then\n    if <(Falling) < [3]> then\n        set [speed y v] to (JUMP FORCE)\n    end\nend\nchange [speed y v] by (GRAVITY)\n\ndefine Control - Left/Right\nset [key x v] to ( - )\nif <(KEY X) = [0]> then\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    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]\ngo to x: (-212) y: (138)\nbroadcast (Game Loop v)\nforever\n    if <touching (sprite1 v)?> then\n        broadcast (Change Scene v)\n        go to x: (-212) y: (-120)\n        change [levels v] by (1)\n    end\n    if <touching (sprite2 v)?> then\n        go to x: (-212) y: (-120)\n    end\n    if <key (r v) pressed?> then\n        go to x: (-212) y: (-120)\n    end\n    if <touching color (#ff0000)?> then\n        go to x: (-212) y: (-120)\n    end\n    if <touching (danger v)?> then\n        go to x: (-212) y: (-120)\n    end\nend\n\nwhen I receive [game loop v]\nforever\n    broadcast (Tick - First 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 [-235]\nend\nif <(x position) < [-235]> then\n    Begin Scene # ((SCENE #) + (-1)) Go to X [235]\nend\n\ndefine Begin Scene # (scene #) Go to X (x)\nset [scene # v] to (scene #)\nset x to (x)\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]\nFix Collision in Direction [0]\nSet Costume\nbroadcast (Game Loop v)\n\ndefine Fix Collision in Direction (direction)\nset [temp v] to (direction)\nset [distance v] to [0]\npoint in direction (direction)\nrepeat (2048)\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]\n\ndefine Set Costume\nset rotation style [left-right v]\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\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 - Celling 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\nwhen flag clicked\nset [levels v] to [1]\npoint in direction (90)\nset [gravity v] to [-1.5]\nset [jump force v] to [12]\nset [acceleration v] to [1.5]\nset [resistance v] to [0.8]\nReset and Begin Level\n\nwhen I receive [skip v]\ngo to x: (-212) y: (-120)\n\n@Level\n\nwhen I receive [change scene v]\nnext costume\n\nwhen flag clicked\nswitch costume to (costume1 v)\n\nswitch costume to (join [Scene] (SCENE #))\n\nwhen flag clicked\n\nplay sound [level1 v] until done\n\nwhen I receive [start v]\n\nwhen flag clicked\nset volume to (40) %\nforever\n    play sound [Marshmello - Alone2 v] until done\n    play sound [level2 v] until done\nend\n\nwhen I receive [skip v]\nnext costume\n\n@Sprite1\n\nwhen flag clicked\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\n\n@Sprite2\n\nwhen flag clicked\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\nset [ghost v] effect to (100)\n\n@Danger\n\nwhen flag clicked\nforever\n    if <(Levels) = [1]> then\n        switch costume to (costume1 v)\n    end\n    if <(Levels) = [2]> then\n        switch costume to (costume2 v)\n    end\n    if <(Levels) = [3]> then\n        switch costume to (costume3 v)\n    end\n    if <(Levels) = [4]> then\n        switch costume to (costume4 v)\n    end\n    if <(Levels) = [5]> then\n        switch costume to (costume5 v)\n    end\n    if <(Levels) = [6]> then\n        switch costume to (costume6 v)\n    end\n    if <(Levels) = [7]> then\n        switch costume to (costume7 v)\n    end\n    if <(Levels) = [8]> then\n        switch costume to (costume8 v)\n    end\n    if <(Levels) = [9]> then\n        switch costume to (costume9 v)\n    end\n    if <(Levels) = [10]> then\n        switch costume to (costume10 v)\n    end\n    if <(Levels) = [11]> then\n        switch costume to (costume11 v)\n    end\n    if <(Levels) = [12]> then\n        switch costume to (costume12 v)\n    end\n    if <(Levels) = [13]> then\n        switch costume to (costume12 v)\n    end\nend\n\n@rain\n\nwhen flag clicked\nhide\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nswitch costume to (klädsel1 v)\ngo to [back v] layer\nshow\nset y to (9999)\nset x to (pick random (-180) to (180))\nrepeat until <<touching color (#9966ff)?> or <touching color (#04ff00)?>>\n    change y by (-15)\nend\nswitch costume to (klädsel2 v)\nrepeat until <not <<touching color (#9966ff)?> or <touching color (#04ff00)?>>>\n    change y by (9)\nend\nwait (0.1) seconds\ndelete this clone\n\nwhen I start as a clone\nwait (8) seconds\ndelete this clone\n\n@Sprite3\n\nwhen flag clicked\nforever\n    if <touching (mouse-pointer v)?> then\n        if <mouse down?> then\n            broadcast (Skip v)\n            change [levels v] by (1)\n            wait (1) seconds\n        end\n    end\nend\n\n@Sprite4\n\nwhen flag clicked\ngo to [back v] layer\n\n@Sprite5\n\nwhen flag clicked\nhide\n\nwhen [timer v] > (0.05)\nswitch costume to (costume1 v)\ngo to x: (36) y: (28)\nshow\nrepeat (23)\n    change y by (((0) - (y position)) / (4))\nend\n\nwhen flag clicked\nif <(y position) = [0]> then\n    glide (0.3) secs to x: (0) y: (345)\nend\ngo to x: (0) y: (345)\nhide\n\nwhen flag clicked\nset [level v] to [1]\ngo to [front v] layer\ngo to [front v] layer\ngo to x: (36) y: (0)\nclear graphic effects\nswitch costume to (costume1 v)\n\nwhen flag clicked\nreset timer\nforever\n    go to [front v] layer\n    go [forward v] (12) layers\n    reset timer\nend\n\n