The Cube - a platformer


@Stage\n\nwhen flag clicked\nforever\n    play sound (pick random (1) to (3)) until done\nend\n\nwhen flag clicked\nforever\n    switch backdrop to (Level)\nend\n\nset [level v] to [15]\n\n@Ground\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (kostium1 v)\nset [level v] to [1]\nforever\n    switch costume to (Level)\nend\n\n@Lava and invisible\n\nwhen flag clicked\nforever\n    if <<(Level) = [10]> or <(Level) = [9]>> then\n        go to [front v] layer\n    else\n        go to [back v] layer\n    end\nend\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (kostium1 v)\nshow\nforever\n    switch costume to (Level)\nend\n\n@The Cube\n\nwhen flag clicked\nReset Level\nforever\n    switch costume to (hitbox v)\n    Controls - Jump, Crouch\n    Gravity\n    Check Hit Ceiling / Floor <(speed y) > [0]>\n    if <(y position) < [-189]> then\n        Reset Level\n    end\n    if <(wall jump) > [0]> then\n        change [wall jump v] by (-1)\n    else\n        Controls - Left and Right\n    end\n    if <(speed x) < [-0.5]> then\n        Walk (-90) (speed x) max steep (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n    else\n        if <(speed x) > [0.5]> then\n            Walk (90) (speed x) max steep (([ceiling v] of ([abs v] of ((speed x) * (1.3)) ) ) + (1))\n        else\n            set [frame v] to [0]\n        end\n    end\n    Set Costume\n    broadcast (tick v) and wait\n    switch costume to (walk8 v)\nend\n\ndefine Controls - Left and Right\nset [speed x v] to ((speed x) * (0.7))\nif <key (a v) pressed?> then\n    change [speed x v] by (-2)\n    point in direction (90)\nend\nif <key (d v) pressed?> then\n    change [speed x v] by (2)\n    point in direction (90)\nend\n\ndefine Walk (direction) (speed) max steep (max steep)\npoint in direction (direction)\nchange x by (speed)\nchange [frame v] by (([abs v] of (speed) ) / (8))\nset [slope v] to [0]\nGet Touching <(in platforrm) = [1]>\nrepeat until <<(slope) = (max steep)> or <(touch) = [0]>>\n    change y by (1)\n    change [slope v] by (1)\n    Get Touching <(in platforrm) = [1]>\nend\nif <(slope) = (max steep)> then\n    change x by ((0) - (speed))\n    change y by ((0) - (slope))\n    if <<(touch) = [1]> and <(in platforrm) = [1]>> then\n        set [in platforrm v] to [2]\n        Walk (direction) (speed) max steep (max steep)\n        if <(speed x) = [0]> then\n            set [in platforrm v] to [1]\n        end\n    else\n        if <<<key (w v) pressed?> and <([abs v] of (speed) ) > [3.5]>> and <(touch) > [1]>> then\n            set [speed x v] to ((-1.2) * (speed))\n            set [speed y v] to [11]\n            set [falling? v] to [6]\n            set [wall jump v] to [15]\n        else\n            set [speed x v] to [0]\n        end\n    end\nend\n\ndefine Controls - Jump, Crouch\nif <key (w v) pressed?> then\n    if <<(jump key) = [0]> and <(falling?) < [3]>> then\n        set [speed y v] to [14]\n        set [falling? v] to [6]\n        set [jump key v] to [1]\n    end\nelse\n    set [jump key v] to [0]\nend\nif <key (s v) pressed?> then\n    set [in platforrm v] to [2]\nend\n\ndefine Gravity\nif <<(speed y) < [4]> or <key (w v) pressed?>> then\n    change [speed y v] by (-1)\nelse\n    change [speed y v] by (-2)\nend\nchange y by (speed y)\nchange [falling? v] by (1)\n\ndefine Check Hit Ceiling / Floor <up?>\nGet Touching \nif <(touch) = [0]> then\n    set [in platforrm v] to [1]\nelse\n    if <<up?> and <(touch) = [1]>> then\n        set [in platforrm v] to [2]\n    end\nend\nrepeat until <(touch) < (in platforrm)>\n    if <up?> then\n        change y by (-1)\n    else\n        change y by (1)\n        set [falling? v] to [0]\n    end\n    Get Touching <not <up?>>\n    set [speed y v] to [0]\nend\n\nwhen flag clicked\nforever\n    if <touching (trampoline3 v)?> then\n        broadcast (Bounce3 v)\n        set [speed y v] to [20]\n    end\nend\n\nwhen flag clicked\nforever\n    if <<touching (knife v)?> and <(Level) = [10]>> then\n        broadcast (show v)\n        Reset Level\n    end\nend\n\nwhen I receive [ouch v]\nReset Level\n\nwhen flag clicked\nforever\n    if <touching (portal v)?> then\n        go to (portal2 v)\n    end\nend\n\ndefine Reset Level\nset size to (20) %\nset rotation style [left-right v]\nif <(Level) = [6]> then\n    go to x: (-222) y: (-39)\nelse\n    if <(Level) = [7]> then\n        go to x: (-145) y: (-118)\n    else\n        if <<(Level) = [9]> or <(Level) = [10]>> then\n            go to x: (-210) y: (-10)\n        else\n            if <(Level) = [13]> then\n                go to x: (-208) y: (88)\n            else\n                if <(Level) = [15]> then\n                    go to x: (-208) y: (88)\n                else\n                    if <(Level) = [17]> then\n                        go to x: (-150) y: (-20)\n                    else\n                        go to x: (-222) y: (-118)\n                    end\n                end\n            end\n        end\n    end\nend\nreset timer\nshow\nset [speed x v] to [0]\nset [speed y v] to [0]\nset [falling? v] to [10]\nset [in platforrm v] to [1]\nset [frame v] to [0]\nset [wall jump v] to [0]\nset [killed\(16\) v] to [0]\n\ndefine Get Touching <check platform?>\nif <touching (ground v)?> then\n    set [touch v] to [9]\nelse\n    if <<check platform?> and <touching (platforms v)?>> then\n        set [touch v] to [1]\n    else\n        set [touch v] to [0]\n    end\nend\n\ndefine Set Costume\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    if <touching color (#ff0000)?> then\n        Reset Level\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (next level v)?> then\n        change [level v] by (1)\n        broadcast (Next Level v)\n        Reset Level\n    end\nend\n\nwhen [r v] key pressed\nReset Level\n\nwhen flag clicked\nforever\n    change [color v] effect by (1)\nend\n\nwhen flag clicked\nforever\n    if <touching (trampoline v)?> then\n        broadcast (Bounce v)\n        set [speed y v] to [20]\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (trampoline2 v)?> then\n        broadcast (Bounce2 v)\n        set [speed y v] to [20]\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (duszek1 v)?> then\n        set [level v] to [1]\n        broadcast (Next Level v)\n        Reset Level\n    end\nend\n\n@Next level\n\nwhen flag clicked\nhide variable [speed y v]\nset [speed y v] to [0]\nset size to (60) %\nshow\ngo to x: (209) y: (-92)\nforever\n    set [speed y v] to [5]\n    repeat (11)\n        change y by (Speed y)\n        change [speed y v] by (-1)\n    end\nend\n\nwhen I start as a clone\nset size to (30) %\npoint in direction (pick random (-180) to (180))\nrepeat (10)\n    move (1) steps\n    change [ghost v] effect by (10)\nend\ndelete this clone\n\nwhen I receive [next level v]\nshow\nif <<(Level) = [1]> or <<(Level) = [2]> or <(Level) = [3]>>> then\n    set [speed y v] to [5]\n    go to x: (209) y: (-92)\nelse\n    if <(Level) = [4]> then\n        set [speed y v] to [5]\n        go to x: (202) y: (100)\n    else\n        if <(Level) = [5]> then\n            set [speed y v] to [5]\n            go to x: (209) y: (-92)\n        else\n            if <(Level) = [6]> then\n                set [speed y v] to [5]\n                go to x: (209) y: (10)\n            else\n                if <(Level) = [7]> then\n                    set [speed y v] to [5]\n                    go to x: (209) y: (-92)\n                else\n                    if <(Level) = [8]> then\n                        set [speed y v] to [5]\n                        go to x: (-211) y: (110)\n                    else\n                        if <(Level) = [9]> then\n                            set [speed y v] to [5]\n                            go to x: (100) y: (140)\n                        else\n                            if <(Level) = [10]> then\n                                hide\n                            else\n                                if <(Level) = [11]> then\n                                    hide\n                                else\n                                    if <(Level) = [12]> then\n                                        hide\n                                        set [speed y v] to [5]\n                                        go to x: (209) y: (-92)\n                                    else\n                                        if <(Level) = [13]> then\n                                            show\n                                            set [speed y v] to [5]\n                                            go to x: (-200) y: (-100)\n                                        else\n                                            if <(Level) = [14]> then\n                                                show\n                                                set [speed y v] to [5]\n                                                go to x: (209) y: (115)\n                                            else\n                                                if <(Level) = [15]> then\n                                                    show\n                                                    set [speed y v] to [5]\n                                                    go to x: (209) y: (115)\n                                                else\n                                                    if <(Level) = [16]> then\n                                                        hide\n                                                    else\n                                                        if <(Level) = [17]> then\n                                                            show\n                                                            set [speed y v] to [5]\n                                                            go to x: (209) y: (115)\n                                                        else\n                                                            hide\n                                                        end\n                                                    end\n                                                end\n                                            end\n                                        end\n                                    end\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nwhen flag clicked\nforever\n    if <(Level) = [5]> then\n        create clone of (cubes v)\n        wait (pick random (1) to (2)) seconds\n    end\nend\n\nwhen I receive [show v]\ngo to (the cube v)\nshow\n\nwhen I receive [died v]\nif <<(Level) = [11]> or <(Level) = [12]>> then\n    set [speed y v] to [5]\n    go to x: (209) y: (-92)\n    show\nelse\n    if <<(Level) = [16]> and <(Killed\(16\)) = [3]>> then\n        set [speed y v] to [5]\n        go to x: (209) y: (-92)\n        show\n    else\n        if <(Level) = [16]> then\n            change [killed\(16\) v] by (1)\n        end\n    end\nend\n\nwhen flag clicked\nset [killed\(16\) v] to [0]\nhide variable [killed\(16\) v]\n\n@Trampoline\n\nwhen flag clicked\nswitch costume to (kostium1 v)\nhide\n\nwhen I receive [bounce v]\nrepeat (5)\n    next costume\nend\nrepeat (5)\n    switch costume to ((costume [number v]) - (1))\nend\nswitch costume to (kostium1 v)\n\nwhen I receive [next level v]\nif <<(Level) = [1]> or <<(Level) = [2]> or <(Level) = [3]>>> then\n    hide\nelse\n    if <(Level) = [4]> then\n        show\n        go to x: (69) y: (-109)\n    else\n        if <(Level) = [5]> then\n            show\n            go to x: (-120) y: (-109)\n        else\n            if <(Level) = [8]> then\n                show\n                go to x: (140) y: (-109)\n            else\n                if <(Level) = [12]> then\n                    show\n                    go to x: (-70) y: (-116)\n                else\n                    if <(Level) = [17]> then\n                        show\n                        go to x: (-150) y: (-110)\n                    else\n                        hide\n                    end\n                end\n            end\n        end\n    end\nend\n\n@Trampoline2\n\nshow\ngo to x: (69) y: (-109)\n\nwhen flag clicked\nswitch costume to (kostium1 v)\nhide\n\nwhen I receive [bounce2 v]\nrepeat (5)\n    next costume\nend\nrepeat (5)\n    switch costume to ((costume [number v]) - (1))\nend\nswitch costume to (kostium1 v)\n\nwhen I receive [next level v]\nif <(Level) = [5]> then\n    show\n    go to x: (120) y: (-109)\nelse\n    hide\nend\n\n@Cubes\n\nwhen I start as a clone\nforever\n    change [color v] effect by (1)\nend\n\nwhen I start as a clone\nset [color v] effect to (pick random (1) to (100))\nshow\ngo to x: (247) y: (80)\nset [spawn repeat v] to (pick random (100) to (200))\nrepeat (Spawn repeat)\n    move ((480) / (Spawn repeat)) steps\nend\ndelete this clone\n\nwhen I start as a clone\nforever\n    if <not <(Level) = [5]>> then\n        delete this clone\n    end\nend\n\ndefine Reset Level\n\ndefine Get Touching <check platform?>\nif <touching (ground v)?> then\n    set [touch v] to [9]\nelse\n    if <<check platform?> and <touching (platforms v)?>> then\n        set [touch v] to [1]\n    else\n        set [touch v] to [0]\n    end\nend\n\ndefine Set Costume\n\nwhen flag clicked\nforever\n    go to [front v] layer\n    if <touching color (#ff0000)?> then\n        Reset Level\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (next level v)?> then\n        Reset Level\n        change [level v] by (1)\n        broadcast (Next Level v)\n    end\nend\n\nwhen [r v] key pressed\nReset Level\n\nwhen flag clicked\nforever\n    change [color v] effect by (1)\nend\n\nwhen flag clicked\nforever\n    if <touching (trampoline v)?> then\n        broadcast (Bounce v)\n        set [speed y v] to [20]\n    end\nend\n\nwhen flag clicked\nforever\n    if <touching (trampoline2 v)?> then\n        broadcast (Bounce2 v)\n        set [speed y v] to [20]\n    end\nend\n\nwhen flag clicked\nset [spawn repeat v] to [0]\nhide variable [spawn repeat v]\nhide\n\n@Trampoline3\n\nwhen [r v] key pressed\nif <(Level) = [6]> then\n    show\nend\n\nwhen flag clicked\ngo to x: (25) y: (-145)\nswitch costume to (kostium1 v)\nforever\n    if <not <(Level) = [6]>> then\n        hide\n    end\nend\n\nwhen I receive [bounce3 v]\nrepeat (5)\n    next costume\nend\nrepeat (5)\n    switch costume to ((costume [number v]) - (1))\nend\nswitch costume to (kostium1 v)\n\n@Platforms\n\nwhen flag clicked\ngo to x: (0) y: (0)\nswitch costume to (kostium1 v)\nshow\nforever\n    switch costume to (Level)\nend\n\n@Knife\n\nwhen flag clicked\nset [x from cube v] to [0]\nhide variable [x from cube v]\npoint in direction (90)\nset size to (15) %\nset [spd y v] to [0]\nhide variable [spd y v]\nhide\ngo to x: (182) y: (15)\nforever\n    if <(Level) = [10]> then\n        repeat (10)\n            change y by (1)\n        end\n        repeat (10)\n            change y by (-1)\n        end\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [10]> then\n    show\nelse\n    hide\nend\n\n@Zombie\n\ndefine Reset Level\nbroadcast (Next Level v)\nset [direction v] to [1]\nset [ghost v] effect to (0)\nset size to (20) %\nset rotation style [left-right v]\nif <(Level) = [11]> then\n    show\n    go to x: (200) y: (-114)\nelse\n    if <(Level) = [12]> then\n        show\n        go to x: (0) y: (114)\n    else\n        if <(Level) = [16]> then\n            show\n            go to x: (0) y: (114)\n        else\n            hide\n        end\n    end\nend\n\nwhen [r v] key pressed\nReset Level\n\nwhen I receive [next level v]\nif <(Level) = [11]> then\n    go to x: (200) y: (-114)\n    show\n    set [ghost v] effect to (0)\n    forever\n        repeat until <(x position) > [210]>\n            change x by (5)\n            if <touching (the cube v)?> then\n                broadcast (Ouch v)\n                Reset Level\n            end\n            if <touching (knife-attack v)?> then\n                broadcast (Died v)\n                repeat (20)\n                    change [ghost v] effect by (5)\n                    hide\n                end\n                stop [this script v]\n            end\n        end\n        repeat until <[-210] > (x position)>\n            change x by (-5)\n            if <touching (the cube v)?> then\n                broadcast (Ouch v)\n                Reset Level\n            end\n            if <touching (knife-attack v)?> then\n                broadcast (Died v)\n                repeat (25)\n                    change [ghost v] effect by (4)\n                end\n                hide\n                stop [this script v]\n            end\n        end\n    end\nelse\n    if <(Level) = [12]> then\n        go to x: (0) y: (114)\n        show\n        set [ghost v] effect to (0)\n        forever\n            repeat until <(x position) > [210]>\n                change x by (5)\n                if <touching (the cube v)?> then\n                    broadcast (Ouch v)\n                    Reset Level\n                end\n                if <touching (knife-attack v)?> then\n                    broadcast (Died v)\n                    repeat (20)\n                        change [ghost v] effect by (5)\n                        hide\n                    end\n                    stop [this script v]\n                end\n            end\n            repeat until <[1] > (x position)>\n                change x by (-5)\n                if <touching (the cube v)?> then\n                    broadcast (Ouch v)\n                    Reset Level\n                end\n                if <touching (knife-attack v)?> then\n                    broadcast (Died v)\n                    repeat (25)\n                        change [ghost v] effect by (4)\n                    end\n                    hide\n                    stop [this script v]\n                end\n            end\n        end\n    else\n        if <(Level) = [16]> then\n            go to x: (200) y: (-114)\n            show\n            set [ghost v] effect to (0)\n            forever\n                repeat until <(x position) > [210]>\n                    change x by (5)\n                    if <touching (the cube v)?> then\n                        broadcast (Ouch v)\n                        Reset Level\n                    end\n                    if <touching (knife-attack v)?> then\n                        broadcast (Died v)\n                        repeat (20)\n                            change [ghost v] effect by (5)\n                            hide\n                        end\n                        stop [this script v]\n                    end\n                end\n                repeat until <[-210] > (x position)>\n                    change x by (-5)\n                    if <touching (the cube v)?> then\n                        broadcast (Ouch v)\n                        Reset Level\n                    end\n                    if <touching (knife-attack v)?> then\n                        broadcast (Died v)\n                        repeat (25)\n                            change [ghost v] effect by (4)\n                        end\n                        hide\n                        stop [this script v]\n                    end\n                end\n            end\n        else\n            hide\n        end\n    end\nend\n\nwhen flag clicked\nset [direction v] to [0]\nhide variable [direction v]\nhide\n\n@Knife-attack\n\nwhen [space v] key pressed\nset [x from cube v] to [10]\nif <(Level) > [10]> then\n    if <([direction v] of [the cube v]) = [90]> then\n        repeat (5)\n            point in direction (90)\n            show\n            go to (the cube v)\n            change x by (X from cube)\n            change y by (20)\n            change [x from cube v] by (5)\n        end\n        repeat (5)\n            point in direction (90)\n            show\n            go to (the cube v)\n            change x by (X from cube)\n            change y by (20)\n            change [x from cube v] by (-5)\n        end\n    else\n        repeat (5)\n            point in direction (-90)\n            show\n            go to (the cube v)\n            change x by (join [-] (X from cube))\n            change y by (20)\n            change [x from cube v] by (5)\n        end\n        repeat (5)\n            point in direction (-90)\n            show\n            go to (the cube v)\n            change x by (join [-] (X from cube))\n            change y by (20)\n            change [x from cube v] by (-5)\n        end\n    end\nend\nhide\nwait (0.3) seconds\n\nwhen flag clicked\nhide\n\n@Portal\n\nwhen flag clicked\nset [spd y v] to [0]\nhide variable [spd y v]\nset size to (50) %\nhide\nforever\n    set [spd y v] to [0.25]\n    repeat (51)\n        change y by (SPD Y)\n        change [spd y v] by (-0.01)\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [14]> then\n    set [spd y v] to [0.25]\n    show\n    go to x: (206) y: (-70)\nelse\n    if <(Level) = [15]> then\n        set [spd y v] to [0.25]\n        show\n        go to x: (40) y: (-130)\n    else\n        if <(Level) = [17]> then\n            set [spd y v] to [0.25]\n            show\n            go to x: (-150) y: (70)\n        else\n            hide\n        end\n    end\nend\n\n@Portal2\n\nwhen flag clicked\nhide variable [spd y v]\nset [spd y v] to [0]\nset [spd y v] to [0]\nhide variable [spd y v]\nset size to (50) %\nhide\nforever\n    set [spd y v] to [0.25]\n    repeat (51)\n        change y by (SpD y)\n        change [spd y v] by (-0.01)\n    end\nend\n\nwhen I receive [next level v]\nif <(Level) = [14]> then\n    set [spd y v] to [0.25]\n    show\n    go to x: (-206) y: (120)\nelse\n    if <(Level) = [15]> then\n        set [spd y v] to [0.25]\n        show\n        go to x: (50) y: (130)\n    else\n        if <(Level) = [17]> then\n            set [spd y v] to [0.25]\n            show\n            go to x: (90) y: (-60)\n        else\n            hide\n        end\n    end\nend\n\nset [level v] to [15]\n\n@Zombie2\n\ndefine Reset Level\nbroadcast (Next Level v)\nset [direction v] to [1]\nset [ghost v] effect to (0)\nset size to (20) %\nset rotation style [left-right v]\nif <(Level) = [16]> then\n    show\n    go to x: (200) y: (-114)\nelse\nend\n\nwhen [r v] key pressed\nReset Level\n\nwhen I receive [next level v]\nhide\nwait (0.9) seconds\nif <(Level) = [16]> then\n    go to x: (200) y: (-114)\n    show\n    set [ghost v] effect to (0)\n    forever\n        repeat until <(x position) > [210]>\n            change x by (5)\n            if <touching (the cube v)?> then\n                broadcast (Ouch v)\n                Reset Level\n            end\n            if <touching (knife-attack v)?> then\n                broadcast (Died v)\n                repeat (20)\n                    change [ghost v] effect by (5)\n                    hide\n                end\n                stop [this script v]\n            end\n        end\n        repeat until <[-210] > (x position)>\n            change x by (-5)\n            if <touching (the cube v)?> then\n                broadcast (Ouch v)\n                Reset Level\n            end\n            if <touching (knife-attack v)?> then\n                broadcast (Died v)\n                repeat (25)\n                    change [ghost v] effect by (4)\n                end\n                hide\n                stop [this script v]\n            end\n        end\n    end\nelse\nend\n\nwhen flag clicked\nset [direction v] to [0]\nhide variable [direction v]\nhide\n\n@Zombie3\n\ndefine Reset Level\nbroadcast (Next Level v)\nset [direction v] to [1]\nset [ghost v] effect to (0)\nset size to (20) %\nset rotation style [left-right v]\nif <(Level) = [16]> then\n    show\n    go to x: (200) y: (-114)\nelse\nend\n\nwhen [r v] key pressed\nReset Level\n\nwhen I receive [next level v]\nhide\nwait (1.8) seconds\nif <(Level) = [16]> then\n    go to x: (200) y: (-114)\n    show\n    set [ghost v] effect to (0)\n    forever\n        repeat until <(x position) > [210]>\n            change x by (5)\n            if <touching (the cube v)?> then\n                broadcast (Ouch v)\n                Reset Level\n            end\n            if <touching (knife-attack v)?> then\n                broadcast (Died v)\n                repeat (20)\n                    change [ghost v] effect by (5)\n                    hide\n                end\n                stop [this script v]\n            end\n        end\n        repeat until <[-210] > (x position)>\n            change x by (-5)\n            if <touching (the cube v)?> then\n                broadcast (Ouch v)\n                Reset Level\n            end\n            if <touching (knife-attack v)?> then\n                broadcast (Died v)\n                repeat (25)\n                    change [ghost v] effect by (4)\n                end\n                hide\n                stop [this script v]\n            end\n        end\n    end\nelse\nend\n\nwhen flag clicked\nset [direction v] to [0]\nhide variable [direction v]\nhide\n\n@Zombie4\n\ndefine Reset Level\nbroadcast (Next Level v)\nset [direction v] to [1]\nset [ghost v] effect to (0)\nset size to (20) %\nset rotation style [left-right v]\nif <(Level) = [16]> then\n    show\n    go to x: (200) y: (-114)\nelse\nend\n\nwhen [r v] key pressed\nReset Level\n\nwhen I receive [next level v]\nhide\nwait (2.7) seconds\nif <(Level) = [16]> then\n    go to x: (200) y: (-114)\n    show\n    set [ghost v] effect to (0)\n    forever\n        repeat until <(x position) > [210]>\n            change x by (5)\n            if <touching (the cube v)?> then\n                broadcast (Ouch v)\n                Reset Level\n            end\n            if <touching (knife-attack v)?> then\n                broadcast (Died v)\n                repeat (20)\n                    change [ghost v] effect by (5)\n                    hide\n                end\n                stop [this script v]\n            end\n        end\n        repeat until <[-210] > (x position)>\n            change x by (-5)\n            if <touching (the cube v)?> then\n                broadcast (Ouch v)\n                Reset Level\n            end\n            if <touching (knife-attack v)?> then\n                broadcast (Died v)\n                repeat (25)\n                    change [ghost v] effect by (4)\n                end\n                hide\n                stop [this script v]\n            end\n        end\n    end\nelse\nend\n\nwhen flag clicked\nset [direction v] to [0]\nhide variable [direction v]\nhide\n\n@Duszek1\n\nwhen flag clicked\ngo to x: (0) y: (0)\nset [ghost v] effect to (100)\nforever\n    if <(Level) = [18]> then\n        show\n    else\n        hide\n    end\nend\n\n@Duszek2\n\nwhen flag clicked\nhide\ngo to [front v] layer\ngo to x: (0) y: (0)\n\n