Cuber's journey-Part 4-The Cave-A platformer

Instructions: --------------------------------------------------------\nCuber's Journey-part 4-The Cave-a platformer\n--------------------------------------------------------\nFeatures:\n18 levels\n2 cutscenes and a bossbattle!\nCharacters\nAll levels are possible!\n--------------------------------------------------------\nCuber's Journey Part 1 Speedrun:\nhttps://scratch.mit.edu/discuss/youtube/GK_QLbmbxHs/\n[There will be more speedruns coming soon for parts 1-7!]\n--------------------------------------------------------\nInstructions:\nPlay part 1, 2 and 3 first, because this has a story\nUse  arrow keys to move\nR to restart\nN to skip (Note: You can't skip cutscenes)\nB for back level\nAvoid spikes, lava, and the lasers shot by the Evil Cube.\n--------------------------------------------------------\nI am hosting a game and intro contest! Please join!\nhttps://scratch.mit.edu/projects/582334507/\n--------------------------------------------------------\nUpdates:\n3/11/2021-Shared\n18/7/2022 - Unshared and reshared all parts so that people can find them easier on my profile\n--------------------------------------------------------\nFirst love/star by: @astrono1\n------------------------------------------------------\nGoals:\n1- 5 views-Done!\n2- 5 hearts-Done!\n3- 5 stars-Done!\n4- 15 views-Done!\n5- 10 hearts-Done!\n6- 10 stars-Done!\n7- 50 views-Done!\n8- 25 stars-Done!\n9- 25 hearts-Done!\n10- 100 views-Done!\n11- 50 hearts-Done!\n12- 50 stars-Done!\n13- 500 views-Done!\n14- 500 stars\n15- 500 hearts\n16- 1,000 views\n17- 1,000 hearts\n18- 1,000 stars\n19- 5,000 views\n20- 2,500 stars\n21-2,500 hearts\n22- 10,000 views\n---------------------------------------------------------

