Platformer Creator #games #scrolling #platformer

Instructions: Play on turbowarp for higher quality and performance: https://turbowarp.org/434160871/fullscreen?hqpen\n\nMultiplayer scrolling platformer: https://scratch.mit.edu/projects/463302065/\n\n--Instructions--\nEditor mode:\nWASD or arrow keys to scroll\nTop left: play / pause\n2nd to top left: save(copy code then press "enter" to close)\n3rd to top left: load(paste code or leave blank to cancel)\n4th to top left: erase("c" + "enter" to clear entire level)\n5th to top left: rotate tile(you can also use "r")\n\nTop 3 tiles: player, checkpoint, end flag\n\nRight tiles: figure them out yourself\nEnemy currently unavailable\n\nBottom left: change theme\n\nPlayer mode:\nWASD or arrow keys to move the player\n\n--Updates--\nv1.1 - Player can only jump when direction is straight\nv1.2 - Turret can only shoot when player is in range\nv1.3 - Fixed flashing/disappearing block glitch | player script adjustments

@Stage\n\nwhen flag clicked\nforever\n    switch backdrop to (theme)\nend\n\n@Lag Reduction\n\n@Intro\n\nwhen flag clicked\nhide\nswitch costume to (background v)\ncreate clone of (_myself_ v)\nwait (0.01) seconds\nswitch costume to (dot1 v)\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nswitch costume to (dot2 v)\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nswitch costume to (dot3 v)\ncreate clone of (_myself_ v)\nwait (0.1) seconds\nswitch costume to (circle1 v)\ncreate clone of (_myself_ v)\nswitch costume to (circle2 v)\ncreate clone of (_myself_ v)\nswitch costume to (master v)\nwait (2) seconds\nbroadcast (initialize project v)\n\nwhen I start as a clone\nif <(costume [name v]) = [background]> then\n    go to x: (0) y: (0)\n    set size to (100) %\n    show\nend\nif < (costume [name v]) contains [dot]?> then\n    point in direction (0)\n    go to x: (0) y: (0)\n    set [ghost v] effect to (100)\n    set size to (0) %\n    show\n    repeat (15)\n        turn right (((90) - (direction)) / (5)) degrees\n        change size by (((100) - (size)) / (5))\n        change [ghost v] effect by (-10)\n    end\nend\nif < (costume [name v]) contains [circle]?> then\n    go to x: (0) y: (0)\n    set [ghost v] effect to (100)\n    set size to (100) %\n    if <(costume [name v]) = [circle1]> then\n        point in direction (-90)\n        wait (0.1) seconds\n    else\n        point in direction (0)\n    end\n    show\n    repeat (15)\n        turn right (((90) - (direction)) / (5)) degrees\n        change [ghost v] effect by (-20)\n    end\nend\n\nwhen I receive [initialize project v]\nif <not <(costume [name v]) = [master]>> then\n    if <(costume [name v]) = [background]> then\n        wait (1) seconds\n        repeat (20)\n            switch costume to (dummy v)\n            set size to (400) %\n            switch costume to (background v)\n            change x by (((-500) - (x position)) / (5))\n            set size to (100) %\n            go to [front v] layer\n        end\n        delete this clone\n    else\n        repeat (20)\n            turn right (((180) - (direction)) / (5)) degrees\n            change size by (((0) - (size)) / (5))\n            change [ghost v] effect by (-20)\n            go to [front v] layer\n        end\n        delete this clone\n    end\nend\n\n@UI\n\nwhen flag clicked\nhide\n\nwhen I receive [initialize project v]\nset [theme v] to [light]\nset [ui: selected? v] to [0]\nset [ui: select y v] to [0]\nset [ui: overlay size v] to [0]\nset [tile index v] to [0]\nset [mode v] to [editor]\nswitch costume to (overlay game dark v)\nrepeat (8)\n    next costume\n    if <(costume [name v]) = [pause]> then\n        next costume\n    end\n    create clone of (_myself_ v)\nend\nswitch costume to (^end v)\nrepeat (8)\n    next costume\n    create clone of (_myself_ v)\nend\nswitch costume to (selector v)\ncreate clone of (_myself_ v)\nswitch costume to (light v)\ncreate clone of (_myself_ v)\nswitch costume to (overlay light v)\ncreate clone of (_myself_ v)\nswitch costume to (master v)\n\nwhen I start as a clone\nif <(costume [name v]) = [overlay light]> then\n    go to x: (0) y: (0)\n    set size to (100) %\n    go to [back v] layer\n    set [effect v] to [0]\n    show\n    forever\n        if <(mode) = [editor]> then\n            if < (costume [name v]) contains [overlay game]?> then\n                change [effect v] by (((100) - (effect)) / (3))\n                set [ghost v] effect to (effect)\n            end\n            if <<(round (effect)) = [100]> or <not < (costume [name v]) contains [overlay game]?>>> then\n                switch costume to (join [overlay ] (theme))\n                change [effect v] by (((0) - (effect)) / (3))\n                set [ghost v] effect to (effect)\n            end\n            if <(costume [name v]) = (join [overlay ] (theme))> then\n                if <<touching (mouse-pointer v)?> and <(UI: selected?) = [1]>> then\n                    change [effect v] by (((90) - (effect)) / (5))\n                    set [ghost v] effect to (effect)\n                else\n                    change [effect v] by (((0) - (effect)) / (5))\n                    set [ghost v] effect to (effect)\n                end\n            end\n        else\n            if <not < (costume [name v]) contains [overlay game]?>> then\n                change [effect v] by (((100) - (effect)) / (3))\n                set [ghost v] effect to (effect)\n            end\n            if <<(round (effect)) = [100]> or < (costume [name v]) contains [overlay game]?>> then\n                switch costume to (join [overlay game ] (theme))\n                change [effect v] by (((0) - (effect)) / (3))\n                set [ghost v] effect to (effect)\n            end\n        end\n    end\nend\nif < (costume [name v]) contains [^]?> then\n    go to x: (0) y: (0)\n    set size to (100) %\n    go to [back v] layer\n    set [effect v] to [0]\n    show\n    forever\n        if <(mode) = [editor]> then\n            change [effect v] by (((0) - (effect)) / (3))\n            set [ghost v] effect to (effect)\n            if <touching (mouse-pointer v)?> then\n                set [brightness v] effect to (-15)\n            else\n                set [brightness v] effect to (0)\n            end\n            if <<touching (mouse-pointer v)?> and <mouse down?>> then\n                if <(costume [name v]) = [^play]> then\n                    switch costume to (pause v)\n                    set [mode v] to [game]\n                    set [ui: selected? v] to [0]\n                    wait until <not <mouse down?>>\n                end\n                if <(costume [name v]) = [^save]> then\n                    broadcast (save v)\n                    wait until <not <mouse down?>>\n                end\n                if <(costume [name v]) = [^load]> then\n                    broadcast (load v)\n                    wait until <not <mouse down?>>\n                end\n                if <(costume [name v]) = [^player]> then\n                    if <<(UI: selected?) = [1]> and <(UI: select y) = [1000]>> then\n                        set [ui: selected? v] to [0]\n                    else\n                        set [ui: selected? v] to [1]\n                        set [ui: select y v] to [1000]\n                        set [tile index v] to [9]\n                    end\n                    wait until <not <mouse down?>>\n                end\n                if <(costume [name v]) = [^checkpoint]> then\n                    if <<(UI: selected?) = [1]> and <(UI: select y) = [3000]>> then\n                        set [ui: selected? v] to [0]\n                    else\n                        set [ui: selected? v] to [1]\n                        set [ui: select y v] to [3000]\n                        set [tile index v] to [10]\n                    end\n                    wait until <not <mouse down?>>\n                end\n                if <(costume [name v]) = [^end]> then\n                    if <<(UI: selected?) = [1]> and <(UI: select y) = [4000]>> then\n                        set [ui: selected? v] to [0]\n                    else\n                        set [ui: selected? v] to [1]\n                        set [ui: select y v] to [4000]\n                        set [tile index v] to [11]\n                    end\n                    wait until <not <mouse down?>>\n                end\n            end\n            if <(costume [name v]) = [^rotate]> then\n                if <<<touching (mouse-pointer v)?> and <mouse down?>> or <key (r v) pressed?>> then\n                    change [tile direction v] by (90)\n                    if <(tile direction) > [449]> then\n                        set [tile direction v] to [90]\n                    end\n                    wait until <not <<mouse down?> or <key (r v) pressed?>>>\n                end\n            end\n            if <(costume [name v]) = [^erase]> then\n                if <<touching (mouse-pointer v)?> and <mouse down?>> then\n                    if <<(UI: selected?) = [1]> and <(UI: select y) = [2000]>> then\n                        set [ui: selected? v] to [0]\n                    else\n                        set [ui: selected? v] to [1]\n                        set [ui: select y v] to [2000]\n                        set [tile index v] to [12]\n                    end\n                    wait until <not <mouse down?>>\n                end\n            end\n        else\n            if <(costume [name v]) = [^play]> then\n                change [effect v] by (((100) - (effect)) / (3))\n                set [ghost v] effect to (effect)\n                if <(round (effect)) = [100]> then\n                    switch costume to (pause v)\n                end\n            else\n                if <(costume [name v]) = [pause]> then\n                    change [effect v] by (((0) - (effect)) / (3))\n                    set [ghost v] effect to (effect)\n                else\n                    change [effect v] by (((100) - (effect)) / (3))\n                    set [ghost v] effect to (effect)\n                end\n            end\n        end\n        if <(costume [name v]) = [pause]> then\n            if <<<touching (mouse-pointer v)?> and <mouse down?>> or <(mode) = [editor]>> then\n                switch costume to (^play v)\n                set [mode v] to [editor]\n                wait until <not <mouse down?>>\n            end\n        end\n    end\nend\nif < (costume [name v]) contains [>]?> then\n    go to x: (0) y: (0)\n    set size to (100) %\n    go to [back v] layer\n    set [effect v] to [0]\n    show\n    forever\n        if <(mode) = [editor]> then\n            change [effect v] by (((0) - (effect)) / (3))\n            set [ghost v] effect to (effect)\n            if <(costume [name v]) = [>enemy]> then\n                set [brightness v] effect to (-30)\n            else\n                if <touching (mouse-pointer v)?> then\n                    set [brightness v] effect to (-15)\n                    if <mouse down?> then\n                        if <<(UI: select y) = (item ((costume [number v]) - (13)) of [select y v])> and <(UI: selected?) = [1]>> then\n                            set [ui: selected? v] to [0]\n                        else\n                            set [ui: select y v] to (item ((costume [number v]) - (13)) of [select y v])\n                            set [ui: selected? v] to [1]\n                            set [tile index v] to ((costume [number v]) - (13))\n                        end\n                        wait until <not <mouse down?>>\n                    end\n                else\n                    set [brightness v] effect to (0)\n                end\n            end\n        else\n            change [effect v] by (((100) - (effect)) / (3))\n            set [ghost v] effect to (effect)\n        end\n    end\nend\nif <(costume [name v]) = [light]> then\n    go to x: (0) y: (0)\n    set size to (100) %\n    go to [back v] layer\n    show\n    forever\n        if <touching (mouse-pointer v)?> then\n            set [brightness v] effect to (-15)\n            if <mouse down?> then\n                if <(costume [name v]) = [light]> then\n                    switch costume to (dark v)\n                    set [theme v] to [dark]\n                else\n                    switch costume to (light v)\n                    set [theme v] to [light]\n                end\n                wait until <not <mouse down?>>\n            end\n        else\n            set [brightness v] effect to (0)\n        end\n    end\nend\nif <(costume [name v]) = [selector]> then\n    go to x: (0) y: (0)\n    set size to (100) %\n    go to [back v] layer\n    set [effect v] to [100]\n    show\n    forever\n        if <(UI: selected?) = [1]> then\n            change y by (((UI: select y) - (y position)) / (3))\n            change [effect v] by (((0) - (effect)) / (3))\n        else\n            change [effect v] by (((100) - (effect)) / (3))\n        end\n        set [ghost v] effect to (effect)\n    end\nend\nif <(costume [name v]) = (join [victory ] (theme))> then\n    go to x: (0) y: (0)\n    set size to (0) %\n    go to [front v] layer\n    set [effect v] to [0]\n    show\n    repeat (50)\n        switch costume to (join [victory ] (theme))\n        set [effect v] to (((effect) * (0.7)) + (((100) - (size)) / (5)))\n        change size by (effect)\n    end\n    repeat (10)\n        switch costume to (join [victory ] (theme))\n        change [ghost v] effect by (10)\n    end\n    delete this clone\nend\n\nwhen I receive [victory v]\nif <(costume [name v]) = [master]> then\n    switch costume to (join [victory ] (theme))\n    create clone of (_myself_ v)\n    switch costume to (master v)\nend\n\nwhen I receive [initialize project v]\nset volume to (80) %\nforever\n    play sound [Alan Walker - Force \[NCS Release\] v] until done\n    play sound [Alan Walker - Fade \[NCS Release\] v] until done\n    play sound [Alan Walker - Spectre \[NCS Release\] v] until done\nend\n\n@Grid\n\nwhen flag clicked\nhide\n\ndefine generate grid x: (x) y: (y)\nset [x v] to (((0) - (((x) / (2)) + (0.5))) * (34))\nset [y v] to ((((y) / (2)) + (0.5)) * (34))\nrepeat (y)\n    change [y v] by (-34)\n    repeat (x)\n        change [x v] by (34)\n        set size to ((65) * (4)) %\n        go to x: ((x) - (scroll x)) y: ((y) - (scroll y))\n        set size to (65) %\n        if <<((x) - (scroll x)) = (x position)> and <((y) - (scroll y)) = (y position)>> then\n            stamp\n        end\n    end\n    set [x v] to (((0) - (((x) / (2)) + (0.5))) * (34))\nend\n\nwhen I receive [initialize project v]\nset size to (65) %\nset [scroll x v] to [-265]\nset [scroll y v] to [-325]\nforever\n    erase all\n    set [ghost v] effect to (70)\n    switch costume to (theme)\n    if <(mode) = [editor]> then\n        if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n            change [scroll x v] by (5)\n        end\n        if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n            change [scroll x v] by (-5)\n        end\n        if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n            change [scroll y v] by (5)\n        end\n        if <<key (s v) pressed?> or <key (down arrow v) pressed?>> then\n            change [scroll y v] by (-5)\n        end\n        find map borders x: [1290] y: [330]\n        generate grid x: [90] y: [30]\n    end\nend\n\ndefine find map borders x: (x) y: (y)\nif <(scroll x) < ((0) - (x))> then\n    set [scroll x v] to ((0) - (x))\nend\nif <(scroll y) < ((0) - (y))> then\n    set [scroll y v] to ((0) - (y))\nend\nif <(scroll x) > (x)> then\n    set [scroll x v] to (x)\nend\nif <(scroll y) > (y)> then\n    set [scroll y v] to (y)\nend\n\n@Tiles\n\ndefine decode (data)\nset [i v] to [0]\ndelete all of [data v]\nadd [] to [data v]\nrepeat ((length of (data)) / (2))\n    change [i v] by (1)\n    set [char v] to (item ((join (letter (((i) * (2)) - (1)) of (data)) (letter ((i) * (2)) of (data))) - (10)) of [chars v])\n    if <(char) = [next]> then\n        add [] to [data v]\n    else\n        replace item (length of [data v]) of [data v] with (join (item (length of [data v]) of [data v]) (char))\n    end\nend\n\ndefine encode (data)\nset [i v] to [0]\nrepeat (length of (data))\n    change [i v] by (1)\n    set [data v] to (join (data) ((item # of (letter (i) of (data)) in [chars v]) + (10)))\nend\nset [data v] to (join (data) ((item # of [next] in [chars v]) + (10)))\n\nwhen flag clicked\nhide\nshow list [code: v]\n\nwhen I receive [initialize project v]\ndelete all of [x v]\ndelete all of [y v]\ndelete all of [tile types v]\ndelete all of [tile directions v]\ndelete all of [missile stages v]\ndelete all of [missile last x v]\ndelete all of [missile last y v]\ndelete all of [xv v]\ndelete all of [yv v]\ndelete all of [turret projectiles v]\nforever\n    set size to (65) %\n    go to [back v] layer\n    hide\n    set [ghost v] effect to (0)\n    stamp\n    if <(UI: selected?) = [1]> then\n        set [ghost v] effect to (50)\n        set [tile type v] to (item (tile index) of [tiles v])\n        if <<(tile type) = [ground]> or <<(tile type) = [water]> or <(tile type) = [lava]>>> then\n            switch costume to (join (tile type) [4])\n        else\n            if <(tile type) = [jump]> then\n                if <<(tile direction) = [90]> or <(tile direction) = [270]>> then\n                    switch costume to (join (tile type) [1])\n                else\n                    switch costume to (join (tile type) [2])\n                end\n            else\n                if <(tile type) = [turret]> then\n                    switch costume to (turret full v)\n                else\n                    switch costume to (tile type)\n                end\n            end\n        end\n        set [x v] to (((round (((mouse x) + (scroll x)) / (34))) * (34)) + (17))\n        set [y v] to (((round (((mouse y) + (scroll y)) / (34))) * (34)) + (17))\n        go to x: ((x) - (scroll x)) y: ((y) - (scroll y))\n        if <<(tile type) = [jump]> or <(tile type) = [spike]>> then\n            point in direction (tile direction)\n        else\n            point in direction (90)\n        end\n        show\n        if <<mouse down?> and <not <touching (ui v)?>>> then\n            if <not <<(tile type) = [player]> and <[tile types v] contains [player]?>>> then\n                check overlap positioning\n                if <(overlap?) = [1]> then\n                    find index of x: (x) y: (y)\n                    if <(item (i4) of [tile types v]) = [turret]> then\n                        replace item (i4) of [tile types v] with (tile type)\n                        replace item (i4) of [missile stages v] with [idle]\n                        replace item (i4) of [missile last x v] with (x)\n                        replace item (i4) of [missile last y v] with (y)\n                        replace item (i4) of [xv v] with [0]\n                        replace item (i4) of [yv v] with [0]\n                        replace item (i4) of [turret projectiles v] with [0]\n                        delete ((i4) + (1)) of [tile types v]\n                        delete ((i4) + (1)) of [missile stages v]\n                        delete ((i4) + (1)) of [missile last x v]\n                        delete ((i4) + (1)) of [missile last y v]\n                        delete ((i4) + (1)) of [xv v]\n                        delete ((i4) + (1)) of [yv v]\n                        delete ((i4) + (1)) of [tile directions v]\n                        delete ((i4) + (1)) of [x v]\n                        delete ((i4) + (1)) of [y v]\n                        delete ((i4) + (1)) of [turret projectiles v]\n                    end\n                    replace item (i4) of [tile types v] with (tile type)\n                    replace item (i4) of [missile stages v] with [idle]\n                    replace item (i4) of [missile last x v] with (x)\n                    replace item (i4) of [missile last y v] with (y)\n                    replace item (i4) of [xv v] with [0]\n                    replace item (i4) of [yv v] with [0]\n                    replace item (i4) of [turret projectiles v] with [0]\n                    if <(tile type) = [turret]> then\n                        add (x) to [x v]\n                        add (y) to [y v]\n                        add [turret base] to [tile types v]\n                        add [idle] to [missile stages v]\n                        add (x) to [missile last x v]\n                        add (y) to [missile last y v]\n                        add [0] to [xv v]\n                        add [0] to [yv v]\n                        add [90] to [tile directions v]\n                        add [0] to [turret projectiles v]\n                    end\n                    if <<(tile type) = [jump]> or <(tile type) = [spike]>> then\n                        replace item (i4) of [tile directions v] with (tile direction)\n                        if <<(tile type) = [jump]> and <<(tile direction) = [90]> or <(tile direction) = [270]>>> then\n                            replace item (i4) of [tile types v] with [jump1]\n                        else\n                            replace item (i4) of [tile types v] with [jump2]\n                        end\n                    else\n                        replace item (i4) of [tile directions v] with [90]\n                    end\n                    if <(tile type) = [erase]> then\n                        delete (i4) of [tile types v]\n                        delete (i4) of [tile directions v]\n                        delete (i4) of [x v]\n                        delete (i4) of [y v]\n                        delete (i4) of [missile stages v]\n                        delete (i4) of [missile last x v]\n                        delete (i4) of [missile last y v]\n                        delete (i4) of [turret projectiles v]\n                        delete (i4) of [xv v]\n                        delete (i4) of [yv v]\n                        if <(item (i4) of [tile types v]) = [turret base]> then\n                            delete (i4) of [tile types v]\n                            delete (i4) of [tile directions v]\n                            delete (i4) of [x v]\n                            delete (i4) of [y v]\n                            delete (i4) of [missile stages v]\n                            delete (i4) of [missile last x v]\n                            delete (i4) of [missile last y v]\n                            delete (i4) of [xv v]\n                            delete (i4) of [yv v]\n                            delete (i4) of [turret projectiles v]\n                        end\n                    end\n                else\n                    add (x) to [x v]\n                    add (y) to [y v]\n                    add (tile type) to [tile types v]\n                    add [idle] to [missile stages v]\n                    add (x) to [missile last x v]\n                    add (y) to [missile last y v]\n                    add [0] to [xv v]\n                    add [0] to [yv v]\n                    add [0] to [turret projectiles v]\n                    if <(tile type) = [turret]> then\n                        add (x) to [x v]\n                        add (y) to [y v]\n                        add [turret base] to [tile types v]\n                        add [idle] to [missile stages v]\n                        add (x) to [missile last x v]\n                        add (y) to [missile last y v]\n                        add [0] to [xv v]\n                        add [0] to [yv v]\n                        add [90] to [tile directions v]\n                        add [0] to [turret projectiles v]\n                    end\n                    if <<(tile type) = [jump]> or <(tile type) = [spike]>> then\n                        add (tile direction) to [tile directions v]\n                        if <<(tile type) = [jump]> and <<(tile direction) = [90]> or <(tile direction) = [270]>>> then\n                            set [i4 v] to (item # of [jump] in [tile types v])\n                            replace item (i4) of [tile types v] with [jump1]\n                        else\n                            set [i4 v] to (item # of [jump] in [tile types v])\n                            replace item (i4) of [tile types v] with [jump2]\n                        end\n                    else\n                        add [90] to [tile directions v]\n                    end\n                    if <(tile type) = [erase]> then\n                        delete (length of [tile types v]) of [tile types v]\n                        delete (length of [tile directions v]) of [tile directions v]\n                        delete (length of [x v]) of [x v]\n                        delete (length of [y v]) of [y v]\n                        delete (length of [missile stages v]) of [missile stages v]\n                        delete (length of [missile last x v]) of [missile last x v]\n                        delete (length of [missile last y v]) of [missile last y v]\n                        delete (length of [turret projectiles v]) of [turret projectiles v]\n                        delete (length of [xv v]) of [xv v]\n                        delete (length of [yv v]) of [yv v]\n                    end\n                end\n                repeat until <not <mouse down?>>\n                    set [x v] to (((round (((mouse x) + (scroll x)) / (34))) * (34)) + (17))\n                    set [y v] to (((round (((mouse y) + (scroll y)) / (34))) * (34)) + (17))\n                    go to x: ((x) - (scroll x)) y: ((y) - (scroll y))\n                    set [ghost v] effect to (0)\n                    stamp\n                end\n            end\n        end\n    end\n    if <<key (c v) pressed?> and <<key ((join [enter] []) v) pressed?> and <(mode) = [editor]>>> then\n        delete all of [tile types v]\n        delete all of [tile directions v]\n        delete all of [x v]\n        delete all of [y v]\n        delete all of [missile stages v]\n        delete all of [missile last x v]\n        delete all of [missile last y v]\n    end\nend\n\ndefine stamp\nset [i1 v] to [0]\nrepeat ((length of [x v]) - <(mode) = [game]>)\n    change [i1 v] by (1)\n    if <<(mode) = [game]> and <(item (i1) of [tile types v]) = [player]>> then\n        change [i1 v] by (1)\n    end\n    if <(item (i1) of [tile types v]) = [missile]> then\n        if <(mode) = [editor]> then\n            replace item (i1) of [missile stages v] with [idle]\n            replace item (i1) of [tile directions v] with [90]\n            replace item (i1) of [x v] with (item (i1) of [missile last x v])\n            replace item (i1) of [y v] with (item (i1) of [missile last y v])\n            set size to ((270) * (4)) %\n            go to x: ((item (i1) of [x v]) - (scroll x)) y: ((item (i1) of [y v]) - (scroll y))\n            set size to (270) %\n            switch costume to (range v)\n            set [ghost v] effect to (60)\n            if <<((item (i1) of [x v]) - (scroll x)) = (x position)> and <((item (i1) of [y v]) - (scroll y)) = (y position)>> then\n                stamp\n            end\n        end\n        if <(mode) = [game]> then\n            go to x: ((item (i1) of [x v]) - (scroll x)) y: ((item (i1) of [y v]) - (scroll y))\n            if <<([sqrt v] of (((([x v] of [player v]) - (item (i1) of [x v])) * (([x v] of [player v]) - (item (i1) of [x v]))) + ((([y v] of [player v]) - (item (i1) of [y v])) * (([y v] of [player v]) - (item (i1) of [y v])))) ) < [187]> and <not <(player x) = []>>> then\n                if <(item (i1) of [missile stages v]) = [idle]> then\n                    replace item (i1) of [missile stages v] with [launch]\n                    point towards (player v)\n                    replace item (i1) of [tile directions v] with ((direction) + (pick random (-2) to (2)))\n                    replace item (i1) of [xv v] with [5]\n                end\n            end\n            if <(item (i1) of [missile stages v]) = [launch]> then\n                set [ghost v] effect to (100)\n                if <<((item (i1) of [x v]) - (scroll x)) = (x position)> and <((item (i1) of [y v]) - (scroll y)) = (y position)>> then\n                    show\n                end\n                if <not <<touching color (#8b8b8b)?> or <touching color (#ff0000)?>>> then\n                    replace item (i1) of [xv v] with ((item (i1) of [xv v]) + (1))\n                    replace item (i1) of [x v] with ((item (i1) of [x v]) + (([sin v] of (item (i1) of [tile directions v]) ) * (item (i1) of [xv v])))\n                    replace item (i1) of [y v] with ((item (i1) of [y v]) + (([cos v] of (item (i1) of [tile directions v]) ) * (item (i1) of [xv v])))\n                    if <touching color (#4a86e8)?> then\n                        replace item (i1) of [xv v] with ((item (i1) of [xv v]) * (0.7))\n                        replace item (i1) of [y v] with ((item (i1) of [y v]) - ((item (i1) of [xv v]) / (7)))\n                    else\n                        replace item (i1) of [xv v] with ((item (i1) of [xv v]) * (0.9))\n                    end\n                    if <<touching color (#00ff00)?> or <touching color (#00d900)?>> then\n                        replace item (i1) of [tile directions v] with ((item (i1) of [xv v]) + (90))\n                    end\n                else\n                    replace item (i1) of [missile stages v] with [dead]\n                end\n                hide\n            end\n            if <(item (i1) of [missile stages v]) = [dead]> then\n                replace item (i1) of [xv v] with ((item (i1) of [xv v]) * (-1))\n                replace item (i1) of [yv v] with ((item (i1) of [xv v]) * (-1))\n                replace item (i1) of [missile stages v] with [die]\n            end\n            if <<(item (i1) of [missile stages v]) = [die]> and <(item (i1) of [y v]) > [-900]>> then\n                replace item (i1) of [x v] with ((item (i1) of [x v]) + (item (i1) of [xv v]))\n                replace item (i1) of [y v] with ((item (i1) of [y v]) + (item (i1) of [yv v]))\n                replace item (i1) of [xv v] with ((item (i1) of [xv v]) * (0.9))\n                replace item (i1) of [yv v] with ((item (i1) of [yv v]) - (1))\n                replace item (i1) of [tile directions v] with ([atan v] of ((item (i1) of [xv v]) / (item (i1) of [yv v])) )\n            end\n        end\n    end\n    set [ghost v] effect to (100)\n    if <<((item (i1) of [x v]) - (scroll x)) = (x position)> and <((item (i1) of [y v]) - (scroll y)) = (y position)>> then\n        show\n    end\n    go to x: ((item (i1) of [x v]) - (scroll x)) y: ((item (i1) of [y v]) - (scroll y))\n    if <(item (i1) of [tile types v]) = [turret]> then\n        if <(mode) = [editor]> then\n            set size to ((270) * (4)) %\n            go to x: ((item (i1) of [x v]) - (scroll x)) y: ((item (i1) of [y v]) - (scroll y))\n            set size to (270) %\n            switch costume to (range v)\n            set [ghost v] effect to (60)\n            if <<((item (i1) of [x v]) - (scroll x)) = (x position)> and <((item (i1) of [y v]) - (scroll y)) = (y position)>> then\n                stamp\n            end\n        end\n        if <(mode) = [game]> then\n            point towards (player v)\n            if <<([sqrt v] of (((([x v] of [player v]) - (item (i1) of [x v])) * (([x v] of [player v]) - (item (i1) of [x v]))) + ((([y v] of [player v]) - (item (i1) of [y v])) * (([y v] of [player v]) - (item (i1) of [y v])))) ) < [187]> and <not <(player x) = []>>> then\n                replace item (i1) of [tile directions v] with ((direction) + (180))\n                if <(item (i1) of [turret projectiles v]) = [0]> then\n                    add [bullet] to [tile types v]\n                    add ((item (i1) of [x v]) + (([sin v] of (direction) ) * (25))) to [x v]\n                    add ((item (i1) of [y v]) + (([cos v] of (direction) ) * (25))) to [y v]\n                    add (direction) to [tile directions v]\n                    replace item (i1) of [turret projectiles v] with ((item (i1) of [turret projectiles v]) + (1))\n                end\n                if <<(item (i1) of [turret projectiles v]) = [0]> or <(item (i1) of [turret projectiles v]) > [50]>> then\n                    replace item (i1) of [turret projectiles v] with [0]\n                else\n                    replace item (i1) of [turret projectiles v] with ((item (i1) of [turret projectiles v]) + (1))\n                end\n            end\n        else\n            replace item (i1) of [tile directions v] with [90]\n        end\n    end\n    if <(item (i1) of [tile types v]) = [bullet]> then\n        if <<(mode) = [game]> and <not <<touching color (#8b8b8b)?> or <<touching color (#ff0000)?> or <<<(item (i1) of [x v]) > (([x v] of [player v]) + (400))> and <(item (i1) of [y v]) > (([y v] of [player v]) + (400))>> or <<(item (i1) of [x v]) < (([x v] of [player v]) - (400))> and <(item (i1) of [y v]) < (([y v] of [player v]) - (400))>>>>>>> then\n            replace item (i1) of [x v] with ((item (i1) of [x v]) + (([sin v] of (item (i1) of [tile directions v]) ) * (5)))\n            replace item (i1) of [y v] with ((item (i1) of [y v]) + (([cos v] of (item (i1) of [tile directions v]) ) * (5)))\n        else\n            delete (i1) of [tile types v]\n            delete (i1) of [tile directions v]\n            delete (i1) of [x v]\n            delete (i1) of [y v]\n        end\n    end\n    set size to ((65) * (4)) %\n    go to x: ((item (i1) of [x v]) - (scroll x)) y: ((item (i1) of [y v]) - (scroll y))\n    set size to (65) %\n    point in direction (90)\n    if <<(item (i1) of [tile types v]) = [ground]> or <<(item (i1) of [tile types v]) = [water]> or <<(item (i1) of [tile types v]) = [lava]> or <(item (i1) of [tile types v]) = [turret base]>>>> then\n        find direction\n    else\n        switch costume to (item (i1) of [tile types v])\n        point in direction (item (i1) of [tile directions v])\n    end\n    set [ghost v] effect to (100)\n    if <<((item (i1) of [x v]) - (scroll x)) = (x position)> and <((item (i1) of [y v]) - (scroll y)) = (y position)>> then\n        show\n    end\n    if <<(item (i1) of [tile types v]) = [checkpoint]> and <<touching (player v)?> and <(mode) = [game]>>> then\n        set [player x v] to (item (i1) of [x v])\n        set [player y v] to (item (i1) of [y v])\n    end\n    if <<(item (i1) of [tile types v]) = [end]> and <<touching (player v)?> and <<(mode) = [game]> and <not <(player x) = []>>>>> then\n        set [mode v] to [editor]\n        broadcast (victory v)\n    end\n    clear graphic effects\n    hide\n    if <<((item (i1) of [x v]) - (scroll x)) = (x position)> and <((item (i1) of [y v]) - (scroll y)) = (y position)>> then\n        stamp\n    end\nend\n\ndefine find direction\ndelete all of [directions v]\nrepeat (4)\n    add [0] to [directions v]\nend\nset [i2 v] to [0]\nrepeat ((length of [x v]) - (1))\n    change [i2 v] by (1)\n    if <<(item (i2) of [x v]) = (item (i1) of [x v])> and <(item (i2) of [y v]) = (item (i1) of [y v])>> then\n        change [i2 v] by (1)\n    end\n    if <<(item (i1) of [x v]) = ((item (i2) of [x v]) + (34))> and <(item (i1) of [y v]) = (item (i2) of [y v])>> then\n        if <(item (i1) of [tile types v]) = (item (i2) of [tile types v])> then\n            replace item (1) of [directions v] with [1]\n        end\n    end\n    if <<(item (i1) of [y v]) = ((item (i2) of [y v]) - (34))> and <(item (i1) of [x v]) = (item (i2) of [x v])>> then\n        if <(item (i1) of [tile types v]) = (item (i2) of [tile types v])> then\n            replace item (2) of [directions v] with [1]\n        end\n    end\n    if <<(item (i1) of [x v]) = ((item (i2) of [x v]) - (34))> and <(item (i1) of [y v]) = (item (i2) of [y v])>> then\n        if <(item (i1) of [tile types v]) = (item (i2) of [tile types v])> then\n            replace item (3) of [directions v] with [1]\n        end\n    end\n    if <<(item (i1) of [y v]) = ((item (i2) of [y v]) + (34))> and <(item (i1) of [x v]) = (item (i2) of [x v])>> then\n        if <(item (i1) of [tile types v]) = (item (i2) of [tile types v])> then\n            replace item (4) of [directions v] with [1]\n        end\n    end\nend\nset [i2 v] to [0]\nset [touching v] to [0]\nrepeat (4)\n    change [i2 v] by (1)\n    if <(item (i2) of [directions v]) = [1]> then\n        change [touching v] by (1)\n    end\nend\nif <(item (i1) of [tile types v]) = [turret base]> then\n    set [i2 v] to [0]\n    repeat ((length of [x v]) - (1))\n        change [i2 v] by (1)\n        if <<(item (i2) of [x v]) = (item (i1) of [x v])> and <(item (i2) of [y v]) = (item (i1) of [y v])>> then\n            change [i2 v] by (1)\n        end\n        if <<(item (i1) of [x v]) = ((item (i2) of [x v]) + (34))> and <(item (i1) of [y v]) = (item (i2) of [y v])>> then\n            if <(item (i2) of [tile types v]) = [ground]> then\n                replace item (1) of [directions v] with [1]\n            end\n        end\n        if <<(item (i1) of [y v]) = ((item (i2) of [y v]) - (34))> and <(item (i1) of [x v]) = (item (i2) of [x v])>> then\n            if <(item (i2) of [tile types v]) = [ground]> then\n                replace item (2) of [directions v] with [1]\n            end\n        end\n        if <<(item (i1) of [x v]) = ((item (i2) of [x v]) - (34))> and <(item (i1) of [y v]) = (item (i2) of [y v])>> then\n            if <(item (i2) of [tile types v]) = [ground]> then\n                replace item (3) of [directions v] with [1]\n            end\n        end\n        if <<(item (i1) of [y v]) = ((item (i2) of [y v]) + (34))> and <(item (i1) of [x v]) = (item (i2) of [x v])>> then\n            if <(item (i2) of [tile types v]) = [ground]> then\n                replace item (4) of [directions v] with [1]\n            end\n        end\n    end\n    set [i2 v] to [0]\n    set [touching v] to [0]\n    repeat (4)\n        change [i2 v] by (1)\n        if <(item (i2) of [directions v]) = [1]> then\n            change [touching v] by (1)\n        end\n    end\n    if <(item (i1) of [tile types v]) = [turret base]> then\n        switch costume to (turret base v)\n        if <(item (1) of [directions v]) = [1]> then\n            point in direction (180)\n        end\n        if <(item (2) of [directions v]) = [1]> then\n            point in direction (-90)\n        end\n        if <(item (3) of [directions v]) = [1]> then\n            point in direction (0)\n        end\n        if <(item (4) of [directions v]) = [1]> then\n            point in direction (90)\n        end\n    else\n        if <(touching) > [2]> then\n            switch costume to (join (item (i1) of [tile types v]) [1])\n        else\n            if <(touching) = [2]> then\n                if <<<(item (1) of [directions v]) = [1]> and <(item (3) of [directions v]) = [1]>> or <<(item (2) of [directions v]) = [1]> and <(item (4) of [directions v]) = [1]>>> then\n                    switch costume to (join (item (i1) of [tile types v]) [1])\n                else\n                    switch costume to (join (item (i1) of [tile types v]) [2])\n                    if <<(item (1) of [directions v]) = [1]> and <(item (2) of [directions v]) = [1]>> then\n                        point in direction (90)\n                    else\n                        if <<(item (2) of [directions v]) = [1]> and <(item (3) of [directions v]) = [1]>> then\n                            point in direction (180)\n                        else\n                            if <<(item (3) of [directions v]) = [1]> and <(item (4) of [directions v]) = [1]>> then\n                                point in direction (-90)\n                            else\n                                point in direction (0)\n                            end\n                        end\n                    end\n                end\n            else\n                if <(touching) = [1]> then\n                    switch costume to (join (item (i1) of [tile types v]) [3])\n                    if <(item (1) of [directions v]) = [1]> then\n                        point in direction (90)\n                    end\n                    if <(item (2) of [directions v]) = [1]> then\n                        point in direction (180)\n                    end\n                    if <(item (3) of [directions v]) = [1]> then\n                        point in direction (-90)\n                    end\n                    if <(item (4) of [directions v]) = [1]> then\n                        point in direction (0)\n                    end\n                else\n                    switch costume to (join (item (i1) of [tile types v]) [4])\n                end\n            end\n        end\n    end\n    switch costume to (turret base v)\n    if <(item (1) of [directions v]) = [1]> then\n        point in direction (180)\n    end\n    if <(item (2) of [directions v]) = [1]> then\n        point in direction (-90)\n    end\n    if <(item (3) of [directions v]) = [1]> then\n        point in direction (0)\n    end\n    if <(item (4) of [directions v]) = [1]> then\n        point in direction (90)\n    end\nelse\n    if <(touching) > [2]> then\n        switch costume to (join (item (i1) of [tile types v]) [1])\n    else\n        if <(touching) = [2]> then\n            if <<<(item (1) of [directions v]) = [1]> and <(item (3) of [directions v]) = [1]>> or <<(item (2) of [directions v]) = [1]> and <(item (4) of [directions v]) = [1]>>> then\n                switch costume to (join (item (i1) of [tile types v]) [1])\n            else\n                switch costume to (join (item (i1) of [tile types v]) [2])\n                if <<(item (1) of [directions v]) = [1]> and <(item (2) of [directions v]) = [1]>> then\n                    point in direction (90)\n                else\n                    if <<(item (2) of [directions v]) = [1]> and <(item (3) of [directions v]) = [1]>> then\n                        point in direction (180)\n                    else\n                        if <<(item (3) of [directions v]) = [1]> and <(item (4) of [directions v]) = [1]>> then\n                            point in direction (-90)\n                        else\n                            point in direction (0)\n                        end\n                    end\n                end\n            end\n        else\n            if <(touching) = [1]> then\n                switch costume to (join (item (i1) of [tile types v]) [3])\n                if <(item (1) of [directions v]) = [1]> then\n                    point in direction (90)\n                end\n                if <(item (2) of [directions v]) = [1]> then\n                    point in direction (180)\n                end\n                if <(item (3) of [directions v]) = [1]> then\n                    point in direction (-90)\n                end\n                if <(item (4) of [directions v]) = [1]> then\n                    point in direction (0)\n                end\n            else\n                switch costume to (join (item (i1) of [tile types v]) [4])\n            end\n        end\n    end\nend\n\ndefine check overlap positioning\nset [i3 v] to [0]\nset [overlap? v] to [0]\nrepeat (length of [x v])\n    change [i3 v] by (1)\n    if <<(item (i3) of [x v]) = (x)> and <(item (i3) of [y v]) = (y)>> then\n        set [overlap? v] to [1]\n    end\nend\n\ndefine find index of x: (x) y: (y)\nset [i4 v] to [0]\nrepeat until <<(item (i4) of [x v]) = (x)> and <(item (i4) of [y v]) = (y)>>\n    change [i4 v] by (1)\nend\n\nwhen I receive [initialize project v]\nforever\n    set [player x v] to []\n    set [player y v] to []\n    wait until <<(mode) = [game]> and <[tile types v] contains [player]?>>\n    set [i4 v] to (item # of [player] in [tile types v])\n    set [player x v] to (item (i4) of [x v])\n    set [player y v] to (item (i4) of [y v])\n    wait until <(mode) = [editor]>\nend\n\nwhen I receive [reset v]\nwait (0.01) seconds\nreset stuff\n\ndefine reset stuff\nset [i4 v] to [0]\nrepeat (length of [tile types v])\n    change [i4 v] by (1)\n    if <(item (i4) of [tile types v]) = [missile]> then\n        replace item (i4) of [missile stages v] with [idle]\n        replace item (i4) of [tile directions v] with [90]\n        replace item (i4) of [x v] with (item (i4) of [missile last x v])\n        replace item (i4) of [y v] with (item (i4) of [missile last y v])\n    end\n    if <(item (i4) of [tile types v]) = [bullet]> then\n        delete (i4) of [tile types v]\n        delete (i4) of [tile directions v]\n        delete (i4) of [x v]\n        delete (i4) of [y v]\n    end\nend\n\nwhen I receive [save v]\ndelete all of [code: v]\nset [data v] to []\nencode save data\nadd (data) to [code: v]\nhide list [code: v]\nrepeat until <key ((join [enter] []) v) pressed?>\n    replace item (1) of [code: v] with (data)\nend\nshow list [code: v]\n\ndefine encode save data\nset [i5 v] to [0]\nrepeat (length of [tile types v])\n    change [i5 v] by (1)\n    encode (item (i5) of [tile types v])\n    encode (item (i5) of [tile directions v])\n    encode (item (i5) of [x v])\n    encode (item (i5) of [y v])\n    encode (item (i5) of [xv v])\n    encode (item (i5) of [yv v])\n    encode (item (i5) of [missile stages v])\n    encode (item (i5) of [missile last x v])\n    encode (item (i5) of [missile last y v])\n    encode (item (i5) of [turret projectiles v])\nend\n\nwhen I receive [load v]\nask [] and wait\nif <not <(answer) = []>> then\n    delete all of [x v]\n    delete all of [y v]\n    delete all of [tile types v]\n    delete all of [tile directions v]\n    delete all of [missile stages v]\n    delete all of [missile last x v]\n    delete all of [missile last y v]\n    delete all of [xv v]\n    delete all of [yv v]\n    delete all of [turret projectiles v]\n    decode (answer)\n    decode save data\nend\n\ndefine decode save data\nset [i5 v] to [-9]\nrepeat ([floor v] of ((length of [data v]) / (10)) )\n    change [i5 v] by (10)\n    add (item (i5) of [data v]) to [tile types v]\n    add (item ((i5) + (1)) of [data v]) to [tile directions v]\n    add (item ((i5) + (2)) of [data v]) to [x v]\n    add (item ((i5) + (3)) of [data v]) to [y v]\n    add (item ((i5) + (4)) of [data v]) to [xv v]\n    add (item ((i5) + (5)) of [data v]) to [yv v]\n    add (item ((i5) + (6)) of [data v]) to [missile stages v]\n    add (item ((i5) + (7)) of [data v]) to [missile last x v]\n    add (item ((i5) + (8)) of [data v]) to [missile last y v]\n    add (item ((i5) + (9)) of [data v]) to [turret projectiles v]\nend\n\nif <(item (i5) of [data v]) = [turret]> then\n\n@Player\n\ndefine turn\nchange [x v] by (10)\nposition\nif <not <touching color (#8b8b8b)?>> then\n    change [direction v] by (3)\n    change [xv v] by (0.3)\nend\nchange [x v] by (-20)\nposition\nif <not <touching color (#8b8b8b)?>> then\n    change [direction v] by (-3)\n    change [xv v] by (-0.3)\nend\nchange [x v] by (10)\nposition\nturn right (2) degrees\nif <not <touching color (#8b8b8b)?>> then\n    change [direction v] by (1)\nend\nturn left (4) degrees\nif <not <touching color (#8b8b8b)?>> then\n    change [direction v] by (-1)\nend\nturn right (2) degrees\nturn right (10) degrees\nif <not <touching color (#8b8b8b)?>> then\n    change [direction v] by (2)\nend\nturn left (20) degrees\nif <not <touching color (#8b8b8b)?>> then\n    change [direction v] by (-2)\nend\nturn right (10) degrees\n\ndefine physics friction: (friction) stiffness: (stiffness)\nif <not <touching color (#8b8b8b)?>> then\n    change [yv v] by (-1)\nend\nchange [y v] by (yv)\nposition\nif <touching color (#8b8b8b)?> then\n    repeat ([abs v] of ([ceiling v] of (yv) ) )\n        if <touching color (#8b8b8b)?> then\n            change [y v] by ((([abs v] of (yv) ) / (yv)) * (-1))\n            position\n        end\n    end\n    set [yv v] to [0]\nelse\n    if <touching color (#4a86e8)?> then\n        set [yv v] to (((0) - (yv)) / (5))\n        change [y v] by (yv)\n        position\n    end\nend\nif <touching color (#00ff00)?> then\n    set [yv v] to ((([abs v] of (yv) ) / (yv)) * (-20))\nend\nif <touching color (#00d900)?> then\n    set [xv v] to ((([abs v] of (xv) ) / (xv)) * (-20))\nend\nchange [x v] by (xv)\nposition\nif <touching color (#8b8b8b)?> then\n    set [slope v] to [0]\n    repeat until <<(slope) = [-8]> or <not <touching color (#8b8b8b)?>>>\n        change [slope v] by (-1)\n        change [y v] by (1)\n        position\n    end\n    if <(slope) = [-8]> then\n        change [y v] by (slope)\n        position\n    end\n    repeat ([abs v] of ([ceiling v] of (xv) ) )\n        change [x v] by ((([abs v] of (xv) ) / (xv)) * (-1.5))\n        position\n    end\n    set [xv v] to [0]\nend\nturn right (direction) degrees\nset [direction v] to ((direction) * (stiffness))\nset [xv v] to ((xv) * (friction))\nif <not <touching color (#8b8b8b)?>> then\n    turn\nend\nchange [scroll x v] by (round (((x) - (scroll x)) / (10)))\nchange [scroll y v] by (round (((y) - (scroll y)) / (10)))\nposition\n\nwhen flag clicked\npoint in direction (90)\nset size to (65) %\nhide\n\nwhen I receive [initialize project v]\ncreate clone of (_myself_ v)\nforever\n    wait until <<(mode) = [game]> and <not <(player x) = []>>>\n    broadcast (reset v)\n    switch costume to (player v)\n    set [x v] to (player x)\n    set [y v] to (player y)\n    set [xv v] to [0]\n    set [yv v] to [0]\n    set [direction v] to [0]\n    set [slope v] to [0]\n    change [scroll x v] by (((x) - (scroll x)) / (1.3))\n    change [scroll y v] by (((y) - (scroll y)) / (1.3))\n    point in direction (90)\n    position\n    show\n    repeat until <<(mode) = [editor]> or <<(y) < [-900]> or <<touching color (#ff0000)?> or <touching color (#ffff00)?>>>>\n        controls\n        physics friction: [0.93] stiffness: [0.6]\n        set [player: x v] to (x)\n        set [player: y v] to (y)\n    end\n    if <<touching color (#ff0000)?> or <touching color (#ffff00)?>> then\n        set [xv v] to ((xv) * (-2))\n        set [yv v] to [10]\n        repeat until <(y) < [-900]>\n            change [x v] by (xv)\n            change [y v] by (yv)\n            position\n            set [xv v] to ((xv) * (0.9))\n            change [yv v] by (-1)\n            point in direction ([atan v] of ((xv) / (yv)) )\n        end\n    end\n    hide\nend\n\ndefine position\nset size to ((size) * (4)) %\ngo to x: ((x) - (scroll x)) y: ((y) - (scroll y))\nset size to ((size) / (4)) %\nif <<((x) - (scroll x)) = (x position)> and <((y) - (scroll y)) = (y position)>> then\n    show\nelse\n    hide\nend\n\ndefine controls\nif <<<key (w v) pressed?> or <key (up arrow v) pressed?>> and <<(player: touching ground?) = [1]> and <(round (direction)) = [0]>>> then\n    set [yv v] to [15]\nend\nif <touching color (#4a86e8)?> then\n    if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n        set [yv v] to [5]\n    end\n    if <<key (s v) pressed?> or <key (down arrow v) pressed?>> then\n        set [yv v] to [-3]\n    end\nend\nif <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n    change [xv v] by (-1)\nend\nif <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n    change [xv v] by (1)\nend\n\nwhen I start as a clone\nswitch costume to (ground check v)\nset [ghost v] effect to (100)\nshow\nforever\n    point in direction (90)\n    set [x v] to (player: x)\n    set [y v] to (player: y)\n    position\n    if <touching color (#8b8b8b)?> then\n        set [player: touching ground? v] to [1]\n    else\n        set [player: touching ground? v] to [0]\n    end\nend\n\n@Thumb\n\nwhen flag clicked\nhide\nforever\n    reset timer\nend\n\nwhen [timer v] > (0)\ngo to x: (0) y: (0)\nset size to (100) %\nswitch costume to (png v)\ngo to [front v] layer\nshow\n\n