knighthood || a scrolling platformer #games

Instructions: Hope you enjoy!\nThe levels are quite hard, but that makes it more interesting!\nI made this in two weeks time!\n

@Stage\n\nwhen [space v] key pressed\n\nset [mouse v] to (join ((scroll x) + (mouse x)) (join [,] ((scroll y) + (mouse y))))\nshow variable [mouse v]\n\nwhen I receive [reset v]\nreset timer\nset [start timer v] to [false]\nwait until <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>\nset [start timer v] to [true]\nreset timer\n\nwhen I receive [tick v]\nif <not <(levels_map) = [true]>> then\n    if <(start timer) = [true]> then\n        set [timer v] to (round (timer))\n    end\nend\n\nwhen I receive [play game v]\nset [timer v] to [0]\n\nwhen I receive [lose v]\nset [timer v] to [0]\n\nwhen flag clicked\nforever\n    if <(levels_map) = [false]> then\n        set volume to (0) %\n    end\n    if <(levels_map) = [true]> then\n        if <(music?) = [false]> then\n            set volume to (0) %\n        else\n            set volume to (70) %\n        end\n    end\nend\n\nwhen flag clicked\nwait (15) seconds\nforever\n    if <(levels_map) = [true]> then\n        play sound [Mushroom Theme v] until done\n    end\nend\n\n@blank\n\n@platform\n\nwhen I receive [green flag v]\nhide\n\nwhen flag clicked\ngo to [back v] layer\nhide\n\nwhen I receive [tick v]\nposition_platform ((x) - (scroll x)) (((y) - (100)) - (scroll y))\n\nwhen I receive [set up v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at x: [450] y: [0]\n    Clone at x: [620] y: [0]\n    Clone at x: [820] y: [150]\n    Clone at x: [940] y: [100]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x: [580] y: [0]\n        Clone at x: [700] y: [0]\n        Clone at x: [700] y: [0]\n        Clone at x: [0] y: [580]\n        Clone at x: [750] y: [0]\n        Clone at x: [600] y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at x: [700] y: [15]\n            Clone at x: [500] y: [0]\n            Clone at x: [700] y: [0]\n            Clone at x: [860] y: [0]\n            Clone at x: [860] y: [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (real 3 1 v)\n                Clone at x: [470] y: [30]\n                Clone at x: [570] y: [50]\n                Clone at x: [600] y: [400]\n                Clone at x: [800] y: [0]\n            end\n        end\n    end\nend\n\ndefine position_platform (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [levels_map v]\nhide\ndelete this clone\n\nwhen I receive [win v]\nwait (2) seconds\nhide\ndelete this clone\n\n@play-instructions\n\nwhen I start as a clone\nshow\nset [ghost v] effect to (0)\nif <(clone levels 2 #) = [1]> then\n    switch costume to (2 v)\n    go to x: (-100) y: (0)\nelse\n    if <(clone levels 2 #) = [2]> then\n        switch costume to (1 v)\n        go to x: (100) y: (0)\n    else\n        if <(clone levels 2 #) = [3]> then\n            switch costume to (knighthood v)\n            set size to (90) %\n            go to x: (0) y: (0)\n        end\n    end\nend\n\nwhen I start as a clone\nforever\n    if <(costume [number v]) = [1]> then\n        if <<touching (mouse-pointer v)?> and <mouse down?>> then\n            broadcast (levels_map v)\n            delete this clone\n        end\n    else\n        if <(costume [number v]) = [2]> then\n            if <<touching (mouse-pointer v)?> and <mouse down?>> then\n                broadcast (instructions v)\n            end\n        end\n    end\n    if <<(costume [number v]) = [1]> or <(costume [number v]) = [2]>> then\n        set y to (([cos v] of ((intro3) * (2)) ) * (20))\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (20)\n        else\n            set [brightness v] effect to (0)\n        end\n    else\n        change size by ([sin v] of ((10) * (intro3)) )\n    end\n    change [intro3 v] by (1)\nend\n\nwhen I receive [play-instructions v]\npoint in direction (90)\nset [intro3 v] to [0]\nset [clone levels 2 # v] to [0]\nrepeat (3)\n    change [clone levels 2 # v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [levels_map v]\ndelete this clone\n\nwhen I receive [play-instructions v]\ndelete this clone\n\n@player\n\nwhen I receive [start game v]\nbroadcast (Green Flag v) and wait\n\nwhen I receive [play game v]\nforever\n    if <not <(LEVEL) = [5]>> then\n        if <not <(levels_map) = [true]>> then\n            broadcast (reset v)\n            set [reset v] to [true]\n            broadcast (set up v) and wait\n            game on\n            repeat until <(EXIT) > []>\n                if <not <(levels_map) = [true]>> then\n                    tick\n                    broadcast (tick v) and wait\n                end\n            end\n            if <(EXIT) = [win]> then\n                broadcast (win v)\n                win\n            else\n                start sound [Crunch v]\n                broadcast (lose v)\n                Die\n            end\n        end\n    end\nend\n\ndefine game on\npoint in direction (90)\nset [sx v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\nset [in air 2 v] to [0]\nset [x v] to [-150]\nset [y v] to [50]\nset [sy v] to [0]\nset [exit v] to []\nswitch costume to (player v)\nset size to (100) %\nset [ghost v] effect to (100)\nshow\n\nwhen flag clicked\nset [level v] to [0]\nset [levels_unblocked v] to [1]\nhide\ngo to [back v] layer\ngo [forward v] (1) layers\nforever\n    if <(LEVEL) = [5]> then\n        hide\n    end\nend\n\ndefine tick\nif <not <(LEVEL) = [5]>> then\n    if <<key (up arrow v) pressed?> or <<key (right arrow v) pressed?> or <key (left arrow v) pressed?>>> then\n        if <key (left arrow v) pressed?> then\n            switch costume to (left v)\n            change [sx v] by (-2)\n        end\n        if <key (right arrow v) pressed?> then\n            switch costume to (player v)\n            change [sx v] by (2)\n        end\n        if <key (up arrow v) pressed?> then\n            if <not <<key (right arrow v) pressed?> or <key (left arrow v) pressed?>>> then\n                switch costume to (middle v)\n            end\n            if <(in air 2) < [4]> then\n                set [sy v] to [16]\n            end\n        end\n    else\n        switch costume to (middle v)\n    end\n    set [sx v] to ((sx) * (0.8))\n    if <([abs v] of (sx) ) > [0.9]> then\n        change player x by (round (sx))\n    end\n    change [sy v] by (-2)\n    change player y by (sy)\n    test die\n    set [scroll x v] to (x)\n    change [scroll y v] by (round (((y) - (scroll y)) / (5)))\n    if <(scroll x) < [-150]> then\n        set [scroll x v] to [-150]\n    end\n    if <(scroll y) < [0]> then\n        set [scroll y v] to [0]\n    end\n    position\n    if <(y) < [-180]> then\n        set [exit v] to [die]\n    end\nend\n\ndefine change player y by (sy)\nchange [y v] by (sy)\nchange [in air 2 v] by (1)\nposition\nrepeat until <not <touching (platform v)?>>\n    if <([abs v] of (sy) ) = (sy)> then\n        set [sy v] to [0]\n        change [y v] by (-2)\n    else\n        change [y v] by (2)\n        set [in air 2 v] to [0]\n        set [in air 2 v] to [0]\n        set [sy v] to [0]\n        if <[-7] > (sy)> then\n            start sound [Land v]\n        end\n    end\n    position\nend\n\ndefine position\ngo to x: ((x) - (scroll x)) y: ((y) - (scroll y))\n\ndefine change player x by (sx)\nchange [x v] by (sx)\nposition\nif <touching (platform v)?> then\n    repeat (12)\n        change [y v] by (1)\n        position\n        if <not <touching (platform v)?>> then\n            stop [this script v]\n        end\n    end\n    change [y v] by (-12)\n    repeat until <not <touching (platform v)?>>\n        if <(sx) > [0]> then\n            change [x v] by (-1)\n        else\n            change [x v] by (1)\n        end\n        position\n    end\nend\n\ndefine Die\nset [exit v] to []\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\ndefine test die\nif <<touching (danger v)?> or <touching (enemies v)?>> then\n    set [exit v] to [die]\nend\n\ndefine win\nrepeat (50)\n    point towards (portal v)\n    turn right (65) degrees\n    move ((distance to [portal v]) / (2)) steps\nend\nhide\nbroadcast (levels_map v)\nif <(LEVEL) = (levels_unblocked)> then\n    change [levels_unblocked v] by (1)\n    change [coins v] by (18)\nend\nwait (1) seconds\n\n@Levels\n\ndefine Smooth Glide x: (x) y: (y) speed: (speed)\nrepeat until <<(round (x position)) = (round (x))> and <(round (y position)) = (round (y))>>\n    change x by (((round (x)) - (round (x position))) / (speed))\n    change y by (((round (y)) - (round (y position))) / (speed))\nend\ngo to x: (x) y: (y)\n\nwhen I receive [levels_map v]\nclone_levels_map\n\ndefine clone_levels_map\npoint in direction (90)\nset [clone levels # v] to [0]\nswitch costume to (1 v)\nrepeat (6)\n    change [clone levels # v] by (1)\n    create clone of (_myself_ v)\n    next costume\nend\n\nwhen I receive [start game v]\nbroadcast (play-instructions v)\n\nwhen flag clicked\nset [intro3 v] to [0]\nset [clone levels # v] to [0]\nhide\n\nwhen I start as a clone\nshow\ngo to [front v] layer\nset size to (100) %\nif <(clone levels #) = [1]> then\n    go to x: (-300) y: (-20)\n    Smooth Glide x: (-190) y: (-20) speed: (7)\nelse\n    if <(clone levels #) = [2]> then\n        set [ghost v] effect to (50)\n        go to x: (-300) y: (-20)\n        Smooth Glide x: (-95) y: (-20) speed: (7)\n    else\n        if <(clone levels #) = [3]> then\n            set [ghost v] effect to (50)\n            go to x: (-300) y: (-20)\n            Smooth Glide x: (0) y: (-20) speed: (7)\n        else\n            if <(clone levels #) = [4]> then\n                set [ghost v] effect to (50)\n                go to x: (-300) y: (-20)\n                Smooth Glide x: (95) y: (-20) speed: (7)\n            else\n                if <(clone levels #) = [5]> then\n                    set [ghost v] effect to (50)\n                    go to x: (-300) y: (-20)\n                    Smooth Glide x: (190) y: (-20) speed: (7)\n                else\n                    if <(clone levels #) = [6]> then\n                        go to x: (0) y: (300)\n                        Smooth Glide x: (0) y: (0) speed: (7)\n                        switch costume to (level select v)\n                    end\n                end\n            end\n        end\n    end\nend\nforever\n    if <not <(set home 2 to true) = [true]>> then\n        if <<<(costume [number v]) = [1]> or <(costume [number v]) > [1]>> and <<(costume [number v]) = [5]> or <(costume [number v]) < [5]>>> then\n            point in direction ((90) + (([cos v] of (intro3) ) * (10)))\n        else\n            change size by ((2) * ([sin v] of (intro3) ))\n        end\n        change [intro3 v] by (2)\n    end\nend\n\nwhen I start as a clone\nforever\n    if <(costume [number v]) = [1]> then\n        if <touching (mouse-pointer v)?> then\n            set [level v] to [1]\n            if <mouse down?> then\n                broadcast (Play game v) and wait\n            end\n        end\n    else\n        if <(costume [number v]) = [2]> then\n            if <(levels_unblocked) < [2]> then\n                set [ghost v] effect to (50)\n            else\n                set [ghost v] effect to (0)\n                if <touching (mouse-pointer v)?> then\n                    set [level v] to [2]\n                    if <mouse down?> then\n                        broadcast (Play game v) and wait\n                    end\n                end\n            end\n        else\n            if <(costume [number v]) = [3]> then\n                if <(levels_unblocked) < [3]> then\n                    set [ghost v] effect to (50)\n                else\n                    set [ghost v] effect to (0)\n                    if <touching (mouse-pointer v)?> then\n                        set [level v] to [3]\n                        if <mouse down?> then\n                            broadcast (Play game v) and wait\n                        end\n                    end\n                end\n            else\n                if <(costume [number v]) = [4]> then\n                    if <(levels_unblocked) < [4]> then\n                        set [ghost v] effect to (50)\n                    else\n                        set [ghost v] effect to (0)\n                        if <touching (mouse-pointer v)?> then\n                            set [level v] to [4]\n                            if <mouse down?> then\n                                broadcast (Play game v) and wait\n                            end\n                        end\n                    end\n                else\n                    if <(costume [number v]) = [5]> then\n                        if <(levels_unblocked) < [5]> then\n                            set [ghost v] effect to (50)\n                        else\n                            set [ghost v] effect to (0)\n                            if <touching (mouse-pointer v)?> then\n                                set [level v] to [5]\n                                set [clone options # v] to [1]\n                                if <mouse down?> then\n                                    broadcast (level 5 v)\n                                    broadcast (Play game v) and wait\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    if <<<(costume [number v]) = [1]> or <(costume [number v]) > [1]>> and <<(costume [number v]) = [5]> or <(costume [number v]) < [5]>>> then\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (20)\n        else\n            set [brightness v] effect to (0)\n        end\n    else\n        set [brightness v] effect to (0)\n    end\nend\n\nwhen I receive [play game v]\nhide\ndelete this clone\n\nwhen I receive [levels_map v]\nhide\ndelete this clone\n\nwhen I receive [play-instructions v]\nhide\ndelete this clone\n\nwhen I receive [close shop v]\nclone_levels_map\n\nwhen I receive [open shop v]\nhide\ndelete this clone\n\n@loading\n\nwhen I receive [play game v]\ngo to x: (0) y: (0)\nset [ghost v] effect to (0)\ngo to [front v] layer\nswitch costume to (costume1 v)\nshow\nrepeat (2)\n    wait (0.5) seconds\n    next costume\nend\nrepeat (20)\n    change [ghost v] effect by (5)\nend\nhide\n\nwhen flag clicked\nhide\n\n@backround\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (castle clipart v)\nhide\nforever\n    go to [back v] layer\nend\n\nwhen I receive [start game v]\nshow\n\n@costumes\n\nwhen I receive [lose v]\nif <not <(home) = [true]>> then\n    repeat (5)\n        hide\n        wait (0.1) seconds\n        show\n        wait (0.1) seconds\n    end\n    hide\n    wait (0.5) seconds\nend\n\nwhen I receive [win v]\nrepeat (50)\n    point towards (portal v)\n    turn right (65) degrees\n    move ((distance to [portal v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (-2)\nend\nhide\n\ndefine set costume\nif <not <(in air 2) < [4]>> then\n    if <(sx) > [0.1]> then\n        point in direction (90)\n    else\n        if <(sx) < [-0.1]> then\n            point in direction (-90)\n        end\n    end\n    if <(sy) > [0]> then\n        switch costume to (player16 v)\n    else\n        switch costume to (player17 v)\n    end\nelse\n    if <(sx) > [0.1]> then\n        point in direction (90)\n        switch costume to ((((timer) * (10)) mod (11)) + (2))\n    else\n        if <(sx) < [-0.1]> then\n            point in direction (-90)\n            switch costume to ((((timer) * (10)) mod (11)) + (2))\n        else\n            switch costume to (player v)\n        end\n    end\nend\n\nwhen I receive [tick v]\nset x to ([x position v] of [player v])\nset y to (([y position v] of [player v]) + (8))\npoint towards (player v)\nset costume\n\nwhen flag clicked\ngo to [front v] layer\nhide\nforever\n    if <(LEVEL) = [5]> then\n        hide\n    end\nend\n\nwhen I receive [play game v]\nset [ghost v] effect to (0)\nset size to (100) %\nshow\n\nwhen I receive [levels_map v]\nhide\n\nwhen I receive [reset v]\nshow\n\n@portal\n\nwhen I receive [green flag v]\nhide\n\nwhen flag clicked\ngo to [back v] layer\nhide\n\nwhen I receive [tick v]\nposition_platform ((x) - (scroll x)) ((y) - (scroll y))\nif <(costume [number v]) = [2]> then\n    if <touching (player v)?> then\n        start sound [Ta Da v]\n        set [exit v] to [win]\n    end\nend\n\nwhen I receive [set up v]\nhide\ngo to [back v] layer\nset [y v] to [0]\nset [x v] to [0]\nset [collected: v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (closed v)\n    Clone at x: [3264] y: [254]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (closed v)\n        Clone at x: [3581] y: [625]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (closed v)\n            Clone at x: [3639] y: [4]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (closed v)\n                Clone at x: [2890] y: [491]\n            end\n        end\n    end\nend\n\ndefine position_platform (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\nhide\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\n\nwhen I receive [open portal v]\nswitch costume to (opened v)\n\nwhen I receive [levels_map v]\nhide\ndelete this clone\n\nwhen I receive [win v]\nwait (2) seconds\nhide\ndelete this clone\n\n@collectables\n\nwhen I receive [green flag v]\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [tick v]\nposition_platform ((x) - (scroll x)) ((y) - (scroll y))\nif <touching (player v)?> then\n    start sound [collect v]\n    change [collected: v] by (1)\n    if <(Collected:) = (All collectables)> then\n        broadcast (open portal v)\n    end\n    delete this clone\nend\nnext costume\n\nwhen I receive [set up v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nset [collected: v] to [0]\nset [all collectables v] to [0]\nif <(LEVEL) = [1]> then\n    Clone at x: [50] y: [43]\n    Clone at x: [300] y: [100]\n    Clone at x: [599] y: [100]\n    Clone at x: [387] y: [-14]\n    Clone at x: [1443] y: [47]\n    Clone at x: [1634] y: [208]\n    Clone at x: [2265] y: [382]\n    Clone at x: [2685] y: [278]\n    Clone at x: [2953] y: [293]\nelse\n    if <(LEVEL) = [2]> then\n        Clone at x: [-41] y: [147]\n        Clone at x: [370] y: [180]\n        Clone at x: [989] y: [0]\n        Clone at x: [1771] y: [580]\n        Clone at x: [1227] y: [114]\n        Clone at x: [2189] y: [604]\n        Clone at x: [2567] y: [611]\n        Clone at x: [2965] y: [619]\n        Clone at x: [3346] y: [675]\n    else\n        if <(LEVEL) = [3]> then\n            Clone at x: [-104] y: [37]\n            Clone at x: [168] y: [4]\n            Clone at x: [744] y: [14]\n            Clone at x: [1263] y: [3]\n            Clone at x: [1776] y: [-82]\n            Clone at x: [1895] y: [-26]\n            Clone at x: [2335] y: [85]\n            Clone at x: [3159] y: [90]\n            Clone at x: [3517] y: [-2]\n        else\n            if <(LEVEL) = [4]> then\n                Clone at x: [-18] y: [-1]\n                Clone at x: [618] y: [-9]\n                Clone at x: [807] y: [59]\n                Clone at x: [1058] y: [257]\n                Clone at x: [1650] y: [401]\n                Clone at x: [1788] y: [578]\n                Clone at x: [1688] y: [401]\n                Clone at x: [2102] y: [421]\n                Clone at x: [2722] y: [427]\n            end\n        end\n    end\nend\nset [x v] to [-99999]\n\ndefine position_platform (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\nelse\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\nset [x v] to (x)\nset [y v] to (y)\nchange [all collectables v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I receive [levels_map v]\ndelete this clone\n\n@danger\n\nwhen I receive [green flag v]\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [tick v]\nposition_platform ((x) - (scroll x)) ((y) - (scroll y))\n\nwhen I receive [set up v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at x: [450] y: [0]\n    Clone at x: [660] y: [0]\n    Clone at x: [780] y: [150]\n    Clone at x: [860] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x: [580] y: [0]\n        Clone at x: [0] y: [0]\n        Clone at x: [700] y: [0]\n        Clone at x: [700] y: [0]\n        Clone at x: [0] y: [580]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at x: [700] y: [-23]\n            Clone at x: [700] y: [-80]\n            Clone at x: [0] y: [0]\n            Clone at x: [900] y: [0]\n            Clone at x: [660] y: [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (real 3 1 v)\n                Clone at x: [470] y: [30]\n                Clone at x: [570] y: [50]\n                Clone at x: [600] y: [40]\n            end\n        end\n    end\nend\n\ndefine position_platform (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\n    set [show detector v] to [true]\nelse\n    hide\n    set [show detector v] to [false]\nend\n\nwhen I receive [reset v]\ngo to [back v] layer\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I start as a clone\nforever\n    if <<(costume [number v]) = [1]> or <(costume [number v]) = [7]>> then\n        fire\n    else\n        if <<<<(costume [number v]) = [12]> or <(costume [number v]) = [13]>> or <(costume [number v]) = [15]>> or <(costume [number v]) = [16]>> then\n            poison\n        end\n        if <(costume [number v]) = [18]> then\n            poison\n        end\n    end\n    if <<(costume [number v]) = [3]> or <(costume [number v]) = [14]>> then\n        flying swords\n    end\nend\n\ndefine fire\nrepeat (15)\n    change [y v] by (5)\nend\nwait (0.5) seconds\nrepeat (75)\n    change [y v] by (-1)\nend\n\ndefine flying swords\nset [danger move v] to [0]\nset [y v] to [0]\nshow\nif <(show detector) = [true]> then\n    start sound [air v]\nend\nrepeat until <(y position) > [400]>\n    change [y v] by (danger move)\n    change [danger move v] by (0.9)\nend\nhide\n\nwhen I receive [levels_map v]\nhide\ndelete this clone\n\nwhen I receive [win v]\nwait (2) seconds\nhide\ndelete this clone\n\ndefine poison\nset [y v] to [0]\nrepeat (4)\n    change [y v] by (5)\nend\nrepeat (3)\n    change [y v] by (4)\nend\nrepeat (2)\n    change [y v] by (3)\nend\nchange [y v] by (2)\nwait (0.5) seconds\nrepeat (80)\n    change [y v] by (-0.5)\nend\n\n@Sprite5\n\nwhen I receive [play game v]\nif <not <(LEVEL) = [5]>> then\n    go to [back v] layer\n    show\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (30)\nhide\n\nwhen I receive [levels_map v]\ngo to [back v] layer\nhide\n\n@Sprite6\n\nwhen flag clicked\ngo to [front v] layer\nset size to (100) %\ngo to x: (0) y: (0)\nswitch costume to (costume1 v)\nhide\n\nwhen I receive [levels_map v]\nhide\ndelete this clone\n\nwhen I receive [play game v]\nif <not <(LEVEL) = [5]>> then\n    create clone of (_myself_ v)\n    show\nend\n\nwhen I start as a clone\nset size to (80) %\nswitch costume to (0 v)\nshow\nforever\n    if <not <(LEVEL) = [5]>> then\n        go to x: (30) y: (154)\n        switch costume to (letter (1) of (Collected:))\n    else\n        hide\n        delete this clone\n    end\nend\n\nwhen I start as a clone\nforever\n    repeat (10)\n        change size by (1)\n    end\n    repeat (10)\n        change size by (-1)\n    end\nend\n\n@Sprite7\n\nwhen I receive [timer v]\ngo to x: (130) y: (153)\nforever\n    if <not <(LEVEL) = [5]>> then\n        if <<not <(home) = [true]>> and <not <(set home 2 to true) = [true]>>> then\n            switch costume to (letter (1) of (timer))\n            if <<(length of (timer)) = [1]> or <(length of (timer)) > [1]>> then\n                show\n            else\n                hide\n            end\n        else\n            hide\n        end\n    else\n        hide\n    end\nend\n\nif <(reset) = [true]> then\n    stop [this script v]\nend\n\nwhen I receive [levels_map v]\nhide\n\nwhen I receive [play game v]\nset [levels_map v] to [false]\nif <not <(LEVEL) = [5]>> then\n    show\nend\n\nwhen flag clicked\ngo to [front v] layer\nhide\n\nwhen I receive [reset v]\nhide\nwait until <<key (left arrow v) pressed?> or <key (right arrow v) pressed?>>\nset [reset v] to [false]\nif <not <(levels_map) = [true]>> then\n    broadcast (timer v)\nend\n\nwhen I receive [levels_map v]\nset [levels_map v] to [true]\n\nwhen I receive [timer v]\nwait (1) seconds\nforever\n    set size to (80) %\n    repeat (10)\n        change size by (1)\n    end\n    repeat (10)\n        change size by (-1)\n    end\nend\n\nwhen I receive [start game v]\nset [levels_map v] to [true]\n\nwhen I receive [level 5 v]\nhide\n\n@Sprite8\n\nwhen flag clicked\ngo to [front v] layer\nhide\n\nwhen I receive [levels_map v]\nhide\n\nwhen I receive [play game v]\nif <not <(LEVEL) = [5]>> then\n    show\nend\n\nwhen I receive [timer v]\ngo to x: (162) y: (153)\nforever\n    if <not <(LEVEL) = [5]>> then\n        if <<not <(home) = [true]>> and <not <(set home 2 to true) = [true]>>> then\n            switch costume to (letter (2) of (timer))\n            if <<(length of (timer)) = [2]> or <(length of (timer)) > [2]>> then\n                show\n            else\n                hide\n            end\n        else\n            hide\n        end\n    else\n        hide\n    end\nend\n\nwhen I receive [reset v]\nhide\n\nwhen I receive [timer v]\nforever\n    set size to (80) %\n    repeat (10)\n        change size by (1)\n    end\n    repeat (10)\n        change size by (-1)\n    end\nend\n\nwhen I receive [level 5 v]\nhide\n\n@Sprite9\n\nwhen I receive [timer v]\nforever\n    if <not <(LEVEL) = [5]>> then\n        if <<not <(home) = [true]>> and <not <(set home 2 to true) = [true]>>> then\n            go to x: (194) y: (153)\n            switch costume to (letter (3) of (timer))\n            if <<(length of (timer)) = [3]> or <(length of (timer)) > [3]>> then\n                show\n            else\n                hide\n            end\n        else\n            hide\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to [front v] layer\nhide\n\nwhen I receive [levels_map v]\nhide\n\nwhen I receive [play game v]\nif <not <(LEVEL) = [5]>> then\n    show\nend\n\nwhen I receive [reset v]\nhide\n\nif <(reset) = [true]> then\n    stop [this script v]\nend\n\nwhen I receive [timer v]\nwait (1) seconds\nforever\n    set size to (80) %\n    repeat (10)\n        change size by (1)\n    end\n    repeat (10)\n        change size by (-1)\n    end\nend\n\nwhen I receive [level 5 v]\nhide\n\n@Sprite10\n\nwhen I receive [timer v]\nforever\n    set size to (80) %\n    repeat (10)\n        change size by (1)\n    end\n    repeat (10)\n        change size by (-1)\n    end\nend\n\nwhen I receive [timer v]\nforever\n    if <not <(LEVEL) = [5]>> then\n        if <<not <(home) = [true]>> and <not <(set home 2 to true) = [true]>>> then\n            go to x: (226) y: (153)\n            switch costume to (letter (4) of (timer))\n            if <<(length of (timer)) = [4]> or <(length of (timer)) > [4]>> then\n                show\n            else\n                hide\n            end\n        else\n            hide\n        end\n    else\n        hide\n    end\nend\n\nwhen flag clicked\ngo to [front v] layer\nhide\n\nwhen I receive [levels_map v]\nhide\n\nwhen I receive [play game v]\nif <not <(LEVEL) = [5]>> then\n    show\nend\n\nwhen I receive [reset v]\nhide\n\nwhen I receive [level 5 v]\nhide\n\n@Sprite1\n\ndefine Smooth Glide x: (x) y: (y) speed: (speed)\nrepeat until <<(round (x position)) = (round (x))> and <(round (y position)) = (round (y))>>\n    change x by (((round (x)) - (round (x position))) / (speed))\n    change y by (((round (y)) - (round (y position))) / (speed))\nend\ngo to x: (x) y: (y)\n\nwhen I receive [win v]\nswitch costume to (LEVEL)\nwait (2) seconds\nshow\ngo to x: (0) y: (-300)\nSmooth Glide x: (0) y: (0) speed: (4)\n\nwhen flag clicked\ngo to [front v] layer\nhide\nforever\n    if <(set home 2 to true) = [true]> then\n        go to [back v] layer\n    else\n        go to [front v] layer\n    end\nend\n\nwhen I receive [play game v]\nhide\n\n@options\n\nwhen I receive [play game v]\nif <not <(LEVEL) = [5]>> then\n    set [clone options # v] to [1]\n    set [home v] to [false]\n    switch costume to (back v)\n    repeat (4)\n        create clone of (_myself_ v)\n        next costume\n    end\nelse\n    delete this clone\nend\n\nwhen flag clicked\nset [music? v] to [true]\nset [set home 2 to true v] to [false]\nset [clone options # v] to [0]\nset [home v] to [false]\nhide\n\nwhen I start as a clone\nif <(clone options #) = [1]> then\n    show\n    if <(costume [number v]) = [1]> then\n        go to x: (-215) y: (155)\n    else\n        if <(costume [number v]) = [2]> then\n            go to x: (-165) y: (155)\n        else\n            go to x: (-115) y: (155)\n        end\n    end\n    forever\n        if <(costume [number v]) = [1]> then\n            if <touching (mouse-pointer v)?> then\n                set [brightness v] effect to (20)\n                if <mouse down?> then\n                    wait until <<not <mouse down?>> or <not <touching (mouse-pointer v)?>>>\n                    broadcast (levels_map v)\n                    set [home v] to [true]\n                end\n            else\n                set [brightness v] effect to (0)\n            end\n        else\n            if <(costume [number v]) = [2]> then\n                if <touching (mouse-pointer v)?> then\n                    set [brightness v] effect to (20)\n                    if <mouse down?> then\n                        set [exit v] to [die]\n                        wait until <<not <mouse down?>> or <not <touching (mouse-pointer v)?>>>\n                    end\n                else\n                    set [brightness v] effect to (0)\n                end\n            else\n                if <touching (mouse-pointer v)?> then\n                    set [brightness v] effect to (20)\n                    if <(costume [number v]) = [4]> then\n                        if <mouse down?> then\n                            switch costume to (music2 v)\n                            set [music? v] to [false]\n                        end\n                        wait until <<not <mouse down?>> or <not <touching (mouse-pointer v)?>>>\n                    else\n                        if <(costume [number v]) = [5]> then\n                            if <mouse down?> then\n                                switch costume to (music v)\n                                set [music? v] to [true]\n                            end\n                            wait until <<not <mouse down?>> or <not <touching (mouse-pointer v)?>>>\n                        end\n                    end\n                else\n                    set [brightness v] effect to (0)\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [levels_map v]\nwait (0.1) seconds\nset [clone options # v] to [0]\nset [set home 2 to true v] to [false]\nswitch costume to (home v)\ncreate clone of (_myself_ v)\n\nwhen I receive [play game v]\ndelete this clone\n\nwhen I start as a clone\nif <(clone options #) = [0]> then\n    show\n    forever\n        if <(costume [number v]) = [3]> then\n            if <touching (mouse-pointer v)?> then\n                set [brightness v] effect to (20)\n                if <mouse down?> then\n                    broadcast (play-instructions v)\n                    set [set home 2 to true v] to [true]\n                    delete this clone\n                end\n            else\n                set [brightness v] effect to (0)\n            end\n        end\n    end\nelse\n    if <(costume [number v]) = [3]> then\n        hide\n    end\nend\n\nwhen I receive [levels_map v]\ndelete this clone\n\nwhen I start as a clone\nforever\n    if <<(costume [number v]) = [4]> or <(costume [number v]) = [5]>> then\n        if <(music?) = [true]> then\n            switch costume to (music v)\n        else\n            switch costume to (music2 v)\n        end\n    end\nend\n\n@decoration\n\nwhen I receive [green flag v]\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [tick v]\nposition_platform ((x) - (scroll x)) ((y) - (scroll y))\n\nwhen I receive [set up v]\ngo to [back v] layer\nset [ghost v] effect to (10)\nhide\nset [y v] to [0]\nset [x v] to [0]\nif <(LEVEL) = [1]> then\n    switch costume to (level 1 1 v)\n    Clone at x: [450] y: [0]\n    Clone at x: [620] y: [0]\n    Clone at x: [820] y: [150]\n    Clone at x: [820] y: [0]\nelse\n    if <(LEVEL) = [2]> then\n        switch costume to (level 2 1 v)\n        Clone at x: [580] y: [0]\n        Clone at x: [700] y: [0]\n        Clone at x: [700] y: [0]\n        Clone at x: [0] y: [580]\n        Clone at x: [750] y: [0]\n        Clone at x: [600] y: [0]\n    else\n        if <(LEVEL) = [3]> then\n            switch costume to (level 3 1 v)\n            Clone at x: [700] y: [15]\n            Clone at x: [500] y: [0]\n            Clone at x: [700] y: [0]\n            Clone at x: [860] y: [0]\n            Clone at x: [860] y: [0]\n        else\n            if <(LEVEL) = [4]> then\n                switch costume to (real 3 1 v)\n                Clone at x: [470] y: [30]\n                Clone at x: [570] y: [50]\n                Clone at x: [600] y: [400]\n            else\n            end\n        end\n    end\nend\n\ndefine position_platform (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    if <not <(LEVEL) = [5]>> then\n        show\n    end\nelse\n    hide\nend\n\nwhen I receive [reset v]\ngo to [back v] layer\ndelete this clone\n\ndefine Clone at x: (x) y: (y)\ncreate clone of (_myself_ v)\nchange [x v] by (x)\nchange [y v] by (y)\nnext costume\n\nwhen I receive [levels_map v]\nhide\ndelete this clone\n\nwhen I receive [win v]\nwait (2) seconds\nhide\ndelete this clone\n\nwhen I receive [level 5 v]\nstop [other scripts in sprite v]\n\nwhen I receive [level 5 v]\nforever\n    hide\n    delete this clone\nend\n\n@instructions\n\nwhen I receive [instructions v]\nset [instructions size v] to [14]\nshow\nrepeat (22)\n    change size by (instructions size)\n    change [instructions size v] by (-1)\nend\nrepeat (4)\n    change size by (instructions size)\n    change [instructions size v] by (1)\nend\nwait until <mouse down?>\nrepeat (20)\n    change size by (5)\n    change [ghost v] effect by (5)\nend\nhide\nset [ghost v] effect to (0)\nset size to (20) %\nset [instructions size v] to [14]\n\nwhen flag clicked\nset [instructions size v] to [14]\nset [ghost v] effect to (0)\nset size to (20) %\nhide\n\n@enemies\n\nwhen I receive [green flag v]\nhide\n\nwhen flag clicked\nhide\n\nwhen I receive [tick v]\nposition_platform ((x) - (scroll x)) ((y) - (scroll y))\n\nwhen I receive [set up v]\nhide\nset [y v] to [0]\nset [x v] to [0]\nset [enemy # v] to [0]\nif <(LEVEL) = [1]> then\n    set [type move \(enemies\) v] to [1]\n    Clone at x: [350] y: [-15] costume: [1]\n    set [type move \(enemies\) v] to [1]\n    Clone at x: [850] y: [-43] costume: [2]\nelse\n    if <(LEVEL) = [2]> then\n        set [type move \(enemies\) v] to [1]\n        Clone at x: [1280] y: [-67] costume: [1]\n        set [type move \(enemies\) v] to [1]\n        Clone at x: [1320] y: [-67] costume: [1]\n        set [type move \(enemies\) v] to [1]\n        Clone at x: [2512] y: [570] costume: [2]\n    else\n        if <(LEVEL) = [3]> then\n            set [type move \(enemies\) v] to [1]\n            Clone at x: [740] y: [-64] costume: [1]\n            set [type move \(enemies\) v] to [2]\n            Clone at x: [2353] y: [0] costume: [3]\n            set [type move \(enemies\) v] to [1]\n            Clone at x: [3258] y: [4] costume: [2]\n        else\n            if <(LEVEL) = [4]> then\n                set [type move \(enemies\) v] to [2]\n                Clone at x: [7] y: [0] costume: [3]\n                set [type move \(enemies\) v] to [2]\n                Clone at x: [227] y: [0] costume: [3]\n                set [type move \(enemies\) v] to [2]\n                Clone at x: [436] y: [0] costume: [3]\n                set [type move \(enemies\) v] to [1]\n                Clone at x: [2456] y: [307] costume: [1]\n            end\n        end\n    end\nend\nset [x v] to [-888]\n\ndefine position_platform (x) (y)\ngo to x: (x) y: (y)\nif <<(x) = (x position)> and <(y) = (y position)>> then\n    show\n    set [show v] to [true]\nelse\n    set [show v] to [false]\n    hide\nend\n\nwhen I receive [reset v]\ndelete this clone\n\ndefine Clone at x: (x) y: (y) costume: (costume)\nswitch costume to (costume)\nset [x v] to (x)\nset [y v] to (y)\nset [start y v] to (y)\nchange [enemy # v] by (1)\ncreate clone of (_myself_ v)\n\nwhen I receive [levels_map v]\ndelete this clone\n\nwhen I start as a clone\nif <(LEVEL) = [1]> then\n    if <(type move \(enemies\)) = [1]> then\n        if <(enemy #) = [1]> then\n            Enemies move (Type 1) [5]\n        else\n            Enemies move (Type 1) [10]\n        end\n    end\nelse\n    if <(LEVEL) = [2]> then\n        if <<(enemy #) = [1]> or <(enemy #) = [2]>> then\n            Enemies move (Type 1) [8]\n        else\n            Enemies move (Type 1) [10]\n        end\n    else\n        if <(LEVEL) = [3]> then\n            if <<(enemy #) = [1]> or <(enemy #) = [3]>> then\n                Enemies move (Type 1) [5]\n            else\n                go to [back v] layer\n                enemies move (type 2)\n            end\n        else\n            if <(LEVEL) = [4]> then\n                if <<(enemy #) = [1]> or <<(enemy #) = [2]> or <(enemy #) = [3]>>> then\n                    go to [back v] layer\n                    enemies move (type 2)\n                else\n                    Enemies move (Type 1) [5]\n                end\n            end\n        end\n    end\nend\n\ndefine Enemies move (Type 1) (x times)\nset rotation style [left-right v]\nforever\n    point in direction (90)\n    repeat (x times)\n        change [x v] by (1)\n    end\n    repeat ((x times) * (3))\n        change [x v] by (2)\n    end\n    repeat ((x times) * (6))\n        change [x v] by (4)\n    end\n    repeat ((x times) * (3))\n        change [x v] by (2)\n    end\n    repeat (x times)\n        change [x v] by (1)\n    end\n    point in direction (-90)\n    repeat (x times)\n        change [x v] by (-1)\n    end\n    repeat ((x times) * (3))\n        change [x v] by (-2)\n    end\n    repeat ((x times) * (6))\n        change [x v] by (-4)\n    end\n    repeat ((x times) * (3))\n        change [x v] by (-2)\n    end\n    repeat (x times)\n        change [x v] by (-1)\n    end\nend\n\nwhen I receive [win v]\ndelete this clone\n\ndefine enemies move (type 2)\nforever\n    set [y v] to (start y)\n    wait (0.7) seconds\n    show\n    set [move enemies v] to [25]\n    repeat (6)\n        change [y v] by (move enemies)\n        change [move enemies v] by (-1)\n    end\n    repeat until <(y) < ((start y) + (20))>\n        change [y v] by (move enemies)\n        change [move enemies v] by (-1)\n        if <(show) = [true]> then\n            start sound [splash v]\n        end\n    end\n    repeat until <(y) < (start y)>\n        change [y v] by (move enemies)\n        change [move enemies v] by (-1)\n    end\nend\n\n@shop\n\nwhen flag clicked\nset [shop's clone # v] to [0]\nhide\nswitch costume to (shop icon v)\ngo to x: (-130) y: (150)\n\nwhen I receive [play-instructions v]\nset [clone options # v] to [1]\nhide\n\nwhen I receive [levels_map v]\nforever\n    if <not <(clone options #) = [1]>> then\n        show\n        switch costume to (shop icon v)\n        if <(SHOP) = [false]> then\n            if <touching (mouse-pointer v)?> then\n                set [brightness v] effect to (20)\n                if <mouse down?> then\n                    broadcast (open shop v) and wait\n                    wait until <not <mouse down?>>\n                    set [shop v] to [true]\n                    set [shop's clone # v] to [1]\n                    create clone of (_myself_ v)\n                end\n            else\n                set [brightness v] effect to (0)\n            end\n        end\n    end\nend\n\nwhen I start as a clone\nif <(shop's clone #) = [1]> then\n    wait (1) seconds\n    switch costume to (exit v)\n    go to x: (0) y: (-135)\n    show\n    forever\n        go to [front v] layer\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (20)\n            if <mouse down?> then\n                broadcast (close shop v)\n                hide\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    end\nend\n\nwhen I receive [close shop v]\nif <(shop's clone #) = [1]> then\n    delete this clone\nend\n\nwhen flag clicked\nforever\n    if <(clone options #) = [1]> then\n        if <(levels_map) = [false]> then\n            hide\n        end\n    end\nend\n\nwhen I receive [level 5 v]\nhide\ndelete this clone\n\n@shop3\n\nwhen flag clicked\nhide\nswitch costume to (shop v)\nset [shop v] to [false]\nset [shop position v] to [0]\ngo to x: (19) y: (-300)\n\nwhen I receive [play game v]\ndelete this clone\n\nwhen I receive [play-instructions v]\ndelete this clone\n\nwhen I receive [open shop v]\nset [shop's clone # v] to [0]\nset [shop position v] to [18]\nshow\ngo to [front v] layer\nrepeat (45)\n    change [shop position v] by (-0.5)\n    change y by (shop position)\nend\nshow variable [coins v]\n\nwhen I receive [close shop v]\nset [shop v] to [false]\nset [shop position v] to [0]\nhide variable [coins v]\nrepeat (40)\n    go to [front v] layer\n    change [shop position v] by (-0.5)\n    change y by (shop position)\nend\nset [shop position v] to [0]\ngo to x: (19) y: (-300)\nhide\n\nwhen flag clicked\nhide variable [coins v]\n\nwhen I receive [play game v]\nset [shop v] to [false]\nset [shop position v] to [0]\nhide variable [coins v]\nrepeat (40)\n    change [shop position v] by (-0.5)\n    change y by (shop position)\nend\nset [shop position v] to [0]\ngo to x: (19) y: (-300)\nhide\n\n@hats\n\nwhen I receive [open shop v]\ngo to [front v] layer\nwait (1) seconds\ngo to [front v] layer\nset [shop's clone # v] to [0]\nrepeat (3)\n    change [shop's clone # v] by (1)\n    create clone of (_myself_ v)\nend\n\nwhen flag clicked\nset [purchased v] to []\nset [coins v] to [0]\nhide\nforever\n    if <key (1 v) pressed?> then\n        if < (purchased) contains [simple]?> then\n            set [hat v] to [simple]\n        end\n    else\n        if <key (2 v) pressed?> then\n            if < (purchased) contains [top]?> then\n                set [hat v] to [top]\n            end\n        else\n            if <key (3 v) pressed?> then\n                if < (purchased) contains [knight]?> then\n                    set [hat v] to [knight]\n                end\n            else\n                if <key (space v) pressed?> then\n                    set [hat v] to [blank]\n                end\n            end\n        end\n    end\nend\n\nwhen I start as a clone\nif <(shop's clone #) = [1]> then\n    set size to (140) %\n    go to x: (-90) y: (-65)\n    if <not < (purchased) contains [simple]?>> then\n        switch costume to (simple hat v)\n    else\n        switch costume to (simple hat owned v)\n    end\n    show\n    repeat (10)\n        change size by (-4)\n    end\n    forever\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (20)\n            if <mouse down?> then\n                if <not < (purchased) contains [simple]?>> then\n                    if <<(coins) = [9]> or <(coins) > [9]>> then\n                        set [hat v] to [simple]\n                        change [coins v] by (-9)\n                        set [purchased v] to (join (purchased) [ simple])\n                        wait until <not <mouse down?>>\n                        switch costume to (simple hat owned v)\n                        think [Purchased! Press 1 to activate it.] for (2) seconds\n                    else\n                        think [Not enough money!] for (2) seconds\n                    end\n                else\n                    think [Already purchased!] for (2) seconds\n                end\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    end\nelse\n    if <(shop's clone #) = [2]> then\n        set size to (140) %\n        go to x: (0) y: (-65)\n        if <not < (purchased) contains [top]?>> then\n            switch costume to (top hat v)\n        else\n            switch costume to (top hat owned v)\n        end\n        show\n        repeat (10)\n            change size by (-4)\n        end\n        forever\n            if <touching (mouse-pointer v)?> then\n                set [brightness v] effect to (20)\n                if <mouse down?> then\n                    if <not < (purchased) contains [top]?>> then\n                        if <<(coins) = [27]> or <(coins) > [27]>> then\n                            set [hat v] to [top]\n                            change [coins v] by (-27)\n                            set [purchased v] to (join (purchased) [ top])\n                            wait until <not <mouse down?>>\n                            switch costume to (top hat owned v)\n                            think [Purchased! Press 2 to activate it.] for (2) seconds\n                        else\n                            think [Not enough money!] for (2) seconds\n                        end\n                    else\n                        think [Already purchased!] for (2) seconds\n                    end\n                end\n            else\n                set [brightness v] effect to (0)\n            end\n        end\n    else\n        if <(shop's clone #) = [3]> then\n            set size to (140) %\n            go to x: (90) y: (-65)\n            if <not < (purchased) contains [knight]?>> then\n                switch costume to (knight hat v)\n            else\n                switch costume to (knight hat owned v)\n            end\n            show\n            repeat (10)\n                change size by (-4)\n            end\n            forever\n                if <touching (mouse-pointer v)?> then\n                    set [brightness v] effect to (20)\n                    if <mouse down?> then\n                        if <not < (purchased) contains [knight]?>> then\n                            if <<(coins) = [36]> or <(coins) > [36]>> then\n                                set [hat v] to [knight]\n                                change [coins v] by (-36)\n                                set [purchased v] to (join (purchased) [ knight])\n                                wait until <not <mouse down?>>\n                                switch costume to (knight hat owned v)\n                                think [Purchased! Press 3 to activate it.] for (2) seconds\n                            else\n                                think [Not enough money!] for (2) seconds\n                            end\n                        else\n                            think [Already purchased!] for (2) seconds\n                        end\n                    end\n                else\n                    set [brightness v] effect to (0)\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [close shop v]\ndelete this clone\n\nwhen I receive [open shop v]\ndelete this clone\n\nwhen I receive [play game v]\ndelete this clone\n\n@hats wear\n\nwhen I receive [lose v]\nrepeat (5)\n    hide\n    wait (0.1) seconds\n    show\n    wait (0.1) seconds\nend\nhide\nwait (0.5) seconds\n\nwhen I receive [win v]\nrepeat (50)\n    point towards (portal v)\n    turn right (65) degrees\n    move ((distance to [portal v]) / (2)) steps\n    change size by (-1)\n    change [ghost v] effect by (-2)\nend\nhide\n\nwhen I receive [tick v]\nshow\ngo to (player v)\npoint towards (player v)\nswitch costume to (hat)\n\nwhen flag clicked\nset [hat v] to [blank]\nswitch costume to (blank v)\nset size to (100) %\nhide\n\nwhen I receive [levels_map v]\ngo to [back v] layer\nhide\n\nwhen I receive [play game v]\nwait (1.2) seconds\nrepeat (10)\n    go to [front v] layer\nend\n\nwhen I receive [set up v]\nset size to (100) %\n\nwhen I receive [play game v]\nforever\n    if <(levels_map) = [false]> then\n        play sound [Grasslands Theme v] until done\n    end\nend\n\nwhen flag clicked\nforever\n    if <(levels_map) = [true]> then\n        set volume to (0) %\n    end\n    if <(levels_map) = [false]> then\n        if <(music?) = [false]> then\n            set volume to (0) %\n        else\n            set volume to (30) %\n        end\n    end\nend\n\n@thumbnail\n\nwhen flag clicked\nshow\nforever\n    set [ghost v] effect to (100)\n    go to [front v] layer\nend\n\n@intro\n\ndefine Smooth Glide x: (x) y: (y) speed: (speed)\nrepeat until <<(round (x position)) = (round (x))> and <(round (y position)) = (round (y))>>\n    change x by (((round (x)) - (round (x position))) / (speed))\n    change y by (((round (y)) - (round (y position))) / (speed))\nend\ngo to x: (x) y: (y)\n\nwhen flag clicked\nset [intro end v] to [false]\nhide\nset [clone# v] to [1]\ncreate clone of (_myself_ v)\nwait (0.3) seconds\nset [clone# v] to [2]\nrepeat (6)\n    create clone of (_myself_ v)\n    wait (0.2) seconds\n    change [clone# v] by (1)\nend\n\nwhen I start as a clone\nif <(clone#) = [1]> then\n    set [ghost v] effect to (0)\n    go to [back v] layer\n    switch costume to (backround v)\n    go to x: (0) y: (0)\n    show\n    forever\n        if <not <(intro end) = [true]>> then\n            glide (0.5) secs to x: (-40) y: (40)\n            set x to (0)\n            set y to (0)\n        else\n            broadcast (start game v)\n            repeat (20)\n                change [ghost v] effect by (5)\n            end\n            delete this clone\n        end\n    end\nelse\n    if <(clone#) = [2]> then\n        go to x: (-250) y: (-100)\n        set [ghost v] effect to (100)\n        switch costume to (j v)\n        go to [front v] layer\n        show\n        repeat (24)\n            change x by (((-100) - (x position)) / (8))\n            change y by (((0) - (y position)) / (4))\n            change [ghost v] effect by (-5)\n        end\n        wait until <(clone#) = [9]>\n        move (-60) steps\n        repeat (20)\n            change size by (i)\n        end\n        set [i v] to [0]\n        repeat until <touching (_edge_ v)?>\n            change [i v] by (-1)\n            change y by (i)\n        end\n        delete this clone\n    else\n        if <(clone#) = [3]> then\n            go to x: (-250) y: (-100)\n            set [ghost v] effect to (100)\n            switch costume to (t v)\n            go to [front v] layer\n            show\n            repeat (24)\n                change x by (((-70) - (x position)) / (8))\n                change y by (((0) - (y position)) / (4))\n                change [ghost v] effect by (-5)\n            end\n            wait until <(clone#) = [9]>\n            move (-45) steps\n            repeat (20)\n                change size by (i)\n            end\n            wait (0.2) seconds\n            repeat until <touching (_edge_ v)?>\n                change y by (i)\n            end\n            delete this clone\n        else\n            if <(clone#) = [4]> then\n                go to x: (-250) y: (-100)\n                set [ghost v] effect to (100)\n                switch costume to (z v)\n                go to [front v] layer\n                show\n                repeat (24)\n                    change x by (((-40) - (x position)) / (8))\n                    change y by (((0) - (y position)) / (4))\n                    change [ghost v] effect by (-5)\n                end\n                wait until <(clone#) = [9]>\n                move (-20) steps\n                repeat (20)\n                    change size by (i)\n                    set [i v] to (((i) * (0.8)) + (((170) - (size)) / (2)))\n                end\n                wait (0.4) seconds\n                repeat until <touching (_edge_ v)?>\n                    change y by (i)\n                end\n                delete this clone\n            else\n                if <(clone#) = [5]> then\n                    go to x: (-250) y: (-100)\n                    set [ghost v] effect to (100)\n                    switch costume to (a v)\n                    go to [front v] layer\n                    show\n                    repeat (24)\n                        change x by (((-10) - (x position)) / (8))\n                        change y by (((0) - (y position)) / (4))\n                        change [ghost v] effect by (-5)\n                    end\n                    wait until <(clone#) = [9]>\n                    repeat (20)\n                        change size by (i)\n                    end\n                    wait (0.6) seconds\n                    repeat until <touching (_edge_ v)?>\n                        change y by (i)\n                    end\n                    delete this clone\n                else\n                    if <(clone#) = [6]> then\n                        go to x: (-250) y: (-100)\n                        set [ghost v] effect to (100)\n                        switch costume to (n v)\n                        go to [front v] layer\n                        show\n                        repeat (24)\n                            change x by (((30) - (x position)) / (8))\n                            change y by (((0) - (y position)) / (4))\n                            change [ghost v] effect by (-5)\n                        end\n                        wait until <(clone#) = [9]>\n                        move (20) steps\n                        repeat (20)\n                            change size by (i)\n                        end\n                        wait (0.8) seconds\n                        repeat until <touching (_edge_ v)?>\n                            change y by (i)\n                        end\n                        delete this clone\n                    else\n                        if <(clone#) = [7]> then\n                            go to x: (-250) y: (-100)\n                            set [ghost v] effect to (100)\n                            switch costume to (e v)\n                            go to [front v] layer\n                            show\n                            repeat (24)\n                                change x by (((70) - (x position)) / (8))\n                                change y by (((0) - (y position)) / (4))\n                                change [ghost v] effect by (-5)\n                            end\n                            set [clone# v] to [9]\n                            wait until <(clone#) = [9]>\n                            move (45) steps\n                            repeat (20)\n                                change size by (i)\n                            end\n                            wait (1) seconds\n                            repeat (5)\n                                change y by (i)\n                            end\n                            create clone of (_myself_ v)\n                            repeat until <touching (_edge_ v)?>\n                                change y by (i)\n                            end\n                            delete this clone\n                        else\n                            if <(clone#) = [9]> then\n                                switch costume to (backround 2 v)\n                                go to [front v] layer\n                                go to x: (-600) y: (0)\n                                show\n                                Smooth Glide x: (0) y: (0) speed: (4)\n                                Smooth Glide x: (600) y: (0) speed: (4)\n                                set [clone# v] to [10]\n                                create clone of (_myself_ v)\n                                delete this clone\n                            else\n                                if <(clone#) = [10]> then\n                                    set size to (100) %\n                                    switch costume to (j logo v)\n                                    show\n                                    Smooth Glide x: (0) y: (0) speed: (4)\n                                    set [i v] to [0]\n                                    repeat (47)\n                                        point in direction ((([tan v] of ((10) * (i)) ) * (10)) + (90))\n                                        change [i v] by (0.4)\n                                    end\n                                    repeat (30)\n                                        set [clone# v] to [11]\n                                        create clone of (_myself_ v)\n                                    end\n                                    repeat (47)\n                                        point in direction ((([tan v] of ((10) * (i)) ) * (10)) + (90))\n                                        change [i v] by (0.4)\n                                    end\n                                    repeat (20)\n                                        change size by (-5)\n                                    end\n                                    set [intro end v] to [true]\n                                    delete this clone\n                                else\n                                    if <(clone#) = [11]> then\n                                        go to x: (-300) y: (0)\n                                        switch costume to (logo2 v)\n                                        set size to (pick random (30) to (75)) %\n                                        set [ghost v] effect to (pick random (0) to (50))\n                                        set [brightness v] effect to (pick random (-20) to (10))\n                                        go to x: (pick random (-20) to (20)) y: (pick random (0) to (20))\n                                        point in direction (pick random (-180) to (180))\n                                        set [v v] to (pick random (10) to (12))\n                                        set [y_v v] to (pick random (9) to (13))\n                                        go to [front v] layer\n                                        go [backward v] (1) layers\n                                        show\n                                        repeat until <(y position) < [-170]>\n                                            move (v) steps\n                                            change y by (y_v)\n                                            set [v v] to ((v) * (0.95))\n                                            change [y_v v] by (-1)\n                                        end\n                                        delete this clone\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nplay sound [bensound-summer v] until done\n\n@level 5 animation player\n\ndefine Typewriter Talk (speak this)\nset [talk v] to []\nset [count v] to [1]\nrepeat (length of (speak this))\n    set [talk v] to (join (talk) (letter (count) of (speak this)))\n    say (talk)\n    wait (0.01) seconds\n    change [count v] by (1)\nend\nwait (2) seconds\nsay []\n\nwhen flag clicked\ngo to [front v] layer\nhide\n\nwhen I receive [level 5 v]\ngo to x: (-200) y: (-35)\nswitch costume to (player v)\nset size to (100) %\nshow\npoint in direction (90)\nwait (2) seconds\nTypewriter Talk [I managed to pass through all challenges and I will be created knight by the king now. Thank you for your help!]\nrepeat (90)\n    next costume\n    move (2) steps\nend\nbroadcast (king v)\n\nwhen I receive [levels_map v]\nhide\n\nwhen I receive [knight award v]\nswitch costume to (player16 v)\n\n@Sprite2\n\ndefine Smooth Glide x: (x) y: (y) speed: (speed)\nrepeat until <<(round (x position)) = (round (x))> and <(round (y position)) = (round (y))>>\n    change x by (((round (x)) - (round (x position))) / (speed))\n    change y by (((round (y)) - (round (y position))) / (speed))\nend\ngo to x: (x) y: (y)\n\nwhen flag clicked\nswitch costume to (costume1 v)\ngo to [back v] layer\ngo [forward v] (1) layers\nhide\n\nwhen I receive [level 5 v]\nshow\n\nwhen I receive [levels_map v]\nhide\n\nwhen I receive [end v]\nstart sound [ta da v]\ncreate clone of (_myself_ v)\n\nwhen I start as a clone\nhide\ngo to x: (0) y: (300)\nswitch costume to (costume2 v)\ngo to [front v] layer\nshow\nSmooth Glide x: (0) y: (-100) speed: (3)\n\n@level 5 animation king\n\ndefine Typewriter Talk (speak this)\nset [talk v] to []\nset [count v] to [1]\nrepeat (length of (speak this))\n    set [talk v] to (join (talk) (letter (count) of (speak this)))\n    say (talk)\n    wait (0.01) seconds\n    change [count v] by (1)\nend\nwait (2) seconds\nsay []\n\nwhen flag clicked\ngo to [front v] layer\nhide\n\nwhen I receive [level 5 v]\ngo to x: (230) y: (-35)\nswitch costume to (player v)\nset size to (100) %\npoint in direction (-90)\nhide\n\nwhen I receive [levels_map v]\nhide\n\nwhen I receive [king v]\nshow\nwait (2) seconds\nrepeat (90)\n    if <not <(costume [number v]) = [15]>> then\n        next costume\n    end\n    move (2) steps\n    if <(costume [number v]) = [15]> then\n        switch costume to (player v)\n    end\nend\nTypewriter Talk [Congratulations! Your courage, tenacity and patience will be awarded. You are now a knight!]\nswitch costume to (player16 v)\nbroadcast (knight award v)\nwait (2) seconds\nswitch costume to (player17 v)\nTypewriter Talk [ser]\nwait (0.5) seconds\nTypewriter Talk (username)\nbroadcast (end v)\n\n