CAVE | A mobile friendly platformer
@Stage\n\nwhen flag clicked\nforever\n    switch backdrop to (level)\nend\n\n@player\n\nwhen flag clicked\nhide\nswitch costume to (normal v)\nset size to (100) %\nclear graphic effects\n\ndefine reset\ngo to x: (-200) y: (35)\nset [xv v] to [0]\nset [yv v] to [0]\nset [jumping? v] to [0]\nset [killedenemy? v] to [0]\nswitch costume to (normal v)\nbroadcast (reset v)\n\nwhen I receive [newlevel v]\nreset\n\nwhen [r v] key pressed\nreset\n\ndefine platform\nchange y by (1)\nif <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<mouse down?> and <(mouse y) > [0]>>> then\n    change y by (1)\n    if <touching (water v)?> then\n        set [jumping? v] to [1]\n        set [yv v] to [2]\n        change y by (yv)\n        if <touching (level v)?> then\n            set [yv v] to [0]\n            repeat until <not <touching (level v)?>>\n                change y by (-0.3)\n            end\n        end\n    else\n        change y by (-2)\n        if <<<touching (level v)?> or <touching (water v)?>> and <(jumping?) = [0]>> then\n            set [yv v] to [11]\n            set [jumping? v] to [1]\n            if <touching (water v)?> then\n                change y by (2)\n            end\n        end\n        change y by (1)\n    end\nend\nif <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<mouse down?> and <(mouse x) < [0]>>> then\n    change [xv v] by (-1)\n    if <touching (water v)?> then\n        set [xv v] to [-1.5]\n        change x by (xv)\n        if <touching (level v)?> then\n            set [xv v] to [0]\n            repeat until <not <touching (level v)?>>\n                change x by (0.1)\n            end\n        end\n    end\n    switch costume to (left v)\nend\nif <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<mouse down?> and <(mouse x) > [0]>>> then\n    change [xv v] by (1)\n    if <touching (water v)?> then\n        set [xv v] to [1.5]\n        change x by (xv)\n        if <touching (level v)?> then\n            set [xv v] to [0]\n            repeat until <not <touching (level v)?>>\n                change x by (-0.1)\n            end\n        end\n    end\n    switch costume to (right v)\nend\nif <touching (water v)?> then\n    set [yv v] to [2]\nend\nset [xv v] to ((xv) * (0.85))\nif <touching (level v)?> then\n    change x by (xv)\nelse\n    change x by (xv)\n    if <touching (level v)?> then\n        if <touching (water v)?> then\n            repeat until <not <touching (level v)?>>\n                change x by (((xv) / ([abs v] of (round (xv)) )) * (-1))\n            end\n        else\n            change y by (8)\n            if <touching (level v)?> then\n                change y by (-8)\n                change x by ((xv) * (-1))\n                repeat until <touching (level v)?>\n                    change x by ((xv) / ([abs v] of (round (xv)) ))\n                end\n                repeat until <not <touching (level v)?>>\n                    change x by (((xv) / ([abs v] of (round (xv)) )) * (-1))\n                end\n                if <<<mouse down?> and <(mouse y) > [0]>> or <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n                    set [xv v] to (((xv) / ([abs v] of (round (xv)) )) * (-16))\n                    set [yv v] to [15]\n                end\n            else\n                repeat until <touching (level v)?>\n                    change y by (-1)\n                end\n                repeat until <not <touching (level v)?>>\n                    change y by (1)\n                end\n            end\n        end\n    end\nend\nif <(yv) < [1]> then\n    set [jumping? v] to [0]\nend\nif <<(jumping?) = [1]> and <not <touching (water v)?>>> then\n    if <not <touching (level v)?>> then\n        change y by (yv)\n        if <touching (level v)?> then\n            repeat until <not <touching (level v)?>>\n                change y by (-1)\n            end\n            set [yv v] to [1]\n            set [jumping? v] to [0]\n        end\n    else\n        change y by (yv)\n    end\n    change [yv v] by (-1)\nelse\n    change y by (-1)\n    if <not <touching (level v)?>> then\n        change y by (yv)\n        change [yv v] by (-1)\n        if <touching (enemy v)?> then\n            broadcast (killEnemy v)\n            set [killedenemy? v] to [1]\n        end\n    end\n    if <<not <touching (level v)?>> and <touching (water v)?>> then\n        change y by (-2)\n    end\nend\nrepeat until <not <touching (level v)?>>\n    change y by (1)\n    set [yv v] to [0]\nend\nchange y by (-1)\nif <touching (jump potion v)?> then\n    set [jumping? v] to [1]\n    set [yv v] to [17]\nend\nif <<(round (xv)) = [0]> and <not <[] = [1]>>> then\n    switch costume to (normal v)\nend\nif <[] = [1]> then\n    switch costume to (squished v)\nend\nif <<touching (danger v)?> or <<touching (enemy v)?> and <(killedEnemy?) = [0]>>> then\n    reset\n    stop [this script v]\nend\n\nwhen I receive [start v]\nbroadcast (newLevel v) and wait\ngo to [front v] layer\nforever\n    platform\n    show\nend\n\nwhen I start as a clone\nswitch costume to (clone v)\nset [ghost v] effect to (0)\nset size to (100) %\nrepeat (10)\n    change size by (-10)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I start as a clone\nforever\n    if <touching (end v)?> then\n        delete this clone\n    end\nend\n\nwhen I receive [start v]\nforever\n    create clone of (_myself_ v)\nend\n\n@level\n\nwhen flag clicked\ngo to [back v] layer\nswitch costume to (1 v)\ngo to x: (0) y: (0)\nset [level v] to [1]\nbroadcast (start v)\n\nwhen I receive [newlevel v]\nswitch costume to (level)\nshow\n\n@end\n\nwhen flag clicked\nforever\n    switch costume to (hasKey?)\n    if <<touching (player v)?> and <(hasKey?) = [1]>> then\n        if <(level) = [4]> then\n            set [level v] to [end]\n            broadcast (newLevel v)\n            broadcast (end v)\n            stop [this script v]\n        end\n        change [level v] by (1)\n        broadcast (newLevel v) and wait\n    end\nend\n\nwhen I receive [newlevel v]\nif <(level) = [1]> then\n    go to x: (137) y: (-40)\nend\nif <(level) = [2]> then\n    go to x: (200) y: (-40)\nend\nif <(level) = [3]> then\n    go to x: (200) y: (-45)\nend\nif <(level) = [4]> then\n    go to x: (200) y: (8)\nend\nshow\n\nwhen I receive [end v]\nhide\n\n@directions\n\nwhen flag clicked\nswitch costume to (1 v)\nforever\n    set size to (75) %\n    go to x: (0) y: (120)\n    go to [front v] layer\n    wait (0.2) seconds\nend\n\nwhen I receive [newlevel v]\nswitch costume to (level)\nshow\n\nwhen I receive [done v]\nstop [other scripts in sprite v]\n\n@jump potion\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (1 v)\n\nwhen I receive [newlevel v]\nif <(level) = [end]> then\n    hide\nelse\n    switch costume to (level)\n    show\nend\n\n@danger\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (1 v)\n\nwhen I receive [newlevel v]\nif <(level) = [end]> then\n    hide\nelse\n    switch costume to (level)\n    show\nend\n\n@key\n\ndefine reset\nswitch costume to (collectible v)\nif <(level) = [1]> then\n    go to x: (200) y: (60)\nend\nif <(level) = [2]> then\n    go to x: (-80) y: (120)\nend\nif <(level) = [3]> then\n    go to x: (0) y: (100)\nend\nif <(level) = [4]> then\n    go to x: (180) y: (135)\nend\nbroadcast (hasKey? v)\nbroadcast (hoverKey v)\nshow\n\nwhen I receive [reset v]\nset [haskey? v] to [0]\nreset\n\nwhen I receive [hoverkey v]\nrepeat until <(hasKey?) = [1]>\n    repeat (30)\n        change y by (0.2)\n    end\n    repeat (30)\n        change y by (-0.2)\n    end\nend\n\nwhen I receive [haskey? v]\nshow\nforever\n    switch costume to (collectible v)\n    point in direction (90)\n    if <touching (player v)?> then\n        broadcast (keyStaysWithPlayer v)\n        stop [this script v]\n    end\nend\n\nwhen I receive [keystayswithplayer v]\nset [haskey? v] to [1]\nrepeat until <(hasKey?) = [0]>\n    switch costume to (held v)\n    go to (player v)\n    if <([costume name v] of [player v]) = [left]> then\n        change x by (-15)\n        point in direction (-90)\n    else\n        point in direction (90)\n        change x by (15)\n    end\nend\n\nwhen I receive [newlevel v]\ngo to [front v] layer\n\n@raindrop\n\nwhen flag clicked\nhide\nforever\n    if <(level) = [1]> then\n        create clone of (_myself_ v)\n    end\nend\n\nwhen I start as a clone\nset [ghost v] effect to (75)\ngo to x: (pick random (-240) to (240)) y: (186)\nshow\nrepeat until <(y position) = [-186]>\n    change x by (pick random (-1) to (5))\n    change y by (-10)\nend\ndelete this clone\n\nwhen I receive [end v]\nstop [other scripts in sprite v]\ndelete this clone\n\n@thumbnail\n\nwhen flag clicked\nset [ghost v] effect to (100)\ngo to x: (0) y: (0)\nforever\n    go to [front v] layer\n    wait (0.01) seconds\n    show\nend\n\nwhen I receive [done v]\nset [vel v] to [-1]\ngo to x: (0) y: (500)\nclear graphic effects\nrepeat until <(y position) < [1]>\n    change y by (vel)\n    change [vel v] by (-1)\nend\nset [vel v] to [10]\nrepeat (10)\n    change y by (vel)\n    change [vel v] by (-1)\nend\nrepeat (10)\n    change y by (vel)\n    change [vel v] by (-1)\nend\nset [vel v] to [5]\nrepeat (5)\n    change y by (vel)\n    change [vel v] by (-1)\nend\nrepeat (5)\n    change y by (vel)\n    change [vel v] by (-1)\nend\ngo to x: (0) y: (0)\nwait (1) seconds\nbroadcast (comment v) and wait\nstop [other scripts in sprite v]\nstop [all v]\n\nwhen I receive [end v]\nwait (10) seconds\nbroadcast (done v)\n\n
PART 2: https://scratch.mit.edu/projects/501869601/\n\nPlease read ↓\n                                ◈ CAVE ◈\nHappy late Valentines Day everyone! <3\n\nWelcome to CAVE, a mobile friendly platformer. Survive the mysterious, scary traps and tricks in the cave, and collect the key to escape through the door . . . or you will be stuck in the cave forever . . .\n\nCAVE 2 is in development!\nIf it lags, press R to reset :)\n\nMake your own platformer easily here!:\nhttps://scratch.mit.edu/projects/477574444/\nPropose this to be featured here!:\nhttps://scratch.mit.edu/studios/28715018/\n\nMake sure to ❤️, ⭐️, and follow for a part 2!!\n\nControls:\nmovement - ←↕→, WAD, or mobile\nreset - R\n\nCan you beat the highscore??\nHave a nice day!\n\nBye! <3