Cave - Part 3 (A Platformer)
@Stage\n\nwhen flag clicked\nswitch backdrop to (backdrop1 v)\nforever\n    if <(level) = [10]> then\n        switch backdrop to (backdrop2 v)\n    end\n    if <(level) = [15]> then\n        switch backdrop to (backdrop1 v)\n    end\n    if <(level) = [23]> then\n        switch backdrop to (backdrop3 v)\n        wait until <(level) = [24]>\n        switch backdrop to (backdrop4 v)\n    end\nend\n\n@player\n\nwhen I receive [go v]\nswitch costume to (1 v)\nset [level v] to [0]\nshow\ngo to x: (-214) y: (115)\nswitch costume to (costume1 v)\nswitch backdrop to (backdrop1 v)\nbroadcast (spawn v)\nforever\n    if <<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<(mouse x) < (x position)> and <mouse down?>>> then\n        change [xv v] by (-1)\n    end\n    if <<<key (right arrow v) pressed?> or <key (d v) pressed?>> or <<(mouse x) > (x position)> and <mouse down?>>> then\n        change [xv v] by (1)\n    end\n    set [xv v] to ((xv) * (0.9))\n    change x by (xv)\n    if <<touching (level v)?> or <touching (moving platform v)?>> then\n        change y by (1)\n        if <<touching (level v)?> or <touching (moving platform v)?>> then\n            change y by (1)\n            if <<touching (level v)?> or <touching (moving platform v)?>> then\n                change y by (1)\n                if <<touching (level v)?> or <touching (moving platform v)?>> then\n                    change y by (1)\n                    if <<touching (level v)?> or <touching (moving platform v)?>> then\n                        change y by (1)\n                        if <<touching (level v)?> or <touching (moving platform v)?>> then\n                            change y by (-5)\n                            change x by ((xv) * (-1))\n                            if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<(mouse y) > (y position)> and <mouse down?>>> then\n                                set [yv v] to [11]\n                                if <([abs v] of (xv) ) = (xv)> then\n                                    set [xv v] to [-10]\n                                else\n                                    set [xv v] to [10]\n                                end\n                            else\n                                set [xv v] to [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change [yv v] by (-1)\n    change y by (yv)\n    if <<touching (level v)?> or <touching (moving platform v)?>> then\n        change y by ((yv) - ((yv) * (2)))\n        set [yv v] to [0]\n    end\n    change y by (-1)\n    if <<touching (level v)?> or <touching (moving platform v)?>> then\n        if <<<key (up arrow v) pressed?> or <key (w v) pressed?>> or <<(mouse y) > (y position)> and <mouse down?>>> then\n            set [yv v] to [16]\n        end\n    end\n    change y by (1)\n    Slope Detection\n    if <(y position) < [-166]> then\n        go to x: (-217) y: (-20)\n    end\n    if <touching (portal v)?> then\n        go to (portal v)\n        repeat (5)\n            move (10) steps\n            change size by (-10)\n            wait (0.07) seconds\n            change y by (-10)\n            wait (0.07) seconds\n            move (-10) steps\n            wait (0.07) seconds\n            change y by (10)\n            change [ghost v] effect by (25)\n        end\n        change [ghost v] effect by (-250)\n        switch backdrop to (next backdrop v)\n        set size to (55) %\n        go to x: (-217) y: (-20)\n    end\nend\n\nwhen flag clicked\nhide\nset size to (55) %\n\nwhen I receive [spawn v]\nchange [level v] by (1)\nset [yv v] to [0]\nset [xv v] to [0]\nif <(level) = [19]> then\n    go to x: (-217) y: (50)\nelse\n    go to x: (-217) y: (-40)\nend\nwait until <(x position) > [222]>\nbroadcast (spawn v)\n\nwhen flag clicked\nforever\n    if <<touching (obstacles v)?> or <<touching (saw v)?> or <<touching (lava v)?> or <touching (saw2 v)?>>>> then\n        go to x: (-217) y: (-40)\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (trampoline v)?> then\n        set [yv v] to [24]\n    end\n    if <touching (darktramp v)?> then\n        set [yv v] to [20]\n    end\nend\n\nwhen I receive [crouch v]\nforever\n    if <<<key (down arrow v) pressed?> or <key (s v) pressed?>> or <<(mouse y) < (y position)> and <mouse down?>>> then\n        if <<(level) = [18]> or <(level) = [19]>> then\n            if <(level) = [18]> then\n                switch costume to (4 v)\n                broadcast (crouch light v)\n            else\n                switch costume to (6 v)\n                broadcast (crouch light v)\n            end\n        else\n            switch costume to (2 v)\n            broadcast (crouch light v)\n        end\n    else\n        if <<(level) = [18]> or <(level) = [19]>> then\n            if <(level) = [18]> then\n                switch costume to (3 v)\n                broadcast (no crouch light v)\n            else\n                switch costume to (5 v)\n                broadcast (no crouch light v)\n            end\n        else\n            switch costume to (1 v)\n            broadcast (no crouch light v)\n        end\n    end\nend\n\ndefine Slope Detection\nif <<touching (level v)?> or <touching (moving platform v)?>> then\n    set [slope v] to [0]\nend\nrepeat until <<(slope) = [8]> or <not <<touching (level v)?> or <touching (moving platform v)?>>>>\n    change [slope v] by (1)\n    change y by (1)\nend\nif <<touching (level v)?> or <touching (moving platform v)?>> then\n    change y by ((slope) / (-1))\nend\n\nwhen I receive [rocks v]\nif <touching (falling rocks v)?> then\n    if <(level) = [19]> then\n        go to x: (-217) y: (50)\n    else\n        go to x: (-217) y: (-40)\n    end\nend\n\n@level\n\nwhen flag clicked\nhide\ngo to x: (0) y: (0)\nforever\n    if <(level) = [7]> then\n        broadcast (crouch v)\n    end\n    if <(level) = [17]> then\n        repeat until <(level) = [24]>\n            set x to (pick random (-2) to (2))\n            set y to (pick random (-2) to (2))\n            create clone of (_myself_ v)\n        end\n    end\n    if <(level) = [24]> then\n        set x to (0)\n        set y to (0)\n    end\nend\n\nwhen I receive [go v]\nshow\n\nwhen I start as a clone\nset [ghost v] effect to (70)\nwait (0.1) seconds\ndelete this clone\n\nwhen flag clicked\nforever\n    switch costume to (level)\nend\n\n@thumbnail\n\nwhen flag clicked\nset [level v] to [0]\nshow\ngo to [front v] layer\nwait (1) seconds\nrepeat (7)\n    change [ghost v] effect by (25)\n    wait (0.2) seconds\nend\nhide\nset [ghost v] effect to (0)\nbroadcast (start screen v)\nforever\n    go to [front v] layer\n    go to x: (36) y: (28)\n    set [ghost v] effect to (100)\n    show\nend\n\nwhen flag clicked\nrepeat until <(level) = [1]>\n    play sound [intro v] until done\nend\n\nwhen I receive [go v]\nstop all sounds\nbroadcast (main song v)\n\nwhen I receive [main song v]\nforever\n    play sound [Elek Tronomia - Elektronomia - Sky High v] until done\nend\n\n@lava\n\nwhen flag clicked\ngo to x: (0) y: (0)\nhide\nforever\n    switch costume to (level)\nend\n\nwhen I receive [go v]\nshow\ngo to [back v] layer\nforever\n    repeat (20)\n        change y by (1)\n    end\n    repeat (20)\n        change y by (-1)\n    end\nend\n\n@obstacles\n\nwhen flag clicked\nhide\ngo to x: (40) y: (-88)\n\nwhen I receive [go v]\ngo to [back v] layer\nshow\nforever\n    switch costume to (level)\nend\n\nwhen flag clicked\nforever\n    if <(level) = [6]> then\n        go to x: (40) y: (-88)\n        repeat until <(level) = [7]>\n            glide (0.5) secs to x: (50) y: (-88)\n            glide (0.5) secs to x: (40) y: (-88)\n        end\n    end\n    if <(level) = [8]> then\n        go to x: (40) y: (-88)\n        repeat until <(level) = [9]>\n            glide (0.5) secs to x: (40) y: (-98)\n            glide (0.5) secs to x: (40) y: (-88)\n        end\n    end\nend\n\n@saw\n\nwhen flag clicked\nset size to (60) %\nswitch costume to (costume1 v)\ngo to [back v] layer\nhide\ngo to x: (0) y: (0)\nforever\n    turn right (9) degrees\n    if <(level) = [8]> then\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <(level) = [5]> then\n        show\n        go to x: (-23) y: (103)\n        create clone of (_myself_ v)\n        wait until <(level) = [6]>\n        hide\n    end\n    if <(level) = [7]> then\n        show\n        go to x: (161) y: (20)\n        broadcast (MOVE v)\n        wait (2) seconds\n    end\n    if <(level) = [8]> then\n        hide\n    end\n    if <(level) = [9]> then\n        show\n        go to x: (-97) y: (-87)\n    end\n    if <(level) = [10]> then\n        switch costume to (costume2 v)\n        go to x: (-192) y: (28)\n    end\n    if <(level) = [11]> then\n        switch costume to (costume2 v)\n        show\n        go to x: (246) y: (47)\n        wait until <(level) = [12]>\n        hide\n    end\n    if <(level) = [13]> then\n        switch costume to (costume2 v)\n        show\n        set size to (80) %\n        go to x: (-175) y: (89)\n    end\n    if <(level) = [14]> then\n        switch costume to (costume2 v)\n        show\n        set size to (60) %\n        go to x: (61) y: (86)\n        wait until <(level) = [15]>\n        switch costume to (costume1 v)\n        go to x: (-114) y: (-85)\n        wait until <(level) = [16]>\n        hide\n    end\n    if <(level) = [23]> then\n        switch costume to (costume1 v)\n        show\n        set size to (60) %\n        go to x: (-113) y: (40)\n        wait until <(level) = [24]>\n        hide\n    end\nend\n\nwhen I start as a clone\ngo to x: (169) y: (-80)\nrepeat until <(level) = [6]>\n    turn right (9) degrees\nend\ndelete this clone\n\nwhen I receive [move v]\nrepeat until <(level) = [8]>\n    glide (1) secs to x: (-150) y: (20)\n    glide (1) secs to x: (161) y: (20)\nend\nstop [this script v]\n\n@trampoline\n\nwhen flag clicked\ngo to [back v] layer\nhide\nswitch costume to (costume1 v)\nforever\n    if <(level) = [4]> then\n        show\n        go to x: (-151) y: (-57)\n        wait until <(level) = [5]>\n        hide\n    end\n    if <(level) = [15]> then\n        show\n        go to x: (-28) y: (-53)\n        wait until <(level) = [16]>\n        hide\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (player v)?> then\n        repeat (5)\n            wait (0.007) seconds\n            next costume\n        end\n    end\nend\n\n@title\n\nwhen flag clicked\nhide\n\nwhen I receive [start screen v]\ngo to x: (0) y: (0)\nshow\nglide (0.3) secs to x: (0) y: (110)\nforever\n    point in direction ((([cos v] of ((tic) * (1.4)) ) * (5)) + (90))\n    change y by (([cos v] of ((tic) * (2.1)) ) * (1.4))\n    change size by (([cos v] of ((tic) * (1.4)) ) * (0.3))\n    change [tic v] by (5)\nend\n\nwhen I receive [go v]\nhide\n\n@play button\n\nwhen flag clicked\nhide\n\nwhen I receive [start screen v]\ngo to [front v] layer\ngo to x: (0) y: (-5)\nshow\nforever\n    point in direction ((([cos v] of ((tic) * (1.4)) ) * (5)) + (90))\n    change y by (([cos v] of ((tic) * (2.1)) ) * (1.4))\n    change size by (([cos v] of ((tic) * (1.4)) ) * (0.3))\n    change [tic v] by (5)\nend\n\nwhen this sprite clicked\nbroadcast (go v)\n\nwhen I receive [go v]\nhide\n\n@start screen thing\n\nwhen I receive [start screen v]\nshow\n\nwhen I receive [go v]\nhide\n\nwhen flag clicked\nhide\n\n@light\n\nwhen I receive [go v]\nshow\nswitch costume to (costume1 v)\nset size to (100) %\nforever\n    go to (player v)\n    go [backward v] (1) layers\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [crouch light v]\nset size to (50) %\n\nwhen I receive [no crouch light v]\nset size to (100) %\n\n@wordies\n\nwhen flag clicked\nhide\n\nwhen I receive [go v]\ngo to x: (0) y: (0)\nshow\nforever\n    go to [front v] layer\n    switch costume to (level)\nend\n\n@saw2\n\nwhen flag clicked\ngo to [back v] layer\nhide\ngo to x: (0) y: (0)\nforever\n    turn right (9) degrees\nend\n\nwhen flag clicked\nforever\n    if <(level) = [5]> then\n        show\n        go to x: (-106) y: (-83)\n        wait until <(level) = [6]>\n        hide\n    end\nend\n\n@moving platform\n\nwhen flag clicked\nhide\ngo to x: (60) y: (-70)\nforever\n    if <(level) = [6]> then\n        show\n        create clone of (_myself_ v)\n        repeat until <(level) = [7]>\n            glide (1) secs to x: (-20) y: (-70)\n            glide (1) secs to x: (60) y: (-70)\n        end\n    end\nend\n\nwhen I start as a clone\nshow\ngo to x: (208) y: (-70)\nforever\n    if <(level) = [6]> then\n        repeat until <(level) = [7]>\n            glide (1) secs to x: (208) y: (10)\n            glide (1) secs to x: (208) y: (-70)\n        end\n    end\nend\n\nwhen I receive [crouch v]\nforever\n    hide\n    stop [this script v]\nend\n\n@skip\n\nwhen this sprite clicked\nbroadcast (spawn v)\n\nwhen flag clicked\nhide\npoint in direction (90)\nset size to (100) %\ngo to x: (-198) y: (-159)\n\nwhen flag clicked\nforever\n    if <touching (mouse-pointer v)?> then\n        set size to (120) %\n    else\n        set size to (100) %\n    end\nend\n\nwhen I receive [go v]\nshow\ngo to [front v] layer\n\nwhen I receive [go v]\nforever\n    point in direction ((([sin v] of ((timer) * (100)) ) * (10)) + (90))\nend\n\nwhen backdrop switches to [backdrop4 v]\nhide\n\n@particle\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nif <(level) = [24]> then\n    hide\n    delete this clone\nend\nswitch costume to (pick random (1) to (3))\ngo to [back v] layer\ngo to x: (-260) y: (pick random (-150) to (180))\nset [ghost v] effect to (pick random (50) to (95))\nset size to (pick random (50) to (100)) %\nrepeat (100)\n    change x by (5)\nend\n\nwhen I start as a clone\nif <(level) = [24]> then\n    hide\n    delete this clone\nend\nif <(size) > [100]> then\n    wait (1) seconds\nelse\n    wait (1.5) seconds\nend\nrepeat (500)\n    change [ghost v] effect by (0.5)\nend\ndelete this clone\n\nwhen I receive [go v]\nshow\ngo to x: (-255) y: (125)\nset [ghost v] effect to (100)\nrepeat until <(level) = [24]>\n    create clone of (_myself_ v)\n    wait (0.07) seconds\nend\n\nwhen backdrop switches to [backdrop4 v]\nhide\ndelete this clone\n\n@darktramp\n\nwhen flag clicked\ngo to [back v] layer\nhide\nswitch costume to (costume1 v)\nforever\n    if <(level) = [12]> then\n        show\n        go to x: (106) y: (-55)\n        if <touching (player v)?> then\n            repeat (5)\n                wait (0.007) seconds\n                next costume\n            end\n        end\n    end\n    if <(level) = [13]> then\n        hide\n    end\nend\n\n@fake wall\n\nwhen flag clicked\ngo to [back v] layer\ngo to x: (3) y: (176)\nhide\nforever\n    if <(level) = [16]> then\n        show\n        wait until <(level) = [17]>\n        hide\n    end\nend\n\n@Falling Rocks\n\nwhen flag clicked\nset [level v] to [0]\ngo to [front v] layer\nhide\nset [ghost v] effect to (100)\nforever\n    if <(level) = [17]> then\n        show\n        create clone of (_myself_ v)\n        repeat until <(level) = [24]>\n            wait (pick random (1) to (1.5)) seconds\n            create clone of (_myself_ v)\n        end\n        if <(level) = [24]> then\n            hide\n            delete this clone\n        end\n    end\nend\n\nwhen I start as a clone\nif <(level) = [24]> then\n    hide\n    delete this clone\nend\nif <<(level) = [21]> or <<(level) = [22]> or <(level) = [23]>>> then\n    set y to (160)\n    set x to (pick random (158) to (-85))\nelse\n    set x to (200)\n    set y to (pick random (158) to (-85))\nend\nset [ghost v] effect to (0)\nswitch costume to (costume4 v)\npoint in direction (90)\nhide\nwait (0.3) seconds\nshow\nwait (0.3) seconds\nswitch costume to (pick random (1) to (3))\nforever\n    if <(level) = [24]> then\n        hide\n        delete this clone\n    end\n    if <not <(costume [number v]) = [4]>> then\n        broadcast (rocks v)\n    end\n    turn right (pick random (2) to (10)) degrees\n    if <<(level) = [21]> or <<(level) = [22]> or <(level) = [23]>>> then\n        change y by (-15)\n        if <(y position) < [-120]> then\n            delete this clone\n        end\n    else\n        change x by (-15)\n        if <(x position) < [-225]> then\n            delete this clone\n        end\n    end\nend\n\nwhen I receive [spawn v]\ndelete this clone\n\n@clouds\n\nwhen backdrop switches to [backdrop4 v]\nhide\ncreate clone of (_myself_ v)\nforever\n    wait (5) seconds\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\ngo to [back v] layer\nshow\nset x to (271)\nset y to (107)\nset size to (100) %\nswitch costume to (pick random (1) to (3))\nset [ghost v] effect to (pick random (30) to (10))\nforever\n    change x by (-3)\n    if <(x position) < [-171]> then\n        delete this clone\n    end\nend\n\n
SPAM the green flag for less lag and a better experience :)\nMovement - Arrow keys, WASD, or mobile\n- Yellow trampoline is bouncy (duh)\n- Avoid saws, spikes, lava, and rocks\nAll 23 levels are possible!! I completed the game on mobile and on computer. Mobile is MUCH harder, but still possible. PLEASE DON'T SPAM THE SKIP BUTTON, because then the saws get messed up.\nPart 1: https://scratch.mit.edu/projects/408980873/\nPart 2: https://scratch.mit.edu/projects/409168331/\nPlease leave a love and favorite, (and maybe even a follow)!\nPart 4 coming soon!\nFor no lag go here: https://turbowarp.org/#413466230\n