Block world - platformer

Instructions: WASD, space or arrow keys to move.\nGet to the left side of the screen without falling in the void, going on lava, falling on spikes or walking on zombies.\nMake your own levels with the level creator by pressing the "Make level" button. 

@Stage\n\nwhen [e v] key pressed\nif <(username) = [Zieejo43]> then\n    if <(Editing) = [0]> then\n        ask (join (join (join (join (join [<< levels created = ] ((length of [levels v]) / (300))) (join [ >> << Current level = ] (Level))) [  >> << Which level do you want to edit 1 - ]) (((length of [levels v]) / (300)) + (1))) [? >>]) and wait\n        if <<<<(Level) > [0]> and <(((length of [levels v]) / (300)) + (2)) > (Level)>> and <(length of (answer)) < [3]>> and <[0] < (length of (answer))>> then\n            set [level v] to (answer)\n            set [editing v] to [1]\n            hide variable [level v]\n            hide variable [coins v]\n            broadcast (EditorMode v)\n        else\n            ask [Error] and wait\n        end\n    else\n        set [editing v] to [0]\n        broadcast (EditorMode v)\n    end\nend\n\nwhen flag clicked\nset [editing v] to [0]\nif <((length of [levels v]) / (300)) < (Level)> then\n    set [level v] to ((length of [levels v]) / (300))\nend\nforever\n    wait until <not <mouse down?>>\n    wait until <mouse down?>\n    broadcast (Click v)\nend\n\nwhen flag clicked\nforever\n    set [fps.timer v] to (timer)\n    switch backdrop to (backdrop1 v)\n    reset timer\n    set [key.w v] to [0]\n    set [key.a v] to [0]\n    set [key.s v] to [0]\n    set [key.d v] to [0]\n    if <<<key (space v) pressed?> or <<key (w v) pressed?> or <key (up arrow v) pressed?>>> or <<mouse down?> and <(mouse y) > [0]>>> then\n        set [key.w v] to [1]\n    end\n    if <<<key (a v) pressed?> or <key (left arrow v) pressed?>> or <<mouse down?> and <[-100] > (mouse x)>>> then\n        set [key.a v] to [1]\n    end\n    if <<key (s v) pressed?> or <key (down arrow v) pressed?>> then\n        set [key.s v] to [1]\n    end\n    if <<<key (d v) pressed?> or <key (right arrow v) pressed?>> or <<mouse down?> and <(mouse x) > [100]>>> then\n        set [key.d v] to [1]\n    end\nend\n\ndefine GetFps\nset [fps v] to [0]\nset [background: i v] to [1]\nrepeat (length of [fpsmem v])\n    change [fps v] by (item (Background: i) of [fpsmem v])\n    change [background: i v] by (1)\nend\nset [fps v] to (round ((1) / ((Fps) / (length of [fpsmem v]))))\n\nwhen flag clicked\ndelete all of [fpsmem v]\nforever\n    insert (Fps.timer) at (1) of [fpsmem v] \n    delete (4) of [fpsmem v]\n    GetFps\nend\n\nwhen [r v] key pressed\nif <(username) = [Zieejo43]> then\n    ask (join (join (join [<< Current level = ] (Level)) [ >> Choose level from 1 - ]) ((length of [levels v]) / (300))) and wait\n    if <<(answer) < (((length of [levels v]) / (300)) + (1))> and <[0] < (answer)>> then\n        set [level v] to (answer)\n        broadcast (Setup v)\n    else\n        ask [Error] and wait\n    end\nend\n\nwhen I receive [resetgamedata v]\ndelete all of [playerslevels v]\nset [hasrated v] to [0]\nset [deaths v] to [0]\nset [asked v] to [0]\nset [coins v] to [0]\nset [story v] to [1]\nset [level v] to [1]\nset [kills v] to [0]\n\nwhen I receive [killenemy v]\nchange [kills v] by (1)\n\n@Level\n\ndefine CreateBlocks (player)\nset [playerlevel? v] to (player)\nSetCurentLevel (player)\nhide\nset [c.id v] to [1]\nset [c.y v] to [7]\nrepeat (15)\n    set [c.x v] to [-9.5]\n    repeat (20)\n        if <not <(item (c.id) of [currentlevel v]) = [0]>> then\n            create clone of (_myself_ v)\n        end\n        change [c.id v] by (1)\n        change [c.x v] by (1)\n    end\n    change [c.y v] by (-1)\nend\n\nwhen I start as a clone\nset [c v] to [1]\nshow\nif <<(item (c.id) of [currentlevel v]) = [2]> or <(item (c.id) of [currentlevel v]) = [9]>> then\n    hide\nend\nUpdatePos\nUpdateBlockSides\nUpdateCostume\nif <<(item (c.id) of [currentlevel v]) = [2]> or <(item (c.id) of [currentlevel v]) = [9]>> then\n    wait (0.1) seconds\n    show\nend\nif <(Editing) = [0]> then\n    forever\n        if <(PlayerEditMenu) = [1]> then\n            wait until <(PlayerEditMenu) = [0]>\n        end\n        if <(item (c.id) of [currentlevel v]) = [2]> then\n            set size to (320) %\n            if <<touching (player v)?> and <(Dead) = [0]>> then\n                set size to (100.5) %\n                change [coins v] by (1)\n                broadcast (Coin v)\n                delete this clone\n            end\n            set size to (100.5) %\n        end\n        if <(item (c.id) of [currentlevel v]) = [3]> then\n            set size to (120) %\n            if <<touching (player v)?> and <(Dead) = [0]>> then\n                broadcast (Die v)\n            end\n            set size to (100.5) %\n        end\n        if <(item (c.id) of [currentlevel v]) = [6]> then\n            set size to (110) %\n            change y by (1)\n            if <<touching (player v)?> and <(Dead) = [0]>> then\n                broadcast (Die v)\n            end\n            set size to (100.5) %\n            UpdatePos\n        end\n        if <(item (c.id) of [currentlevel v]) = [9]> then\n            change [custumetimer v] by (Fps.timer)\n            switch costume to (hitbox v)\n            go to [front v] layer\n            UpdateBlockSides\n            change [c.x v] by (-0.5)\n            UpdatePos\n            UpdateBlockSides\n            if <<(item (3) of [c.sides v]) = [0]> or <touching (_edge_ v)?>> then\n                change [c.x v] by (0.5)\n            else\n                change [c.x v] by (1)\n                UpdatePos\n                UpdateBlockSides\n                change [c.x v] by (-0.5)\n            end\n            if <<<(item (3) of [c.sides v]) = [0]> or <<(item (2) of [c.sides v]) = [1]> or <(item (4) of [c.sides v]) = [1]>>> or <touching (_edge_ v)?>> then\n                if <(direction) = [1]> then\n                    change [c.x v] by (-0.1)\n                    set [direction v] to [0]\n                else\n                    change [c.x v] by (0.1)\n                    set [direction v] to [1]\n                end\n            end\n            if <(custumeTimer) > [0.25]> then\n                set [custumetimer v] to [0]\n                if <(costume) = [1]> then\n                    set [costume v] to [0]\n                else\n                    set [costume v] to [1]\n                end\n            end\n            if <(direction) = [1]> then\n                change [c.x v] by (0.03)\n            else\n                change [c.x v] by (-0.03)\n            end\n            UpdatePos\n            set size to (120) %\n            if <touching (player v)?> then\n                if <(PlayerYV) < [-1]> then\n                    broadcast (KillEnemy v)\n                    delete this clone\n                else\n                    if <(Dead) = [0]> then\n                        broadcast (Die v)\n                    end\n                end\n            end\n            set size to (100.5) %\n            if <(direction) = [1]> then\n                switch costume to (join [r] ((1) + (costume)))\n            else\n                switch costume to (join [l] ((1) + (costume)))\n            end\n        end\n    end\nend\n\ndefine UpdateBlockSides\nif <(c) = [1]> then\n    switch costume to (hitbox v)\n    set size to (50) %\n    delete all of [c.sides v]\n    add [0] to [c.sides v]\n    add [0] to [c.sides v]\n    add [0] to [c.sides v]\n    add [0] to [c.sides v]\n    set [i v] to [1]\n    repeat (4)\n        if <(i) = [1]> then\n            change y by (24)\n        end\n        if <(i) = [2]> then\n            change x by (-24)\n        end\n        if <(i) = [3]> then\n            change y by (-24)\n        end\n        if <(i) = [4]> then\n            change x by (24)\n        end\n        if <touching (level v)?> then\n            replace item (i) of [c.sides v] with [1]\n        end\n        change [i v] by (1)\n        UpdatePos\n    end\n    UpdateCostume\nend\n\ndefine UpdateCostume\nif <(item (c.id) of [currentlevel v]) = [0]> then\n    delete this clone\nend\nset size to (100.5) %\nset [brightness v] effect to (10)\nif <(item (c.id) of [currentlevel v]) = [1]> then\n    set [brightness v] effect to (20)\nend\nswitch costume to (join (item (c.id) of [currentlevel v]) [])\nif <<(item (c.id) of [currentlevel v]) = [1]> and <(item (1) of [c.sides v]) = [0]>> then\n    switch costume to (grass v)\nend\n\ndefine UpdatePos\ngo to x: ((c.x) * (24)) y: ((c.y) * (24))\n\nwhen I receive [editormode v]\nset [playerlevel? v] to [0]\nif <(Editing) = [0]> then\n    if <(c) = [1]> then\n        delete this clone\n    else\n        SaveLevel [0]\n        broadcast (Setup v)\n    end\nelse\n    if <(c) = [1]> then\n        delete this clone\n    else\n        SetCurentLevel [0]\n        wait (0.5) seconds\n        CreateBlocks [0]\n        set [editing v] to [1]\n        wait (0.5) seconds\n        forever\n            show\n            set [c.x v] to ((-0.5) + (round ((mouse x) / (24))))\n            set [c.y v] to (round ((mouse y) / (24)))\n            if <(c.x) < [-9.5]> then\n                set [c.x v] to [-9.5]\n            end\n            if <[9.5] < (c.x)> then\n                set [c.x v] to [9.5]\n            end\n            if <(c.y) < [-7]> then\n                set [c.y v] to [-7]\n            end\n            if <[7] < (c.y)> then\n                set [c.y v] to [7]\n            end\n            set [c.id v] to (((c.x) + (10.5)) + (((7) + (() - (c.y))) * (20)))\n            go to x: ((c.x) * (24)) y: ((c.y) * (24))\n            switch costume to (join [Pointer] (SelectedBlock))\n            if <mouse down?> then\n                if <(SelectedBlock) = [0]> then\n                    if <not <(item (c.id) of [currentlevel v]) = [0]>> then\n                        replace item (c.id) of [currentlevel v] with [0]\n                        broadcast (PublicBlockUpdate v)\n                    end\n                else\n                    if <(item (c.id) of [currentlevel v]) = [0]> then\n                        create clone of (_myself_ v)\n                    end\n                    if <not <(item (c.id) of [currentlevel v]) = (SelectedBlock)>> then\n                        broadcast (PublicBlockUpdate v)\n                    end\n                    replace item (c.id) of [currentlevel v] with (SelectedBlock)\n                end\n            end\n            if <(Editing) = [0]> then\n                hide\n                stop [this script v]\n            end\n        end\n    end\nend\n\nwhen I receive [publicblockupdate v]\nif <(c) = [1]> then\n    if <<(item (c.id) of [currentlevel v]) = [2]> or <(item (c.id) of [currentlevel v]) = [9]>> then\n        hide\n    end\n    repeat (10)\n        UpdateBlockSides\n        UpdateCostume\n    end\n    if <<(item (c.id) of [currentlevel v]) = [2]> or <(item (c.id) of [currentlevel v]) = [9]>> then\n        show\n    end\nend\n\nwhen [up arrow v] key pressed\nif <<(c) = [0]> and <(Editing) = [1]>> then\n    change [selectedblock v] by (1)\n    switch costume to (join [Pointer] (SelectedBlock))\n    if <not < (costume [name v]) contains (SelectedBlock)?>> then\n        set [selectedblock v] to (join (letter (8) of (costume [name v])) (letter (9) of (costume [name v])))\n    end\n    broadcast (SelectedBlockChange v)\nend\n\nwhen [down arrow v] key pressed\nif <<(c) = [0]> and <(Editing) = [1]>> then\n    change [selectedblock v] by (-1)\n    if <(SelectedBlock) < [0]> then\n        set [selectedblock v] to [0]\n    end\n    broadcast (SelectedBlockChange v)\nend\n\nwhen I receive [setup v]\nif <(c) = [1]> then\n    delete this clone\nelse\n    if <(PlayerLevel?) = [0]> then\n        show variable [coins v]\n    end\n    wait (0.5) seconds\n    if <(PlayerLevel?) = [1]> then\n        hide variable [level v]\n    end\n    set [c v] to [0]\n    CreateBlocks (PlayerLevel?)\n    hide\nend\n\ndefine SetCurentLevel (player)\nset [playerlevel? v] to (player)\ndelete all of [currentlevel v]\nset [i v] to [0]\nrepeat (300)\n    if <(player) = [1]> then\n        if <(item (((Load.PlayerLevel.ID) * (300)) - (i)) of [playerslevels v]) = []> then\n            insert [0] at (1) of [currentlevel v] \n        else\n            insert (item (((Load.PlayerLevel.ID) * (300)) - (i)) of [playerslevels v]) at (1) of [currentlevel v] \n        end\n    else\n        if <(item (((Level) * (300)) - (i)) of [levels v]) = []> then\n            insert [0] at (1) of [currentlevel v] \n        else\n            insert (item (((Level) * (300)) - (i)) of [levels v]) at (1) of [currentlevel v] \n        end\n    end\n    change [i v] by (1)\nend\n\ndefine SaveLevel (player)\nset [i v] to [1]\nrepeat (300)\n    if <(player) = [1]> then\n        if <(Load.PlayerLevel.ID) > ([floor v] of ((length of [playerslevels v]) / (300)) )> then\n            add (item (i) of [currentlevel v]) to [playerslevels v]\n        else\n            replace item ((((Load.PlayerLevel.ID) - (1)) * (300)) + (i)) of [playerslevels v] with (item (i) of [currentlevel v])\n        end\n    else\n        if <(Level) > ([floor v] of ((length of [levels v]) / (300)) )> then\n            add (item (i) of [currentlevel v]) to [levels v]\n        else\n            replace item ((((Level) - (1)) * (300)) + (i)) of [levels v] with (item (i) of [currentlevel v])\n        end\n    end\n    change [i v] by (1)\nend\n\nwhen I receive [loadplayerlevel v]\nset [playerlevel? v] to [1]\nif <(Editing) = [0]> then\n    if <(c) = [1]> then\n        delete this clone\n    else\n        SaveLevel [1]\n        broadcast (Setup v)\n    end\nelse\n    if <(c) = [1]> then\n        delete this clone\n    else\n        SetCurentLevel [1]\n        wait (0.5) seconds\n        CreateBlocks [1]\n        set [editing v] to [1]\n        wait (0.5) seconds\n        if <(length of [playerslevels v]) = [0]> then\n            wait until <(PlayerEditor.TutorialStage) = [2]>\n        end\n        forever\n            if <(PlayerEditMenu) = [1]> then\n                wait until <<(PlayerEditMenu) = [0]> and <not <mouse down?>>>\n            end\n            show\n            set [c.x v] to ((-0.5) + (round ((mouse x) / (24))))\n            set [c.y v] to (round ((mouse y) / (24)))\n            if <(c.x) < [-9.5]> then\n                set [c.x v] to [-9.5]\n            end\n            if <[9.5] < (c.x)> then\n                set [c.x v] to [9.5]\n            end\n            if <(c.y) < [-7]> then\n                set [c.y v] to [-7]\n            end\n            if <[7] < (c.y)> then\n                set [c.y v] to [7]\n            end\n            set [c.id v] to (((c.x) + (10.5)) + (((7) + (() - (c.y))) * (20)))\n            go to x: ((c.x) * (24)) y: ((c.y) * (24))\n            switch costume to (join [Pointer] (SelectedBlock))\n            if <mouse down?> then\n                if <(SelectedBlock) = [0]> then\n                    if <not <(item (c.id) of [currentlevel v]) = [0]>> then\n                        replace item (c.id) of [currentlevel v] with [0]\n                        broadcast (PublicBlockUpdate v)\n                    end\n                else\n                    if <(item (c.id) of [currentlevel v]) = [0]> then\n                        create clone of (_myself_ v)\n                    end\n                    if <not <(item (c.id) of [currentlevel v]) = (SelectedBlock)>> then\n                        broadcast (PublicBlockUpdate v)\n                    end\n                    replace item (c.id) of [currentlevel v] with (SelectedBlock)\n                end\n            end\n            if <(Editing) = [0]> then\n                hide\n                stop [this script v]\n            end\n        end\n    end\nend\n\nwhen flag clicked\nhide variable [coins v]\nhide\n\nwhen I receive [saveplayerlevel v]\nSaveLevel [1]\n\nwhen I start as a clone\nforever\n    if <<(PlayerLevel?) = [1]> and <(PlayerEditMenu) = [1]>> then\n        go to [back v] layer\n    end\nend\n\nwhen I receive [startmenu v]\ndelete this clone\n\n@Player\n\nwhen I receive [setup v]\nshow\npoint in direction (90)\ngo to x: (-200) y: (-80)\nif <(Level) = [10]> then\n    change y by (-40)\nend\nset [acceleration v] to [7]\nset [jumpforce v] to [11]\nset [finished v] to [0]\nset [dead v] to [0]\nset [speed v] to [5]\nset [xv v] to [0]\nset [yv v] to [0]\nswitch costume to (hitbox v)\nset [ghost v] effect to (100)\nwait (0.95) seconds\nforever\n    if <(PlayerEditMenu) = [1]> then\n        wait until <(PlayerEditMenu) = [0]>\n    end\n    point in direction (90)\n    switch costume to (hitbox v)\n    set size to (98) %\n    if <(Editing) = [1]> then\n        hide\n        stop [this script v]\n    end\n    if <(Key.A) = [1]> then\n        change [xv v] by (((() - (speed)) - (xv)) / (acceleration))\n        if <(Key.D) = [0]> then\n            change [xv v] by (((() - (speed)) - (xv)) / (acceleration))\n        end\n    end\n    if <(Key.D) = [1]> then\n        change [xv v] by (((speed) - (xv)) / (acceleration))\n        if <(Key.A) = [0]> then\n            change [xv v] by (((speed) - (xv)) / (acceleration))\n        end\n    end\n    if <<<(Key.A) = [1]> and <(Key.D) = [1]>> or <<(Key.A) = [0]> and <(Key.D) = [0]>>> then\n        change [xv v] by (((0) - (xv)) / ((acceleration) * (0.65)))\n    end\n    if <<(xv) < [0.3]> and <[-0.3] < (xv)>> then\n        set [xv v] to [0]\n    end\n    if <[0] < (xv)> then\n        set [currentspeed v] to (xv)\n    else\n        set [currentspeed v] to (() - (xv))\n    end\n    change x by (xv)\n    if <(x position) > [230]> then\n        set [finished v] to [1]\n        broadcast (LevelFinished v)\n        stop [this script v]\n    end\n    if <(dead) = [1]> then\n        switch costume to (death v)\n        if <(Dead) = [0]> then\n            broadcast (Die v)\n        end\n        stop [this script v]\n    end\n    if <touching (level v)?> then\n        change y by (1)\n        if <touching (level v)?> then\n            change y by (1)\n            if <touching (level v)?> then\n                change y by (1)\n                if <touching (level v)?> then\n                    change y by (1)\n                    if <touching (level v)?> then\n                        change y by (1)\n                        if <touching (level v)?> then\n                            change y by (-5)\n                            if <(xv) > [0]> then\n                                HitWall [1]\n                            else\n                                HitWall [0]\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\n    change [yv v] by (-1)\n    set [playeryv v] to (yv)\n    if <[-14] > (yv)> then\n        set [yv v] to [-14]\n    end\n    change y by (yv)\n    if <<[-180] > (y position)> and <(dead) = [0]>> then\n        broadcast (Die v)\n    end\n    set [ground v] to [0]\n    if <touching (level v)?> then\n        change y by (() - (yv))\n        change y by (-20)\n        if <touching (level v)?> then\n            set [ground v] to [1]\n            HitY [1]\n            if <(Key.W) = [1]> then\n                set [yv v] to (jumpforce)\n                broadcast (Jump v)\n            end\n        else\n            change y by (30)\n            HitY [0]\n        end\n    end\n    if <not <(xv) = [0]>> then\n        change [costume v] by ((round (((0.1) + (((currentspeed) / (speed)) * (0.6))) * (10))) / (10))\n    end\n    if <(costume) > [14]> then\n        set [costume v] to [2]\n    end\n    if <<<[0] > (xv)> or <(Key.A) = [1]>> and <not <(xv) = [0]>>> then\n        set [costumedirection v] to [0]\n    end\n    if <<<(xv) > [0]> or <(Key.D) = [1]>> and <not <(xv) = [0]>>> then\n        set [costumedirection v] to [1]\n    end\n    if <(ground) = [0]> then\n        set [costume v] to [3]\n    end\n    if <<(xv) = [0]> and <(ground) = [1]>> then\n        set [costume v] to [-1]\n    end\n    set [costumedirection v] to (costumeDirection)\n    set [costume v] to (costume)\n    if <<<(xv) = [0]> and <(ground) = [1]>> and <<not <<[0] > (xv)> or <(Key.A) = [1]>>> and <not <<(xv) > [0]> or <(Key.D) = [1]>>>>> then\n        set [costume v] to [-1]\n    end\nend\n\nwhen flag clicked\nhide\nforever\n    set [dead v] to (dead)\nend\n\ndefine HitWall (right)\nif <(right) = [1]> then\n    repeat until <not <touching (level v)?>>\n        change x by (-1)\n    end\nelse\n    repeat until <not <touching (level v)?>>\n        change x by (1)\n    end\nend\nset [xv v] to [0]\n\ndefine HitY (ground)\nif <(ground) = [1]> then\n    if <<touching (level v)?> and <(yv) < [-1]>> then\n        broadcast (Land v)\n    end\n    repeat until <not <touching (level v)?>>\n        change y by (1)\n    end\nelse\n    repeat until <not <touching (level v)?>>\n        change y by (-1)\n    end\nend\nset [yv v] to [0]\n\nwhen I receive [die v]\nset [dead v] to [1]\n\nwhen [timer v] > (1.5)\nhide\n\nwhen I receive [levelfinished v]\nif <(PlayerLevel?) = [1]> then\n    set [editing v] to [1]\n    broadcast (LoadPlayerLevel v)\nelse\n    if <(Level) < ((length of [levels v]) / (300))> then\n        change [level v] by (1)\n    end\n    hide\n    broadcast (Setup v)\nend\n\nwhen I receive [die v]\nrepeat (10)\n    if <(Coins) > [0]> then\n        change [coins v] by (-1)\n    end\nend\n\nwhen I receive [killenemy v]\nset [yv v] to ((jumpforce) * (0.66))\nif <(Key.W) = [1]> then\n    set [yv v] to ((jumpforce) * (1.15))\nend\n\n@Bakcground\n\nwhen flag clicked\nforever\n    go to x: (0) y: (0)\n    set [pixelate v] effect to (20)\n    go to [back v] layer\n    set size to (102) %\n    show\n    if <(Editing) = [1]> then\n        hide\n    end\nend\n\nwhen I receive [startmenu v]\nset [startmenustage v] to [0]\nrepeat until <(StartMenuStage) = [4]>\n    if <(StartMenuStage) = [0]> then\n        change [background: brightness v] by (((-8) - (Background: Brightness)) / (10))\n    else\n        if <(StartMenuStage) = [2]> then\n            change [background: brightness v] by (((-50) - (Background: Brightness)) / (10))\n        else\n            change [background: brightness v] by (((-30) - (Background: Brightness)) / (10))\n        end\n    end\n    set [brightness v] effect to (Background: Brightness)\nend\nset [brightness v] effect to (8)\n\nwhen I receive [setup v]\nset [brightness v] effect to (8)\n\n@Thumbnail\n\nwhen flag clicked\nforever\n    hide\n    go to x: (0) y: (0)\nend\n\nwhen [timer v] > ((1) * ((Fps.timer) * (10)))\ngo to [front v] layer\nset size to (100) %\nshow\nhide variable [level v]\nhide variable [coins v]\nif <(username) = [Zieejo43]> then\n    broadcast (ResetGameData v)\nend\n\n@Sounds\n\nwhen I receive [die v]\nchange [deaths v] by (1)\nstart sound [hurt v]\n\nwhen I receive [coin v]\nstart sound [pop2 v]\n\nwhen I receive [jump v]\nstart sound [jump v]\n\nwhen I receive [step v]\nstart sound [footstep wood2 v]\n\nwhen I receive [land v]\nstart sound [footstep wood2 v]\n\nwhen I receive [killenemy v]\nstart sound [Coin v]\nstart sound [jump v]\n\nwhen flag clicked\nforever\n    set volume to (volume) %\nend\n\nwhen I receive [buttonclick v]\nstart sound [High Whoosh v]\n\nwhen I receive [firework v]\nstart sound (pick random (8) to (10))\n\nwhen I receive [bigwork v]\nstart sound [FIREWORK SOUND EFFECT4 v]\n\nwhen I receive [fireballexplotion v]\nstart sound (pick random (11) to (13))\n\nwhen I receive [bossland v]\nstart sound [Small explosion - Sound effect4 v]\n\n@PlayeCostume\n\nwhen I receive [setup v]\nwait (0.1) seconds\npoint in direction (90)\ngo to (player v)\nswitch costume to (standing v)\ngo to [front v] layer\nshow\nwait (0.85) seconds\nforever\n    if <(PlayerEditMenu) = [1]> then\n        go [backward v] (2) layers\n        wait until <(PlayerEditMenu) = [0]>\n    end\n    point in direction (90)\n    go to (player v)\n    change y by (-1.5)\n    go to [front v] layer\n    go [backward v] (2) layers\n    set size to (100) %\n    if <(Editing) = [1]> then\n        hide\n        stop [this script v]\n    end\n    if <(Dead) = [1]> then\n        switch costume to (death v)\n        stop [this script v]\n    end\n    set [costumedirection v] to (CostumeDirection)\n    set [costume v] to (Costume)\n    if <(costumeDirection) = [0]> then\n        switch costume to (join [run.l] (round (costume)))\n    end\n    if <(costumeDirection) = [1]> then\n        switch costume to (join [run.r] (round (costume)))\n    end\n    if <(Costume) = [-1]> then\n        switch costume to (standing v)\n        if <not <(blink) = [0]>> then\n            if <(blink) = [1]> then\n                switch costume to (blink v)\n            else\n                switch costume to (easter egg v)\n            end\n        end\n    end\nend\n\nwhen flag clicked\nhide\n\nwhen I receive [die v]\nshow\nswitch costume to (death v)\nset [yv v] to [15]\nchange y by (-10)\nrepeat until <<(yv) < [0]> or <(y position) > [170]>>\n    go to [front v] layer\n    change y by (yv)\n    turn right (15) degrees\n    change [yv v] by (-0.75)\nend\nset [yv v] to [-0.75]\nrepeat until <(y position) < [-180]>\n    go to [front v] layer\n    change y by (yv)\n    turn right (15) degrees\n    change [yv v] by (-0.75)\nend\nhide\nbroadcast (Setup v)\n\nwhen flag clicked\nset [blink v] to [0]\nforever\n    wait (0.2) seconds\n    set [blink v] to [0]\n    wait (pick random (1) to (4)) seconds\n    if <(pick random (1) to (750)) = [1]> then\n        set [blink v] to [1]\n    else\n        set [blink v] to [1]\n    end\nend\n\nset [blink v] to [2]\nwait (5) seconds\n\nwhen [timer v] > (1.5)\nhide\n\nwhen I receive [levelfinished v]\nhide\nbroadcast (Setup v)\n\n@TutorialText\n\nwhen flag clicked\nhide\nset size to (20) %\nforever\n    go to [front v] layer\n    switch costume to (join [Text] (Level))\n    go to x: (-70) y: (50)\n    if <(Level) = [11]> then\n        go to x: (0) y: (0)\n        set size to (90) %\n    end\nend\n\nwhen I receive [setup v]\nif <<<(size) = [20]> and <(PlayerLevel?) = [0]>> or <(Level) = [11]>> then\n    show\n    set size to (75) %\nend\n\nwhen I receive [click v]\nif <<<(size) > [20]> and <touching (mouse-pointer v)?>> and <(mouse y) < [125]>> then\n    if <(Level) = [1]> then\n        if <<<(size) > [20]> and <touching (mouse-pointer v)?>> and <(mouse y) < [100]>> then\n            hide\n            set size to (0) %\n        end\n    else\n        hide\n        set size to (0) %\n    end\nend\n\n@Music\n\nwhen I receive [setup v]\nif <(PlayerLevel?) = [1]> then\n    set [play.repeate v] to [1]\n    set [play.song v] to [3]\n    broadcast (Playsong v)\nelse\n    if <(Level) = [11]> then\n        set [play.repeate v] to [0]\n        stop all sounds\n    else\n        if <(Level) = [10]> then\n            set [play.repeate v] to [1]\n            set [play.song v] to [2]\n            broadcast (Playsong v)\n        else\n            set [play.repeate v] to [1]\n            set [play.song v] to [4]\n            broadcast (Playsong v)\n        end\n    end\nend\n\nwhen flag clicked\nset [pitch v] effect to (0)\nset [playing.song v] to [0]\nset [play.repeate v] to [1]\nset [play.song v] to [4]\nbroadcast (Playsong v)\n\nwhen I receive [playsong v]\nif <<not <(Playing.song) = (Play.Song)>> or <(Playing.song) = [0]>> then\n    broadcast (StartSong v)\nend\n\nwhen I receive [startsong v]\nset [playing.song v] to (Play.Song)\nif <(Play.Song) = [1]> then\n    set volume to ((volume) / (4)) %\nend\nif <(Play.Song) = [2]> then\n    set volume to ((volume) / (4)) %\nend\nif <(Play.Song) = [3]> then\n    set volume to ((volume) / (4)) %\nend\nif <(Play.Song) = [4]> then\n    set volume to (volume) %\nend\nrepeat (2)\n    stop all sounds\nend\nif <(Play.repeate) = [1]> then\n    repeat until <<(Level) = [11]> and <(StartMenuStage) = [4]>>\n        play sound (Play.Song) until done\n        if <(Play.Song) = [4]> then\n            play sound ((Play.Song) + (1)) until done\n        end\n    end\nelse\n    play sound (Play.Song) until done\nend\n\nwhen I receive [loadplayerlevel v]\nif <(Editing) = [1]> then\n    set [play.repeate v] to [1]\n    set [play.song v] to [3]\n    broadcast (Playsong v)\nend\n\nwhen I receive [startmenu v]\nset [play.repeate v] to [1]\nset [play.song v] to [4]\nbroadcast (Playsong v)\n\n@StartMenu\n\nwhen I receive [startmenu v]\nCreateClones\n\nwhen I start as a clone\nshow\nset [ghost v] effect to (100)\nrepeat (20)\n    change [ghost v] effect by (-5)\nend\n\nwhen flag clicked\nhide\n\ndefine CreateClones\nset [id v] to [1]\nrepeat (14)\n    create clone of (_myself_ v)\n    change [id v] by (1)\nend\n\nwhen I start as a clone\nset [selectedbutton v] to [2]\nset [startmenustage v] to [0]\npoint in direction (90)\nset y to ((-25) - (((selectedbutton) - (1)) * (35)))\nforever\n    show\n    switch costume to (id)\n    set size to (100) %\n    if <(id) > [8]> then\n        hide\n    end\n    if <(id) = [1]> then\n        go to x: (0) y: (100)\n        set size to (105) %\n    end\n    if <(id) = [2]> then\n        point in direction ((90) + (vel.variable))\n        go to x: (150) y: (-65)\n        set size to (50) %\n    end\n    if <(id) = [3]> then\n        set x to (-78)\n        change y by ((((-25) - (((selectedbutton) - (1)) * (35))) - (y position)) / (3))\n        set size to (75) %\n    end\n    if <<(id) > [3]> and <[8] > (id)>> then\n        go to x: (-80) y: ((-25) - (((id) - (4)) * (35)))\n        set size to (75) %\n        if <<touching (mouse-pointer v)?> and <not <(id) = [4]>>> then\n            set [selectedbutton v] to ((id) - (3))\n        end\n        if <(id) = [4]> then\n            hide\n        end\n        if <(id) = [5]> then\n            switch costume to (playbutton v)\n        end\n    end\n    if <(id) = [8]> then\n        set x to (-78)\n        set y to ((-25) - (((id) - (5)) * (35)))\n        set size to (75) %\n        if <(StartMenuStage) = [0]> then\n            hide\n        else\n            set [selectedbutton v] to [4]\n        end\n    end\n    if <<<<(id) > [0]> and <[8] > (id)>> and <not <(id) = [3]>>> and <<not <(StartMenuStage) = [0]>> and <not <(StartMenuStage) = [4]>>>> then\n        hide\n    end\n    if <(StartMenuStage) = [2]> then\n        if <(id) = [1]> then\n            show\n            set size to (100) %\n            switch costume to (yourlevels v)\n            go to x: (0) y: (0)\n        end\n        if <<(id) > [8]> and <(id) < [15]>> then\n            show\n            set size to (105) %\n            switch costume to (join [level] ((id) - (8)))\n            go to x: ((-100) + (((id) - (9)) * (100))) y: (70)\n            if <(id) > [11]> then\n                go to x: ((-100) + (((id) - (12)) * (100))) y: (-40)\n            end\n            set [ghost v] effect to (0)\n            if <((id) - (9)) > ((length of [playerslevels v]) / (300))> then\n                switch costume to (empty v)\n                set [ghost v] effect to (75)\n            end\n            if <((id) - (9)) = ((length of [playerslevels v]) / (300))> then\n                switch costume to (createlevel v)\n            end\n        end\n    end\n    if <<(id) = [1]> and <(StartMenuStage) = [3]>> then\n        show\n        set size to (100) %\n        switch costume to (controlls v)\n        go to x: (0) y: (0)\n    end\n    if <(rating) = [1]> then\n        wait until <(rating) = [0]>\n    end\nend\n\nwhen I receive [click v]\nif <(rating) = [0]> then\n    if <touching (mouse-pointer v)?> then\n        if <<<(id) > [3]> and <[8] > (id)>> and <(StartMenuStage) = [0]>> then\n            wait (0.1) seconds\n            if <(id) > [4]> then\n                broadcast (ButtonClick v)\n                set [startmenustage v] to ((id) - (4))\n                if <(id) = [5]> then\n                    set [playerlevel? v] to [0]\n                    broadcast (ButtonClick v)\n                    broadcast (Setup v)\n                    set [startmenustage v] to [4]\n                end\n            end\n            if <(id) = [5]> then\n            end\n        end\n        if <<(id) = [8]> and <not <(StartMenuStage) = [0]>>> then\n            broadcast (ButtonClick v)\n            wait (0.1) seconds\n            set [startmenustage v] to [0]\n        end\n        if <<<<(id) > [8]> and <[15] > (id)>> and <((id) - (10)) < ((length of [playerslevels v]) / (300))>> and <(StartMenuStage) = [2]>> then\n            set [load.playerlevel.id v] to ((id) - (8))\n            if <((id) - (9)) = ((length of [playerslevels v]) / (300))> then\n                set [editing v] to [1]\n            else\n                if <((mouse y) - (y position)) > [0]> then\n                    set [editing v] to [0]\n                else\n                    set [editing v] to [1]\n                end\n            end\n            set [startmenustage v] to [4]\n            broadcast (LoadPlayerLevel v)\n        end\n    end\nend\n\nwhen I receive [setup v]\ndelete this clone\n\nwhen I start as a clone\nset [vel.variable v] to [0]\nset [vel.power v] to [0.05]\nset [vel.time v] to [50]\nforever\n    set [vel v] to (((vel.power) * (vel.time)) / (2))\n    repeat (vel.time)\n        change [vel v] by (() - (vel.power))\n        change [vel.variable v] by (vel)\n    end\n    set [vel v] to ((() - ((vel.power) * (vel.time))) / (2))\n    repeat (vel.time)\n        change [vel v] by (vel.power)\n        change [vel.variable v] by (vel)\n    end\nend\n\nwhen I receive [startmenu v]\nhide variable [level v]\n\nwhen I receive [setup v]\nshow variable [level v]\n\nwhen I receive [loadplayerlevel v]\ndelete this clone\n\n@PlayerEditiorUI\n\nwhen I receive [loadplayerlevel v]\nset [playereditmenu v] to [0]\n\nwhen flag clicked\nhide\nhide variable [selectedblockname v]\nset [playereditmenu v] to [0]\nset [selectedblocknameshowtimer v] to [6]\nif <(length of [playerslevels v]) = [0]> then\n    set [playereditor.tutorialstage v] to [1]\nend\n\nwhen [space v] key pressed\nif <(StartMenuStage) = [4]> then\n    if <(PlayerLevel?) = [1]> then\n        if <(PlayerEditMenu) = [0]> then\n            set [playereditmenu v] to [1]\n            if <(PlayerEditor.TutorialStage) = [1]> then\n                set [playereditor.tutorialstage v] to [2]\n            end\n        else\n            set [playereditmenu v] to [0]\n        end\n    end\nend\n\nwhen I start as a clone\nforever\n    go to x: (0) y: (0)\n    if <(SelectedBlockNameShowTimer) > [5]> then\n        hide variable [selectedblockname v]\n    else\n        show variable [selectedblockname v]\n        change [selectedblocknameshowtimer v] by (Fps.timer)\n    end\n    if <(id) = [0]> then\n        hide\n        if <(PlayerEditor.TutorialStage) = [1]> then\n            switch costume to (costume1 v)\n            set [ghost v] effect to (0)\n            show\n        end\n        if <(PlayerEditor.TutorialStage) = [2]> then\n            switch costume to (costume5 v)\n            set [ghost v] effect to (0)\n            show\n        end\n        if <(PlayerEditMenu) = [1]> then\n            set [ghost v] effect to (20)\n            show\n            switch costume to (costume2 v)\n        end\n    end\n    if <(id) = [1]> then\n        hide\n        go to [front v] layer\n        if <(PlayerEditMenu) = [1]> then\n            if <(Editing) = [1]> then\n                switch costume to (costume3 v)\n            else\n                switch costume to (costume4 v)\n            end\n            if <not <(PlayerEditor.TutorialStage) = [0]>> then\n                switch costume to (costume6 v)\n            end\n            show\n        end\n    end\nend\n\nwhen I receive [loadplayerlevel v]\nset [id v] to [0]\nrepeat (2)\n    create clone of (_myself_ v)\n    change [id v] by (1)\nend\n\nwhen I receive [click v]\nif <<(id) = [1]> and <<<([abs v] of (mouse x) ) < [160]> and <([abs v] of (mouse y) ) < [75]>> and <(PlayerEditMenu) = [1]>>> then\n    if <[25] < (mouse y)> then\n        set [playereditmenu v] to [0]\n    else\n        if <(mouse y) < [-25]> then\n            if <<(PlayerEditor.TutorialStage) = [0]> and <(Editing) = [1]>> then\n                set [playereditmenu v] to [0]\n                set [editing v] to [0]\n                broadcast (SavePlayerLevel v)\n                broadcast (StartMenu v)\n                set [startmenustage v] to [2]\n            end\n        else\n            if <(Editing) = [0]> then\n                set [playereditmenu v] to [0]\n                set [editing v] to [1]\n                broadcast (LoadPlayerLevel v)\n            else\n                if <(PlayerEditor.TutorialStage) = [0]> then\n                    set [playereditmenu v] to [0]\n                    set [editing v] to [0]\n                    broadcast (SavePlayerLevel v)\n                    broadcast (Setup v)\n                end\n            end\n        end\n    end\nend\n\nwhen I receive [selectedblockchange v]\nset [selectedblocknameshowtimer v] to [0]\nif <(PlayerEditor.TutorialStage) = [2]> then\n    set [playereditor.tutorialstage v] to [0]\nend\nset [selectedblockname v] to (item ((1) + (SelectedBlock)) of [blocknames v])\n\nwhen I receive [startmenu v]\ndelete this clone\n\n@FireWorks\n\ndefine CreateFireWork (color) (amount) (x) (y) (velrange)\nset [color v] effect to (color)\ngo to [front v] layer\nrepeat (amount)\n    hide\n    go to x: (x) y: (y)\n    point in direction (pick random (0) to (360))\n    set [x v] to (x position)\n    set [y v] to (y position)\n    move (pick random (() - (velrange)) to (velrange)) steps\n    set [xv v] to ((x) - (x position))\n    set [yv v] to ((y) - (y position))\n    create clone of (_myself_ v)\nend\n\nwhen I start as a clone\nset [ghost v] effect to (0)\nshow\npoint in direction (90)\nrepeat until <([abs v] of ((xv) + (yv)) ) < [1]>\n    change x by (xv)\n    change y by (yv)\n    set [xv v] to ((round (((xv) * (0.97)) * (100000))) / (100000))\n    set [yv v] to ((round (((yv) * (0.97)) * (100000))) / (100000))\nend\nrepeat (10)\n    go to [front v] layer\n    change [ghost v] effect by (10)\n    change x by (xv)\n    change y by (yv)\n    set [xv v] to ((round (((xv) * (0.97)) * (100000))) / (100000))\n    set [yv v] to ((round (((yv) * (0.97)) * (100000))) / (100000))\nend\ndelete this clone\n\nwhen I receive [setup v]\nif <<(Level) = [11]> and <(PlayerLevel?) = [0]>> then\n    repeat (10)\n        wait (2) seconds\n        CreateFireWork (pick random (0) to (200)) [40] (pick random (-100) to (100)) (pick random (-50) to (150)) [4.0]\n        broadcast (FireWork v)\n    end\n    broadcast (BigWork v)\n    CreateFireWork (pick random (0) to (200)) [50] (pick random (-100) to (-50)) (pick random (75) to (150)) [4.0]\n    CreateFireWork (pick random (0) to (200)) [50] (pick random (-100) to (-50)) (pick random (-50) to (25)) [4.0]\n    CreateFireWork (pick random (0) to (200)) [50] (pick random (50) to (100)) (pick random (75) to (150)) [4.0]\n    CreateFireWork (pick random (0) to (200)) [50] (pick random (50) to (100)) (pick random (-50) to (25)) [4.0]\nend\n\n@Boss\n\nwhen flag clicked\nset [clone v] to [0]\nhide\n\nwhen I receive [setup v]\nif <<<(Level) = [10]> and <(Clone) = [0]>> and <(PlayerLevel?) = [0]>> then\n    show\n    set size to (100) %\n    switch costume to (boss v)\n    go to x: (189) y: (300)\n    set [bossstage v] to [1]\n    set [bossstagetimer v] to [0]\n    repeat until <<not <(Level) = [10]>> and <not <(StartMenuStage) = [4]>>>\n        change [bossstagetimer v] by (Fps.timer)\n        change [yv v] by (-0.3)\n        change y by (yv)\n        if <touching (level v)?> then\n            change y by (() - (yv))\n            if <[-9] > (yv)> then\n                broadcast (BossLand v)\n            end\n            set [yv v] to [0]\n        end\n        if <<touching (player v)?> and <(Dead) = [0]>> then\n            broadcast (Die v)\n        end\n        if <(BossStageTimer) > [5]> then\n            set [bossstagetimer v] to [0]\n            broadcast (BossTing v)\n            if <(BossStage) = [4]> then\n                set [bossstage v] to [1]\n            else\n                change [bossstage v] by (1)\n            end\n        end\n    end\n    hide\nend\nhide\n\nwhen I receive [bossting v]\nif <(Clone) = [0]> then\n    if <<(BossStage) = [1]> or <(BossStage) = [2]>> then\n        broadcast (FireBall v)\n    end\n    if <(BossStage) = [3]> then\n        broadcast (FireBall v)\n        wait (1) seconds\n        broadcast (FireBall v)\n        wait (1) seconds\n        broadcast (FireBall v)\n    end\n    if <(BossStage) = [4]> then\n        set [yv v] to [12]\n    end\nend\n\nwhen I start as a clone\nset [clone v] to [1]\nswitch costume to (fireball v)\nshow\nrepeat until <<<touching (level v)?> or <touching (player v)?>> or <touching (_edge_ v)?>>\n    set size to (300) %\n    move (vel) steps\nend\nif <<touching (player v)?> and <(Dead) = [0]>> then\n    broadcast (Die v)\n    broadcast (FireBallExplotion v)\n    move (-25) steps\n    turn left (90) degrees\n    repeat (7)\n        next costume\n        set size to (35) %\n    end\n    delete this clone\nelse\n    broadcast (FireBallExplotion v)\n    if <touching (level v)?> then\n        point in direction (90)\n        change y by (25)\n    else\n        point in direction (180)\n        change x by (25)\n    end\n    repeat (7)\n        next costume\n        set size to (35) %\n    end\n    delete this clone\nend\n\nwhen I receive [fireball v]\nif <(Clone) = [0]> then\n    switch costume to (fireball v)\n    point towards (player v)\n    change y by (25)\n    set [vel v] to [5]\n    create clone of (_myself_ v)\n    point in direction (90)\n    change y by (-25)\n    switch costume to (boss v)\nend\n\nwhen I receive [setup v]\ndelete this clone\n\n@Stars\n\nwhen I receive [startmenu v]\nif <<<(Level) > [3]> and <(HasRated) = [0]>> and <(Asked) = [0]>> then\n    CreateClones\n    set [stars v] to [0]\n    set [rating v] to [1]\n    set [clicks v] to [0]\n    set [asked v] to [1]\nend\n\nwhen flag clicked\nset [stars v] to ((round (((☁ TotalStars) / (☁ Ratings)) * (10))) / (10))\nset [rating v] to [0]\nhide\n\ndefine CreateClones\nset [id v] to [0]\nrepeat (5)\n    create clone of (_myself_ v)\n    change [id v] by (1)\nend\n\nwhen I receive [rategame v]\nif <(HasRated) = [0]> then\n    set [hasrated v] to [1]\n    change [☁ ratings v] by (1)\n    change [☁ totalstars v] by (stars)\n    set [stars v] to ((round (((☁ TotalStars) / (☁ Ratings)) * (10))) / (10))\n    wait (0.1) seconds\n    set [rating v] to [0]\nend\ndelete this clone\n\nwhen I start as a clone\nforever\n    if <<([abs v] of (mouse x) ) < [120]> and <([abs v] of (mouse y) ) < [20]>> then\n        set [stars v] to ((round (((2.75) + ((mouse x) / (38))) * (2))) / (2))\n    end\n    if <(stars) > [5]> then\n        set [stars v] to [5]\n    end\n    if <(stars) < [0]> then\n        set [stars v] to [0]\n    end\n    show\n    go to [front v] layer\n    if <(id) = [0]> then\n        go to x: (0) y: (10)\n        switch costume to (background v)\n        set [ghost v] effect to (5)\n        set size to (100) %\n    end\n    if <(id) = [1]> then\n        go to x: (0) y: (20)\n        switch costume to (rate my game v)\n        set size to (65) %\n    end\n    if <(id) = [2]> then\n        go to x: (0) y: (0)\n        switch costume to (join (stars) [])\n        set size to (200) %\n    end\n    if <(id) = [3]> then\n        if <not <(Clicks) = [1]>> then\n            hide\n        end\n        go to x: (0) y: (-50)\n        switch costume to (click again to confirm v)\n        set size to (45) %\n    end\n    if <(id) = [4]> then\n        go to x: (135) y: (-150)\n        switch costume to (costume1 v)\n        set size to (75) %\n    end\nend\n\nwhen I receive [click v]\nif <<([abs v] of (mouse x) ) < [95]> and <([abs v] of (mouse y) ) < [20]>> then\n    if <(id) = [0]> then\n        change [clicks v] by (1)\n        if <(Clicks) = [2]> then\n            broadcast (RateGame v)\n        end\n    end\nelse\n    if <<([abs v] of (mouse x) ) < [95]> and <([abs v] of (mouse y) ) < [50]>> then\nend\n\n@Story\n\nwhen flag clicked\nset [startmenustage v] to [0]\nif <(Level) = [11]> then\n    set [level v] to [1]\nend\nif <(Story) = [1]> then\n    set [story v] to [0]\n    switch costume to (newspaper v)\n    create clone of (_myself_ v)\n    switch costume to (background v)\n    create clone of (_myself_ v)\n    go to x: (0) y: (0)\n    show\n    go to [front v] layer\n    switch costume to (costume1 v)\n    set [ghost v] effect to (0)\n    wait (1) seconds\n    repeat (40)\n        change [ghost v] effect by (2.5)\n    end\n    hide\n    wait until <not <mouse down?>>\n    wait until <mouse down?>\nend\nbroadcast (StartMenu v)\n\nwhen I start as a clone\ngo to x: (0) y: (0)\nshow\ngo to [back v] layer\nset size to (101) %\n\nwhen I receive [startmenu v]\nhide\ndelete this clone\n\n