@Stage\n\nwhen I receive [intro done v]\nswitch backdrop to (clear sky v)\nbroadcast (end v)\nforever\n    if <(Level) = [1]> then\n        switch backdrop to (landing on the beach v)\n    end\n    if <<<<(Level) = [2]> or <(Level) = [3]>> or <<(Level) = [4]> or <(Level) = [5]>>> or <(Level) = [9]>> then\n        switch backdrop to (clear sky v)\n    end\n    if <(Level) = [6]> then\n        switch backdrop to (cave shadow v)\n    end\n    if <<(Level) > [6]> and <(Level) < [16]>> then\n        switch backdrop to (the cave v)\n    end\n    if <(Level) = [16]> then\n        switch backdrop to (weird glow of the epic sword v)\n    end\n    if <(Level) = [17]> then\n        switch backdrop to (epic sword  v)\n    end\n    if <(Level) = [18]> then\n        switch backdrop to (exit v)\n    end\n    if <(Level) = [19]> then\n        switch backdrop to (clear sky v)\n    end\nend\n\nwhen flag clicked\nset volume to (100) %\nswitch backdrop to (thumbnail v)\nwait (3) seconds\nswitch backdrop to (backdrop3 v)\n\nwhen flag clicked\nforever\n    play sound [TheFatRat - Unity \(Instrumental\) v] until done\nend\n\n@Cuber\n\ndefine Looks\nif <key (any v) pressed?> then\n    if <<<<key (left arrow v) pressed?> or <key (a v) pressed?>> or <<key (right arrow v) pressed?> or <key (d v) pressed?>>> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            point in direction (90)\n        end\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            point in direction (-90)\n        end\n    else\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            point in direction (90)\n        end\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            point in direction (-90)\n        end\n        if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n    end\nend\nset size to (10) %\n\ndefine Dead?\nif <key (r v) pressed?> then\n    Restart\nend\nif <key (b v) pressed?> then\n    broadcast (Back a Level v)\n    Restart\n    wait (0.1) seconds\nend\nif <key (n v) pressed?> then\n    broadcast (Next Level v)\n    Restart\n    wait (0.1) seconds\nend\nif <(x position) > [235]> then\n    if <(Level) = [16]> then\n        if <(Boss defeated) = [1]> then\n            broadcast (Next Level v)\n            Restart\n        end\n    else\n        broadcast (Next Level v)\n        Restart\n    end\nend\nif <(y position) < [-160]> then\n    Dead Looks [1]\nend\nif <touching (spikes and other v)?> then\n    Dead Looks [2]\nend\nif <touching (lava and other v)?> then\n    Dead Looks [3]\nend\nif <touching (the evil cube v)?> then\n    Dead Looks [3]\nend\n\ndefine Restart\nset [xv v] to [0]\nset [yv v] to [0]\ngo to x: (-215) y: (0)\nclear graphic effects\nbroadcast (OOF v)\n\ndefine Dead Looks (type)\nif <(type) = [1]> then\n    set [brightness v] effect to (75)\nend\nif <<(type) = [2]> or <(type) = [4]>> then\n    repeat (20)\n        change y by (2.5)\n        change [ghost v] effect by (5)\n        set [yv v] to [0]\n    end\nend\nif <(type) = [3]> then\n    repeat (20)\n        change y by (-0.5)\n        change [ghost v] effect by (5)\n        set [yv v] to [0]\n    end\nend\nRestart\nbroadcast (OOF v)\n\nwhen I receive [end v]\nwait (0.5) seconds\nshow\nRestart\nset rotation style [left-right v]\nforever\n    if <(Move) = [1]> then\n        go to [front v] layer\n        change [yv v] by (-1)\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            change [xv v] by (1)\n        end\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> 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 (ground v)?> or <touching (bridge v)?>> then\n            change y by (1)\n            if <<touching (ground v)?> or <touching (bridge v)?>> then\n                change y by (1)\n                if <<touching (ground v)?> or <touching (bridge v)?>> then\n                    change y by (1)\n                    if <<touching (ground v)?> or <touching (bridge v)?>> then\n                        change y by (1)\n                        if <<touching (ground v)?> or <touching (bridge v)?>> then\n                            change y by (-4)\n                            change x by ((Xv) * (-1))\n                            if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n                                set [yv v] to [15]\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        change y by (Yv)\n        if <<touching (ground v)?> or <touching (bridge 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 (ground v)?> or <touching (bridge v)?>> and <<key (up arrow v) pressed?> or <key (w v) pressed?>>> then\n            set [yv v] to [15]\n        end\n        change y by (1)\n        Looks\n        Dead?\n        if <touching (bridge v)?> then\n            change x by ([xv v] of [bridge v])\n        end\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nswitch costume to (cuber v)\nforever\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nswitch costume to (cuber v)\nset [bb v] to [0]\nset [move v] to [1]\n\nwhen I start as a clone\ngo to [front v] layer\ngo [backward v] (2) layers\nclear graphic effects\nrepeat (10)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I receive [end v]\nswitch costume to (cuber v)\n\nwhen I receive [animation v]\nglide (1) secs to x: (-215) y: (-70)\nsay [Cubie?] for (2) seconds\nsay [Wake up!] for (2) seconds\nbroadcast (Wake up Cubie! v)\n\nwhen I receive [come with me! v]\nsay [Ok!] for (2) seconds\n\nwhen I receive [come with me! v]\nglide (1) secs to x: (0) y: (-70)\nswitch costume to (cuber/cubie v)\nsay [This way! -->] for (3) seconds\n\ndefine Say (say cuber)\nset [letter cuber v] to [1]\nset [say cuber v] to []\nrepeat (length of (say cuber))\n    if <(letter (Letter cuber) of (say cuber)) = [,]> then\n        set [say cuber v] to (join (Say cuber) (letter (Letter cuber) of (say cuber)))\n        say (Say cuber)\n        change [say cuber v] by (1)\n        wait (0.2) seconds\n    else\n        if <(letter (Letter cuber) of (say cuber)) = [.]> then\n            set [say cubie v] to (join (Say cuber) (letter (Letter cuber) of (say cuber)))\n            say (Say Cubie)\n            change [letter cuber v] by (1)\n            wait (0.5) seconds\n        else\n            if <(letter (Letter cuber) of (say cuber)) = [?]> then\n                set [say cubie v] to (join (Say Cubie) (letter (Letter cuber) of (say cuber)))\n                say (Say Cubie)\n                change [letter cuber v] by (1)\n                wait (0.5) seconds\n            else\n                if <(letter (Letter cubie) of (say cuber)) = [!]> then\n                    set [say cubie v] to (join (Say Cubie) (letter (Letter cubie) of (say cuber)))\n                    say (Say Cubie)\n                    change [letter cubie v] by (1)\n                    wait (0.5) seconds\n                else\n                    if <(letter (Letter cubie) of (say cuber)) = [:]> then\n                        set [say cubie v] to (join (Say Cubie) (letter (Letter cubie) of (say cuber)))\n                        say (Say Cubie)\n                        change [letter cubie v] by (1)\n                        wait (0.5) seconds\n                    else\n                        if <(letter (Letter cubie) of (say cuber)) = [;]> then\n                            set [say cubie v] to (join (Say Cubie) (letter (Letter cubie) of (say cuber)))\n                            say (Say Cubie)\n                            change [letter cubie v] by (1)\n                            wait (0.5) seconds\n                        else\n                            set [say cubie v] to (join (Say Cubie) (letter (Letter cubie) of (say cuber)))\n                            say (Say Cubie)\n                            change [letter cubie v] by (1)\n                            wait (0.05) seconds\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\nwait (1) seconds\n\nwhen I receive [end v]\nwait (1) seconds\nwait until <(Level) = [5]>\nshow\nsay [We are getting near!]\nwait until <not <(Level) = [5]>>\nsay []\nwait until <(Level) = [6]>\nsay [Yes Texer! That's what I wanted to show you and Cuber! A cave! Come in, I think that the Epic Sword may be inside]\nwait until <not <(Level) = [6]>>\nsay []\nwait until <(Level) = [18]>\nsay [There's the exit!]\nwait until <not <(Level) = [18]>>\nsay []\n\nwhen I receive [bossfight v]\nswitch costume to (cuber v)\nglide (1) secs to x: (-170) y: (-24)\n\nwhen I receive [hide texer v]\nsay [Noo!!!] for (3) seconds\n\nwhen I receive [lever activated v]\nglide (1) secs to (epic sword v)\nglide (1) secs to x: (120) y: (-13)\n\nwhen I receive [cross the bridge v]\nsay [Climb on me! Let's get out of here!] for (5) seconds\n\nwhen I receive [move v]\nswitch costume to (cuber/cubie v)\nset [move v] to [1]\n\nwhen I receive [end v]\nset [move v] to [1]\nwait (1) seconds\nwait until <(Level) = [19]>\nswitch costume to (cuber v)\nsay [Yes! We got the sword! But we still need the gem! So, next stop, the sky!!! :D]\n\n@Ground\n\nwhen I receive [next level v]\nnext costume\n\nwhen I receive [back a level v]\nswitch costume to ((costume [number v]) - (1))\n\nwhen flag clicked\nhide\n\nwhen I receive [end v]\nshow\nforever\n    set [level v] to (costume [number v])\n    go to x: (0) y: (0)\nend\n\nwhen flag clicked\nswitch costume to (1 v)\n\nwhen I receive [to be continued... v]\nhide\n\n@Bridge\n\nwhen flag clicked\nhide\n\nwhen I receive [lever activated v]\nhide\n\nwhen I receive [bossfight v]\nshow\ngo to x: (0) y: (0)\n\nwhen I receive [cross the bridge v]\nshow\nwait until <not <(Level) = [17]>>\nhide\n\n@Spikes and Other\n\nwhen I receive [end v]\nshow\nforever\n    switch costume to (Level)\n    go to x: (0) y: (0)\n    go to [back v] layer\nend\n\nwhen flag clicked\nhide\n\n@Lava and Other\n\nwhen flag clicked\nhide\n\nwhen I receive [end v]\nshow\ngo to [back v] layer\nforever\n    show\n    switch costume to (Level)\nend\n\nwhen flag clicked\nhide\nset x to (0)\nforever\n    repeat (20)\n        change y by (0.2)\n    end\n    repeat (20)\n        change y by (-0.2)\n    end\n    set y to (0)\nend\n\n@Cloud Effects\n\nwhen I receive [end v]\nforever\n    hide\n    if <(Level) < [7]> then\n        hide\n        create clone of (_myself_ v)\n        wait (2) seconds\n    end\nend\n\nwhen I start as a clone\nshow\nif <(Level) > [6]> then\n    delete this clone\nend\nswitch costume to (pick random (1) to (3))\nset [ghost v] effect to (pick random (50) to (90))\nset size to (pick random (90) to (110)) %\nset y to (pick random (70) to (150))\nset [cloud speed v] to (pick random (0.3) to (1))\nset x to (-250)\nrepeat until <(x position) > [250]>\n    go to [back v] layer\n    move (Cloud Speed) steps\n    if <(Level) > [6]> then\n        delete this clone\n    end\nend\ndelete this clone\n\nwhen flag clicked\nhide\n\n@Cubie\n\nwhen I start as a clone\ngo to [front v] layer\ngo [backward v] (2) layers\nclear graphic effects\nrepeat (10)\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen flag clicked\nhide\nforever\n    create clone of (_myself_ v)\nend\n\nwhen I receive [end v]\nshow variable [time v]\nreset timer\nforever\n    if <not <(Level) = [19]>> then\n        set [time v] to (join [Your time: ] (timer))\n    end\nend\n\nwhen flag clicked\nhide variable [time v]\n\nwhen I receive [end v]\nset [move v] to [1]\nhide\nwait (1) seconds\nwait until <(Level) = [4]>\nshow\nbroadcast (Animation v)\ngo to x: (215) y: (-70)\nset [move v] to [0]\nsay [zzz...]\nbroadcast (Cubie? v)\n\nwhen I receive [wake up cubie! v]\nsay [C-cuber?] for (2) seconds\nsay [Oh it's you! I woke up a while ago, but got tired, and the beach was quite hot, so I fell asleep. Come, I want to show you something!] for (7) seconds\nbroadcast (Come with me! v)\nwait (2) seconds\nset [move v] to [1]\n\nwhen I receive [come with me! v]\nglide (1) secs to x: (0) y: (-42)\nhide\n\nwhen I receive [bossfight v]\nshow\ngo to x: (-210) y: (-18)\n\nwhen I receive [cross the bridge v]\nwait (1) seconds\nsay [Ok!]\nglide (1) secs to x: (120) y: (14)\nbroadcast (Move v)\nsay []\nhide\n\nwhen I receive [end v]\nset [move v] to [1]\nhide\nwait (1) seconds\nwait until <(Level) = [19]>\nshow\ngo to x: (200) y: (-119)\nsay [Part 5 at 100 likes/loves!]\n\n@The evil cube\n\nwhen flag clicked\nhide\n\nwhen I receive [end v]\nwait (1) seconds\nwait until <(Level) = [17]>\nbroadcast (Bossfight v)\n\nwhen I receive [bossfight v]\nswitch costume to (the evil cube v)\nset size to (25) %\nset [move v] to [0]\nshow\ngo to x: (-43) y: (-4)\nsay [Muahahaha! The Epic Sword is mine! MINE! And, luckily for me, there are no little cubes to spoil my wicked plans- WHAT?! What are you doing here?] for (10) seconds\nsay [Oh, you ask what I'm doing here Texer? I'm going to grab the sword! And say goodbye to Texer!] for (5) seconds\ncreate clone of (_myself_ v)\nset [laser type v] to [1]\nsay [Muahahaha! Now there's no Texer to guide you, I will grab the Sword!] for (5) seconds\nsay [Well, I guess it's already mine, because I'm in front of it, so I will defend it until you leave me alone.] for (5) seconds\nswitch costume to (fire resistance potion v)\nsay [I'm going to drink this fire resistance potion just in case!] for (2) seconds\nsay [Glug-Glug-Glug] for (1) seconds\nswitch costume to (the evil cube v)\nsay [Ok, done! Now let's start!] for (3) seconds\nset [move v] to [1]\nbroadcast (Get here v)\nforever\n    wait (1) seconds\n    set [laser type v] to [2]\n    create clone of (_myself_ v)\n    glide (0.5) secs to x: (-43) y: (30)\n    glide (0.5) secs to x: (-43) y: (-4)\n    wait (2) seconds\n    set [laser type v] to [2]\n    create clone of (_myself_ v)\n    wait (1) seconds\n    set [laser type v] to [3]\n    create clone of (_myself_ v)\n    glide (0.5) secs to x: (-43) y: (100)\n    wait (3) seconds\n    glide (0.5) secs to x: (-43) y: (-4)\nend\n\nwhen I start as a clone\nif <(Laser Type) = [1]> then\n    go to [front v] layer\n    switch costume to (laser 1 v)\n    glide (1) secs to (texer v)\n    broadcast (Hide Texer v)\n    delete this clone\nelse\n    if <(Laser Type) = [2]> then\n        go to [front v] layer\n        switch costume to (laser 2 v)\n        repeat until <touching (_edge_ v)?>\n            change x by (-10)\n        end\n        delete this clone\n    else\n        switch costume to (laser 3 v)\n        glide (1) secs to (cuber v)\n        delete this clone\n    end\nend\n\nwhen I receive [lever activated v]\nstop [other scripts in sprite v]\nbroadcast (Become small v)\nsay [Uh-oh] for (2) seconds\nset [move v] to [0]\n\nwhen I receive [become small v]\nwait (2) seconds\nrepeat (15)\n    change size by (-1)\nend\nrepeat until <touching (lava and other v)?>\n    change y by (-10)\nend\nsay [I WILL HAVE MY REVENGE!]\nwait until <not <(Level) = [17]>>\nhide\n\n@Futurer\n\n@Intro\n\ndefine Play intro\nset [ghost v] effect to (0)\nshow\nset size to (100) %\nbroadcast (Intro sprite2 v)\ngo to [front v] layer\ngo to x: (0) y: (0)\nswitch costume to (joshisaurio!!! v)\nwait (1) seconds\nrepeat (11)\n    wait (0.5) seconds\n    next costume\nend\nbroadcast (Disappear v)\nrepeat (140)\n    change size by (5)\nend\n\nwhen I receive [disappear v]\nrepeat (50)\n    change [ghost v] effect by (2)\nend\nbroadcast (almostdone v)\n\nwhen I receive [start intro v]\nPlay intro\n\nwhen flag clicked\nhide\n\n@Intro2\n\nwhen I receive [intro sprite2 v]\nset [hide v] to [0]\nshow\ngo to x: (-150) y: (90)\ncreate clone of (_myself_ v)\ngo to x: (150) y: (90)\ncreate clone of (_myself_ v)\ngo to x: (-150) y: (-90)\ncreate clone of (_myself_ v)\ngo to x: (150) y: (-90)\ncreate clone of (_myself_ v)\nhide\n\nwhen flag clicked\nhide\n\nwhen I start as a clone\nforever\n    turn right (10) degrees\nend\n\nwhen I start as a clone\nwait until <(Hide) = [1]>\nrepeat (50)\n    change [ghost v] effect by (2)\nend\n\nwhen I receive [disappear v]\nset [hide v] to [1]\n\n@Sprite1\n\nwhen I receive [almostdone v]\nrepeat (50)\n    change [ghost v] effect by (2)\nend\nhide\nbroadcast (Intro Done v)\nhide\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\ngo to [back v] layer\nrepeat (50)\n    change [ghost v] effect by (-2)\nend\nbroadcast (Start Intro v)\n\n@Lag reducer\n\n@Dark\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\n\nwhen I receive [end v]\ngo to [front v] layer\nswitch costume to (some time later... v)\nset [ghost v] effect to (0)\nwait (3) seconds\nrepeat (100)\n    change [ghost v] effect by (1)\nend\nhide\n\nwhen I receive [end v]\nwait (1) seconds\ngo to [front v] layer\nset [ghost v] effect to (0)\nrepeat (100)\n    change [ghost v] effect by (1)\nend\nhide\n\n@Thumbnail\n\nwhen [timer v] > (timer)\ngo to x: (0) y: (0)\nshow\nforever\n    go to [front v] layer\nend\n\nwhen flag clicked\nhide\nset [your time v] to [0.01]\nforever\n    set [your time v] to (timer)\nend\n\n@Texer\n\nwhen I receive [bossfight v]\nshow\n\nwhen flag clicked\nhide\n\nwhen I receive [hide texer v]\nhide\n\n@Epic Sword\n\nwhen flag clicked\nhide\n\nwhen I receive [bossfight v]\nshow\nwait until <touching (cuber v)?>\nhide\n\n@Bridge lever\n\nwhen I receive [get here v]\nswitch costume to (get here v)\nwait (5) seconds\nswitch costume to (lever off v)\nwait until <touching (cuber v)?>\nswitch costume to (lever on v)\nbroadcast (Lever activated v)\nwait (5) seconds\nswitch costume to (lever off v)\nbroadcast (Cross the bridge v)\nwait until <not <(Level) = [17]>>\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [bossfight v]\nshow\n\n