A Knight's Quest || Scratch Platformer

Instructions: ============== [HOW TO PLAY] ==============\narrow keys / wad - to move\ns - skip cutscenes\nmouse - go through scene dialogue & interact with certain objects\nspacebar - use sword\nneed help with obtaining a key? - the king may give you a clue...\n================ [NOTICE] =================\nThis game was created as a submission for a contest... but unfortunately, I was not able to complete this project in time.  Even though this project may not be the best, I am completely proud with what I have created for you guys to hopefully enjoy, and any constructive criticism would be gladly appreciated.  Thank you! - xqlvicc\n=========================================\n#games #all #platformer #knight #forthethrone #mission

@Stage\n\nwhen flag clicked\nforever\n    switch backdrop to (sky_var)\nend\n\nwhen flag clicked\nforever\n\nplay sound [Medieval2 v] until done\n\nwhen flag clicked\nforever\n    if <<<(stage #) < [7]> or <(stage #) > [10]>> and <not <(stage #) = [14]>>> then\n        set [sky_var v] to [SKY]\n    else\n        if <(stage #) = [14]> then\n            set [sky_var v] to [CASTLE]\n        else\n            set [sky_var v] to [CAVE]\n        end\n    end\nend\n\nwhen flag clicked\nset [death count v] to [0]\nset [enemy death count v] to [0]\n\nwhen I receive [player down! v]\nchange [death count v] by (1)\n\n@HITBOX\n\nwhen flag clicked\nshow\nset [ghost v] effect to (100)\nset size to (50) %\npoint in direction (90)\nset [y movement speed v] to [0]\nset [fall var v] to [20]\nset [gravity v] to [-1.5]\nset [x movement speed v] to [0]\nforever\n    if <(game) = [play]> then\n        if <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n            change [x movement speed v] by (-1.2)\n        end\n        if <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n            change [x movement speed v] by (1.2)\n        end\n        set [x movement speed v] to ((x movement speed) * (0.9))\n        change [y movement speed v] by (gravity)\n        if <<touching (props v)?> and <([costume name v] of [props v]) = [rope]>> then\n            move in steps ([abs v] of (x movement speed) )\n        else\n            move in steps (([abs v] of (x movement speed) ) + ([abs v] of (y movement speed) ))\n        end\n    end\nend\n\ndefine move in steps (steps)\nchange [fall var v] by (1)\nrepeat (steps)\n    set [last value v] to (x position)\n    change x by ((x movement speed) / (steps))\n    if <<touching (level v)?> or <touching (block v)?>> then\n        set x to (last value)\n        set [x movement speed v] to [0]\n    end\n    set [last value v] to (y position)\n    change y by ((y movement speed) / (steps))\n    if <<touching (level v)?> or <touching (block v)?>> then\n        set y to (last value)\n        if <(y movement speed) < [0]> then\n            set [fall var v] to [0]\n        end\n        set [y movement speed v] to [0]\n    end\nend\n\nwhen flag clicked\nset [last y v] to [-40]\ngo to x: (-203) y: (last y)\nset [stage # v] to [1]\nforever\n    if <<<touching (obstacles v)?> or <<touching (haunted knight v)?> and <(hit?) = [no]>>> or <<touching (slime v)?> and <(hit?) = [no]>>> then\n        wait (0.0001) seconds\n        set [game v] to [death]\n        broadcast (player down! v) and wait\n        set x to (last x)\n        set y to (last y)\n        set [game v] to [play]\n        broadcast (alive v)\n    end\n    if <(game) = [play]> then\n        if <<(x position) = [242]> or <(x position) > [242]>> then\n            set x to (-203)\n            set [stage # v] to ((stage #) + (1))\n            set [last y v] to (y position)\n            set [last x v] to (x position)\n            set y to (last y)\n            set [x movement speed v] to [0]\n        end\n    end\nend\n\nwhen I receive [investigate the chest v]\ngo to x: (-77) y: (-56)\n\nwhen flag clicked\nforever\n    if <<key (up arrow v) pressed?> or <key (w v) pressed?>> then\n        if <(fall var) < [3]> then\n            set [y movement speed v] to [16]\n        end\n    end\nend\n\n@LEVEL\n\nwhen flag clicked\nforever\n    repeat until <(costume [name v]) = [14]>\n        go to x: (0) y: (0)\n        switch costume to (join [LEVEL ] (stage #))\n    end\nend\n\nwhen I receive [ending scene v]\nset [stage # v] to [14]\n\n@PROPS\n\nwhen flag clicked\nhide\nforever\n    if <(stage #) = [1]> then\n        show\n        switch costume to (overworld sign v)\n        go to x: (-160) y: (-90)\n        go to [back v] layer\n    else\n        if <(stage #) = [2]> then\n            show\n            switch costume to (overworld sign v)\n            go to x: (-100) y: (-90)\n            go to [back v] layer\n        else\n            if <(stage #) = [3]> then\n                show\n                switch costume to (overworld sign v)\n                go to x: (-150) y: (-90)\n                go to [back v] layer\n            else\n                if <(stage #) = [6]> then\n                    show\n                    switch costume to (overworld sign v)\n                    go to x: (-120) y: (-96)\n                    go to [back v] layer\n                else\n                    if <(stage #) = [8]> then\n                        show\n                        switch costume to (underground sign2 v)\n                        go to x: (16) y: (13)\n                        go to [back v] layer\n                    else\n                        hide\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nset [text v] to [false]\nforever\n    if < (costume [name v]) contains [SIGN]?> then\n        if <touching (hitbox v)?> then\n            repeat until <not <touching (hitbox v)?>>\n                set [text v] to [true]\n            end\n            set [text v] to [false]\n        end\n    end\nend\n\n@CROSS-HAIRE\n\nwhen flag clicked\ngo [forward v] (999) layers\nforever\n    go to (mouse-pointer v)\nend\n\nif < ([costume name v] of [weapons v]) contains [bow]?> then\n    show\nelse\n    hide\nend\n\n@PLAYER\n\nwhen flag clicked\nswitch costume to (current v)\nset [ghost v] effect to (0)\nforever\n    if <(game) = [play]> then\n        set [brightness v] effect to (0)\n        set rotation style [left-right v]\n        go to (hitbox v)\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    end\nend\n\nwhen I receive [player down! v]\nswitch costume to (current \(dead\) v)\nset [brightness v] effect to (50)\nwait (0.3) seconds\nrepeat (20)\n    change [ghost v] effect by (5)\nend\nswitch costume to (current v)\nset [x movement speed v] to [0]\n\nwhen I receive [player down! v]\nrepeat (1)\n    change y by (-5)\nend\nrepeat (30)\n    change y by (5)\nend\n\nwhen flag clicked\npoint in direction (90)\nset [game v] to [beginning cutscene]\ngo to x: (-200) y: (-56)\n\nwhen I receive [walk! v]\nglide (2) secs to x: (100) y: (-56)\n\nwhen I receive [walk back! v]\npoint in direction (-90)\nglide (2) secs to x: (-200) y: (-56)\n\nwhen flag clicked\nwait (1) seconds\nwait until <[inventory v] contains [crown]?>\nbroadcast (game completed! v) and wait\n\nwhen I receive [game completed! v]\nwait until <(game) = [ending cutscene]>\npoint in direction (90)\nswitch costume to (current \(crown\) v)\ngo to x: (-200) y: (-56)\n\nwhen I receive [knight gives crown! v]\nwait (1) seconds\nswitch costume to (current v)\n\nwhen I receive [turn around! v]\npoint in direction (-90)\n\nwhen I receive [walk to chest v]\nglide (2) secs to x: (-77) y: (-56)\npoint in direction (90)\n\nwhen I receive [investigate the chest v]\nswitch costume to (current v)\n\nadd [key] to [inventory v]\n\nwhen I receive [chest appear! v]\nrepeat (10)\n    wait (0.09) seconds\n    change y by (1)\n    change x by (10)\n    wait (0.09) seconds\n    change y by (-1)\n    change x by (-10)\nend\n\nwhen I receive [alive v]\ngo to (hitbox v)\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nset [ghost v] effect to (100)\n\n@OBSTACLES\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    switch costume to (join [OBSTACLE ] (stage #))\nend\n\n@TEXT\n\nwhen flag clicked\nforever\n    if <not < (game) contains [cutscene]?>> then\n        switch costume to (join [TEXT LEVEL ] (stage #))\n        if <(stage #) = [14]> then\n            go to (king v)\n        else\n            go to (props v)\n        end\n        if <(text) = [true]> then\n            show\n        else\n            hide\n        end\n    else\n        hide\n    end\nend\n\n@COLLECTIBLES\n\nwhen flag clicked\nset [chest v] to [closed]\nhide\nforever\n    if <(stage #) = [14]> then\n        set [type of gem? v] to (pick random (1) to (4))\n        if <(type of gem?) = [1]> then\n            set [item v] to [diamond]\n        else\n            if <(type of gem?) = [2]> then\n                set [item v] to [ruby stone]\n            else\n                if <(type of gem?) = [3]> then\n                    set [item v] to [pink diamond]\n                else\n                    if <(type of gem?) = [4]> then\n                        set [item v] to [mystic stone]\n                    end\n                end\n            end\n        end\n        set [brightness v] effect to (10)\n        set [ghost v] effect to (100)\n        switch costume to (item)\n        wait until <<(chest) = [opened]> or <not <(stage #) = [14]>>>\n        create clone of (_myself_ v)\n        wait until <not <(stage #) = [14]>>\n    else\n        if <(stage #) = [6]> then\n            set [brightness v] effect to (0)\n            set [item v] to [pickaxe]\n            insert tool [-63] [-92]\n            create clone of (_myself_ v)\n            wait until <not <(stage #) = [6]>>\n        else\n            if <(stage #) = [8]> then\n                set [brightness v] effect to (0)\n                set [item v] to [sword]\n                insert tool [10] [44]\n                create clone of (_myself_ v)\n                wait until <not <(stage #) = [8]>>\n            else\n                if <<(stage #) = [12]> and <<(enemy death count) = [4]> and <(death count) < [4]>>> then\n                    set [brightness v] effect to (10)\n                    set [item v] to [key]\n                    insert tool [148] [-26]\n                    create clone of (_myself_ v)\n                    wait until <not <(stage #) = [12]>>\n                else\n                    if <(stage #) = [13]> then\n                        set [brightness v] effect to (10)\n                        set [item v] to [crown]\n                        insert tool [11] [90]\n                        create clone of (_myself_ v)\n                        wait until <not <(stage #) = [13]>>\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine insert tool (x) (y)\ngo to x: (x) y: (y)\nswitch costume to (item)\n\nwhen I start as a clone\nshow\nif <<(item) = [key]> or << (item) contains [diamond]?> or < (item) contains [stone]?>>> then\n    set [ghost v] effect to (100)\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\nend\nforever\n    set [ghost v] effect to (0)\n    if <touching (player v)?> then\n        if <(item) = [crown]> then\n            broadcast (crown!! v)\n        else\n            broadcast (item collected! v)\n        end\n        insert (item) at (1) of [inventory v] \n        delete this clone\n    else\n        if <(item) = [0]> then\n            delete this clone\n        end\n    end\nend\n\nwhen flag clicked\nset [item v] to [0]\ndelete all of [inventory v]\n\nwhen I start as a clone\nforever\n    if << (item) contains [diamond]?> or < (item) contains [stone]?>> then\n        go to (chest v)\n    end\nend\n\nwhen I start as a clone\n\n    set [brightness v] effect to (10)\n    switch costume to (item)\n    set [ghost v] effect to (100)\n    repeat (10)\n        change [ghost v] effect by (-10)\n    end\nend\n\n@BLOCK\n\nwhen I start as a clone\nshow\nforever\n    if <[inventory v] contains [pickaxe]?> then\n        if <touching (mouse-pointer v)?> then\n            repeat until <not <touching (mouse-pointer v)?>>\n                set [brightness v] effect to (-10)\n                if <mouse down?> then\n                    broadcast (mining v)\n                    delete this clone\n                end\n            end\n            set [brightness v] effect to (0)\n        end\n    end\nend\n\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nhide\nwait (1) seconds\nforever\n    if <(stage #) = [6]> then\n        go to x: (130) y: (-80)\n        switch costume to (6 v)\n        create clone of (_myself_ v)\n        wait until <not <(stage #) = [6]>>\n    else\n        if <(stage #) = [8]> then\n            go to x: (211) y: (92)\n            switch costume to (10 v)\n            create clone of (_myself_ v)\n            wait until <not <(stage #) = [8]>>\n        end\n    end\nend\n\nwhen flag clicked\n\n@SETTINGS\n\nwhen flag clicked\nforever\n    hide\nend\n\n@WEAPON\n\nrepeat (7)\n    turn right (-15) degrees\nend\n\n\n\n\n\ndefine insert tool (x) (y)\ngo to x: (x) y: (y)\nswitch costume to (item)\ncreate clone of (_myself_ v)\n\nwhen flag clicked\nforever\n    go to (hitbox v)\nend\n\nrepeat (7)\n\nturn right (15) degrees\n\nturn right (-15) degrees\nwait (0.2) seconds\n\nwhen flag clicked\nforever\n    if <[inventory v] contains [sword]?> then\n        if <<key (space v) pressed?> and <(game) = [play]>> then\n            broadcast (swoosh! v)\n            if <([direction v] of [player v]) = [90]> then\n                switch costume to (sword left v)\n                show\n                repeat (12)\n                    turn right (15) degrees\n                end\n                hide\n                wait (0.2) seconds\n            else\n                if <([direction v] of [player v]) = [-90]> then\n                    switch costume to (sword right v)\n                    show\n                    repeat (12)\n                        turn right (-15) degrees\n                    end\n                    hide\n                    wait (0.2) seconds\n                end\n            end\n        end\n        point in direction (90)\n    else\n        hide\n    end\nend\n\n@HAUNTED KNIGHT\n\nwhen flag clicked\nhide\n\nwhen flag clicked\nwait (1) seconds\nforever\n    if <(stage #) = [8]> then\n        go to x: (172) y: (56)\n        point in direction (90)\n        create clone of (_myself_ v)\n        wait until <not <(stage #) = [8]>>\n    else\n        if <(stage #) = [10]> then\n            go to x: (19) y: (-12)\n            point in direction (90)\n            create clone of (_myself_ v)\n            wait until <not <(stage #) = [10]>>\n        end\n    end\nend\n\nwhen I start as a clone\nset [hit? v] to [no]\nshow\nset [ghost v] effect to (0)\nset [brightness v] effect to (0)\nforever\n    if <touching (weapon v)?> then\n        change [enemy death count v] by (1)\n        set [hit? v] to [yes]\n        repeat (20)\n            change [brightness v] effect by (5)\n            change [ghost v] effect by (5)\n        end\n        delete this clone\n    end\nend\n\nwhen I start as a clone\nforever\n    switch costume to (0 v)\n    wait (0.09) seconds\n    broadcast (sword out! v)\n    repeat until <(costume [name v]) = [6]>\n        next costume\n        wait (0.09) seconds\n    end\n    wait (1) seconds\n    broadcast (pull back! v)\n    repeat until <(costume [name v]) = [9]>\n        next costume\n        wait (0.09) seconds\n    end\n    wait (1) seconds\nend\n\n@AUDIO\n\nwhen flag clicked\nhide\nforever\n    play sound [medival music v] until done\nend\n\nwhen I receive [next scene! v]\nstart sound [click v]\nstart sound [robot v]\n\nwhen I receive [player down! v]\nstart sound [pew v]\nstart sound [death v]\nplay sound [death sound v] until done\n\nwhen I receive [jump! v]\nstart sound [high whoosh v]\nplay sound [Jump v] until done\n\nwhen I receive [mining v]\nstart sound [break low v]\nplay sound [break high v] until done\n\nwhen I receive [item collected! v]\nstart sound [collected v]\nstart sound [item picked up v]\nplay sound [collect v] until done\n\nwhen I receive [swoosh! v]\nstart sound [low whoosh v]\nplay sound [high whoosh v] until done\n\nwhen flag clicked\nset [hit? v] to [no]\nforever\n    if <(hit?) = [yes]> then\n        start sound [strike v]\n        start sound [death v]\n        play sound [death sound v] until done\n        wait until <(hit?) = [no]>\n    end\nend\n\nwhen I receive [crown!! v]\nstart sound [you obtained the crown! v]\n\nwhen flag clicked\nforever\n    if <<(y movement speed) = [0]> and <<<key (d v) pressed?> or <key (a v) pressed?>> or <<key (right arrow v) pressed?> or <key (left arrow v) pressed?>>>> then\n        repeat until <not <<(y movement speed) = [0]> and <<<key (d v) pressed?> or <key (a v) pressed?>> or <<key (right arrow v) pressed?> or <key (left arrow v) pressed?>>>>>\n    end\nend\n\nwhen I receive [sword out! v]\nstart sound [high whoosh v]\n\nwhen I receive [pull back! v]\nstart sound [low whoosh v]\n\nwhen I receive [slimedown v]\n\nwhen I receive [slimeup! v]\n\nstart sound [slimeup v]\n\nstart sound [slimedown v]\n\n@LABEL\n\nwhen I receive [item collected! v]\nrepeat (10)\n    change [pixelate v] effect by (-10)\nend\nwait (1) seconds\nrepeat (10)\n    change [pixelate v] effect by (10)\nend\nset [pixelate v] effect to (100)\n\nwhen I receive [crown!! v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (1) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nset [ghost v] effect to (100)\n\nwhen flag clicked\ngo to x: (-160) y: (-169)\nset [ghost v] effect to (100)\nset [pixelate v] effect to (100)\n\nwhen flag clicked\n\nwhen I receive [investigate the chest v]\nrepeat until <(chest) = [opened]>\n    if <(chest dialogue) = [yes]> then\n        repeat (10)\n            change [ghost v] effect by (-10)\n        end\n        wait until <not <(chest dialogue) = [yes]>>\n        repeat (10)\n            change [ghost v] effect by (10)\n        end\n    end\nend\n\nwhen I receive [investigate the chest v]\nrepeat until <(chest) = [opened]>\n    if <(chest dialogue) = [yes]> then\n        if <(chest dialogue) = [yes]> then\n            repeat (10)\n                change [pixelate v] effect by (-10)\n            end\n            wait until <not <(chest dialogue) = [yes]>>\n            repeat (10)\n                change [pixelate v] effect by (10)\n            end\n        end\n    end\nend\n\nwhen flag clicked\nshow\nforever\n    if <(chest dialogue) = [yes]> then\n        repeat until <(chest) = [opened]>\n            if <[inventory v] contains [key]?> then\n                switch costume to (click to unlock v)\n            else\n                switch costume to (requires key v)\n            end\n        end\n    else\n        if << (item) contains [diamond]?> or < (item) contains [stone]?>> then\n            switch costume to (join (item) [ obtained])\n        else\n            if < (item) contains [crown]?> then\n                switch costume to (crown retrieved v)\n            else\n                switch costume to (tool collected v)\n            end\n        end\n    end\nend\n\nwhen I receive [crown!! v]\nrepeat (10)\n    change [pixelate v] effect by (-10)\nend\nwait (1) seconds\nrepeat (10)\n    change [pixelate v] effect by (10)\nend\nset [pixelate v] effect to (100)\n\nwhen I receive [item collected! v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\nwait (1) seconds\nrepeat (10)\n    change [ghost v] effect by (10)\nend\nset [ghost v] effect to (100)\n\n@SLIME\n\nwhen I start as a clone\nforever\n    switch costume to (1 v)\n    wait (1) seconds\n    repeat until <(costume [name v]) = [5]>\n        next costume\n        wait (0.09) seconds\n    end\n    broadcast (slimeup! v)\n    repeat until <(costume [name v]) = [1]>\n        switch costume to ((costume [name v]) - (1))\n        wait (0.09) seconds\n    end\n    wait (0.09) seconds\n    broadcast (slimedown v)\nend\n\nwhen I start as a clone\nset [hit? v] to [no]\nshow\nset [ghost v] effect to (0)\nset [brightness v] effect to (0)\nforever\n    if <touching (weapon v)?> then\n        change [enemy death count v] by (1)\n        set [hit? v] to [yes]\n        repeat (20)\n            change [brightness v] effect by (5)\n            change [ghost v] effect by (5)\n        end\n        delete this clone\n    end\nend\n\nwhen flag clicked\nhide\nwait (1) seconds\nforever\n    if <(stage #) = [11]> then\n        switch costume to (1 v)\n        go to x: (80) y: (-105)\n        point in direction (90)\n        create clone of (_myself_ v)\n        wait until <not <(stage #) = [11]>>\n    else\n        if <(stage #) = [12]> then\n            switch costume to (1 v)\n            go to x: (13) y: (35)\n            point in direction (90)\n            create clone of (_myself_ v)\n            wait until <not <(stage #) = [12]>>\n        else\n            \n        end\n    end\nend\n\ndelete this clone\n\nwhen I start as a clone\nif <(stage #) = [11]> then\n    wait until <not <(stage #) = [11]>>\n    delete this clone\nend\n\n@CINEMA LINES\n\nwhen flag clicked\nshow\n\nforever\n\nwhen flag clicked\nforever\n    if < (game) contains [cutscene]?> then\n        switch costume to (lines - cinema v)\n    else\n        switch costume to (lines - gameplay v)\n    end\nend\n\n@ANIMATED BACKGROUND\n\nwhen flag clicked\nforever\n    if < (game) contains [cutscene]?> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [chest appear! v]\nrepeat (10)\n    wait (0.09) seconds\n    change y by (1)\n    change x by (10)\n    wait (0.09) seconds\n    change y by (-1)\n    change x by (-10)\nend\n\n@SCENE DIALOGUE\n\nwhen flag clicked\nshow\ngo to x: (5) y: (-146)\nswitch costume to (1 v)\nwait until <(game) = [beginning cutscene]>\nrepeat until <(costume [name v]) = [11]>\n    if <mouse down?> then\n        if <(game) = [beginning cutscene]> then\n            if <(costume [name v]) = [1]> then\n                broadcast (walk! v) and wait\n            end\n            broadcast (next scene! v)\n            next costume\n            wait (0.5) seconds\n        end\n    end\nend\nwait until <mouse down?>\nbroadcast (walk back! v) and wait\nbroadcast (start game! v)\n\nwhen I receive [start game! v]\nbroadcast (black screen! v) and wait\n\nwhen I receive [game completed! v]\nswitch costume to (12 v)\n\nwhen flag clicked\nwait (1) seconds\nwait until <(game) = [ending cutscene]>\nshow\nrepeat until <(costume [name v]) = [26]>\n    if <mouse down?> then\n        if <(costume [name v]) = [12]> then\n            broadcast (walk! v) and wait\n        else\n            if <(costume [name v]) = [13]> then\n                broadcast (get up! v) and wait\n            else\n                if <(costume [name v]) = [16]> then\n                    broadcast (knight gives crown! v)\n                    wait (1) seconds\n                else\n                    if <(costume [name v]) = [22]> then\n                        hide\n                        broadcast (chest appear! v) and wait\n                        show\n                    else\n                        if <(costume [name v]) = [23]> then\n                            broadcast (turn around! v) and wait\n                        end\n                        if <(costume [name v]) = [25]> then\n                            broadcast (walk to chest v) and wait\n                            broadcast (investigate the chest v) and wait\n                        end\n                    end\n                end\n            end\n        end\n        broadcast (next scene! v)\n        next costume\n        wait (0.5) seconds\n    end\nend\n\nwhen I receive [investigate the chest v]\nwait (1) seconds\nforever\n    switch costume to (26 v)\nend\n\nwhen I receive [knight gives crown! v]\nhide\nwait until <([costume name v] of [king v]) = [CROWNED]>\nwait (1) seconds\nshow\n\nwhen I receive [black screen! v]\nwait (1) seconds\nhide\n\nwhen I receive [chest appear! v]\nwait (4) seconds\n\n@BLACK SCREEN\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\n\nwhen I receive [black screen! v]\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\nwait (3) seconds\nset [game v] to [play]\nrepeat (20)\n    change [ghost v] effect by (5)\nend\n\nwhen flag clicked\nforever\n    if <(game) = [ending cutscene]> then\n        if <key (s v) pressed?> then\n            broadcast (investigate the chest v) and wait\n        end\n    else\n        if <(game) = [beginning cutscene]> then\n            if <key (s v) pressed?> then\n                broadcast (black screen! v) and wait\n            end\n        end\n    end\nend\n\nwhen I receive [game completed! v]\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\nwait (3) seconds\nset [game v] to [ending cutscene]\nrepeat (20)\n    change [ghost v] effect by (5)\nend\n\nwhen I receive [investigate the chest v]\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\nwait (3) seconds\nset [stage # v] to [14]\nset [game v] to [play]\nrepeat (20)\n    change [ghost v] effect by (5)\nend\n\n@KING\n\nwhen flag clicked\nswitch costume to (crownless v)\ngo to x: (196) y: (-29)\npoint in direction (90)\n\nwhen I receive [get up! v]\nturn right (15) degrees\nrepeat until <(direction) = [88]>\n    turn left (1) degrees\nend\npoint in direction (90)\n\nwhen I receive [get up! v]\nrepeat (10)\n    move (-2) steps\nend\nglide (0.5) secs to x: (165) y: (-50)\n\nwhen I receive [knight gives crown! v]\nwait (1) seconds\nswitch costume to (crowned v)\n\nwhen I receive [walk to chest v]\npoint in direction (90)\nglide (1) secs to x: (65) y: (-50)\n\nwhen flag clicked\nforever\n    if <(stage #) = [14]> then\n        if <touching (hitbox v)?> then\n            repeat until <<not <touching (hitbox v)?>> or <not <(stage #) = [14]>>>\n                set [text v] to [true]\n            end\n        end\n        set [text v] to [false]\n    end\nend\n\nwhen I receive [investigate the chest v]\nwait (1) seconds\nswitch costume to (crowned v)\ngo to x: (65) y: (-50)\n\nwhen flag clicked\nforever\n    if <<< (game) contains [cutscene]?> or <(costume [name v]) < [14]>> or <(stage #) = [14]>> then\n        show\n    else\n        hide\n    end\nend\n\nwhen I receive [chest appear! v]\nif <not <key (s v) pressed?>> then\n    repeat (10)\n        wait (0.09) seconds\n        change y by (1)\n        change x by (10)\n        wait (0.09) seconds\n        change y by (-1)\n        change x by (-10)\n    end\nend\n\n@CHEST\n\nwhen I receive [chest appear! v]\nglide (2) secs to x: (0) y: (10)\nset [chest appeared? v] to [true]\n\nwhen flag clicked\nwait (1) seconds\nwait until <(chest appeared?) = [true]>\nforever\n    glide (0.9) secs to x: (0) y: (-10)\n    glide (0.9) secs to x: (0) y: (10)\nend\n\nwhen flag clicked\nset [chest dialogue v] to [no]\nwait (1) seconds\nwait until <(stage #) = [14]>\nforever\n    if <touching (mouse-pointer v)?> then\n        repeat until <<not <touching (mouse-pointer v)?>> or <(chest) = [opened]>>\n            set [chest dialogue v] to [yes]\n            set [brightness v] effect to (10)\n            set size to (110) %\n            if <mouse down?> then\n                if <[inventory v] contains [key]?> then\n                    broadcast (open chest! v) and wait\n                    set [chest dialogue v] to [no]\n                    delete (item # of [key] in [inventory v]) of [inventory v]\n                    hide\n                end\n            end\n        end\n        set [chest dialogue v] to [no]\n        set [brightness v] effect to (0)\n        set size to (100) %\n    end\nend\n\nwhen I receive [open chest! v]\nset [chest v] to [opened]\nrepeat (20)\n    change [ghost v] effect by (10)\nend\nhide\n\nadd [key] to [inventory v]\n\nwhen flag clicked\nset [chest appeared? v] to [false]\nset [ghost v] effect to (100)\ngo to x: (0) y: (-250)\nswitch costume to (closed chest v)\n\nwhen I receive [chest appear! v]\nshow\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\nadd [key] to [inventory v]\n\nwhen I receive [chest appear! v]\nglide (2) secs to x: (0) y: (10)\nset [chest appeared? v] to [true]\n\nwhen flag clicked\nwait (1) seconds\nwait until <<key (s v) pressed?> and <(game) = [ending cutscene]>>\nwait (1) seconds\nshow\nset [ghost v] effect to (0)\nglide (2) secs to x: (0) y: (10)\nset [chest appeared? v] to [true]\n\n@CHEST LIGHT\n\nwhen I receive [open chest! v]\nrepeat (10)\n    change [ghost v] effect by (10)\nend\n\nwhen flag clicked\nwait (1) seconds\nwait until <<key (s v) pressed?> and <(game) = [ending cutscene]>>\nwait (1) seconds\nset [ghost v] effect to (0)\n\nwhen flag clicked\nset [ghost v] effect to (100)\nforever\n    go to (chest v)\nend\n\nwhen I receive [chest appear! v]\nrepeat (10)\n    change [ghost v] effect by (-10)\nend\n\n@THUMBNAIL\n\nwhen flag clicked\nswitch costume to (official v)\nforever\n    go to [front v] layer\n    set [ghost v] effect to (100)\nend\n\n