platformer

Instructions: wasd or arrow keys\njust a demo of an upcoming game\nill release catacloud after this game comes out\n\nmain @coder_d6

@Stage\n\n@tiles\n\ndefine render\nset pen size to (16)\nset size to (300) %\nset [tile x v] to [0]\nrepeat (22)\n    set [tile y v] to [0]\n    set x to (((-252) - ((x scroll) mod (24))) + ((tile x) * (24)))\n    repeat (17)\n        set y to (((-180) - ((y scroll) mod (24))) + ((tile y) * (24)))\n        render tile\n        change [tile y v] by (1)\n    end\n    change [tile x v] by (1)\nend\n\ndefine @tile (x) (y)\nset [@tile v] to ((([floor v] of (((x) + (x scroll)) / (24)) ) * (level height)) + ([floor v] of (((y) + (y scroll)) / (24)) ))\n\nwhen flag clicked\nsetUp\n\ndefine rand\ndelete all of [level v]\nrepeat ((level height) * (100))\n    add [0] to [level v]\nend\n\ndefine set up clones\nset [clone tile v] to [1]\nrepeat (28)\n    switch costume to (clone tile)\n    create clone of (_myself_ v)\n    change [clone tile v] by (1)\nend\nswitch costume to (clone tile)\n\ndefine setUp\ndelete all of [set up render v]\nset [tile x v] to [0]\nrepeat ((100) * (level height))\n    change [tile x v] by (1)\n    add (item (tile x) of [level v]) to [set up render v]\nend\ndelete all of [render v]\nset [tile x v] to [0]\nrepeat ((100) * (level height))\n    change [tile x v] by (1)\n    add (item (tile x) of [level v]) to [render v]\nend\ndelete all of [attatch? v]\nadd [1] to [attatch? v]\ntile [1]\ndelete all of [attatch? v]\nadd [1] to [attatch? v]\nadd [2] to [attatch? v]\ntile [2]\ndelete all of [attatch? v]\nadd [1] to [attatch? v]\nadd [3] to [attatch? v]\ntile [3]\ndelete all of [attatch? v]\nadd [4] to [attatch? v]\ntile [4]\n\ndefine tiling (tile type) (tile#)\nif <[attatch? v] contains (item ((tile#) + (1)) of [level v])?> then\n    if <[attatch? v] contains (item ((tile#) + (-1)) of [level v])?> then\n        if <[attatch? v] contains (item ((tile#) + (level height)) of [level v])?> then\n            if <[attatch? v] contains (item ((tile#) - (level height)) of [level v])?> then\n                if <<<not <[attatch? v] contains (item (((tile#) + (level height)) + (1)) of [level v])?>> or <not <[attatch? v] contains (item (((tile#) + (level height)) + (-1)) of [level v])?>>> or <<not <[attatch? v] contains (item (((tile#) - (level height)) + (1)) of [level v])?>> or <not <[attatch? v] contains (item (((tile#) - (level height)) + (-1)) of [level v])?>>>> then\n                    replace item (tile#) of [set up render v] with (item ((tiling i) + (37)) of [tiling v])\n                else\n                    replace item (tile#) of [set up render v] with (item ((tiling i) + (13)) of [tiling v])\n                end\n            else\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (11)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (11)) of [tiling v])\n            end\n        else\n            if <[attatch? v] contains (item ((tile#) - (level height)) of [level v])?> then\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (15)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (15)) of [tiling v])\n            else\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (28)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (28)) of [tiling v])\n            end\n        end\n    else\n        if <[attatch? v] contains (item ((tile#) + (level height)) of [level v])?> then\n            if <[attatch? v] contains (item ((tile#) - (level height)) of [level v])?> then\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (23)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (23)) of [tiling v])\n            else\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (21)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (21)) of [tiling v])\n            end\n        else\n            if <[attatch? v] contains (item ((tile#) - (level height)) of [level v])?> then\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (25)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (25)) of [tiling v])\n            else\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (30)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (30)) of [tiling v])\n            end\n        end\n    end\nelse\n    if <[attatch? v] contains (item ((tile#) + (-1)) of [level v])?> then\n        if <[attatch? v] contains (item ((tile#) + (level height)) of [level v])?> then\n            if <[attatch? v] contains (item ((tile#) - (level height)) of [level v])?> then\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (3)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (3)) of [tiling v])\n            else\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (1)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (1)) of [tiling v])\n            end\n        else\n            if <[attatch? v] contains (item ((tile#) - (level height)) of [level v])?> then\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (5)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (5)) of [tiling v])\n            else\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (26)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (26)) of [tiling v])\n            end\n        end\n    else\n        if <[attatch? v] contains (item ((tile#) + (level height)) of [level v])?> then\n            if <[attatch? v] contains (item ((tile#) - (level height)) of [level v])?> then\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (33)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (33)) of [tiling v])\n            else\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (31)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (31)) of [tiling v])\n            end\n        else\n            if <[attatch? v] contains (item ((tile#) - (level height)) of [level v])?> then\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (35)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (35)) of [tiling v])\n            else\n                replace item (tile#) of [set up render v] with (item ((tiling i) + (36)) of [tiling v])\n                replace item (tile#) of [render v] with (item ((tiling i) + (36)) of [tiling v])\n            end\n        end\n    end\nend\n\ndefine tile (tile type)\nset [tiling i v] to [0]\nset [tiling id v] to [0]\nrepeat until <(tile type) = (tiling id)>\n    change [tiling i v] by (1)\n    if <(item (tiling i) of [tiling v]) = [-]> then\n        change [tiling id v] by (1)\n    end\nend\nset [tile x v] to [0]\nrepeat (100)\n    set [tile y v] to [0]\n    repeat (level height)\n        change [tile y v] by (1)\n        if <(item (((tile x) * (level height)) + (tile y)) of [level v]) = (tile type)> then\n            tiling (tile type) (((tile x) * (level height)) + (tile y))\n        end\n    end\n    change [tile x v] by (1)\nend\nset [tile x v] to [0]\nrepeat (100)\n    set [tile y v] to [0]\n    repeat (level height)\n        change [tile y v] by (1)\n        if <(item (((tile x) * (level height)) + (tile y)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n            tiling 2nd (tile type) (((tile x) * (level height)) + (tile y))\n        end\n    end\n    change [tile x v] by (1)\nend\n\ndefine tiling 2nd (tile type) (tile#)\nif <(item ((tile#) + (1)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n    if <(item ((tile#) + (-1)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n        if <(item ((tile#) + (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n            if <(item ((tile#) - (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n                replace item (tile#) of [render v] with (item ((tiling i) + (13)) of [tiling v])\n            else\n                replace item (tile#) of [render v] with (item ((tiling i) + (12)) of [tiling v])\n            end\n        else\n            if <(item ((tile#) - (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n                replace item (tile#) of [render v] with (item ((tiling i) + (14)) of [tiling v])\n            else\n                replace item (tile#) of [render v] with (item ((tiling i) + (14)) of [tiling v])\n            end\n        end\n    else\n        if <(item ((tile#) + (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n            if <(item ((tile#) - (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n                replace item (tile#) of [render v] with (item ((tiling i) + (18)) of [tiling v])\n            else\n                replace item (tile#) of [render v] with (item ((tiling i) + (17)) of [tiling v])\n            end\n        else\n            if <(item ((tile#) - (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n                replace item (tile#) of [render v] with (item ((tiling i) + (19)) of [tiling v])\n            else\n                replace item (tile#) of [render v] with (item ((tiling i) + (18)) of [tiling v])\n            end\n        end\n    end\nelse\n    if <(item ((tile#) + (-1)) of [level v]) = (item ((tiling i) + (13)) of [tiling v])> then\n        if <(item ((tile#) + (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n            if <(item ((tile#) - (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n                replace item (tile#) of [render v] with (item ((tiling i) + (13)) of [tiling v])\n            else\n                replace item (tile#) of [render v] with (item ((tiling i) + (13)) of [tiling v])\n            end\n        else\n            if <(item ((tile#) - (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n                replace item (tile#) of [render v] with (item ((tiling i) + (13)) of [tiling v])\n            else\n                replace item (tile#) of [render v] with (item ((tiling i) + (13)) of [tiling v])\n            end\n        end\n    else\n        if <(item ((tile#) + (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n            if <(item ((tile#) - (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n                replace item (tile#) of [render v] with (item ((tiling i) + (8)) of [tiling v])\n            else\n                replace item (tile#) of [render v] with (item ((tiling i) + (7)) of [tiling v])\n            end\n        else\n            if <(item ((tile#) - (level height)) of [set up render v]) = (item ((tiling i) + (13)) of [tiling v])> then\n                replace item (tile#) of [render v] with (item ((tiling i) + (9)) of [tiling v])\n            else\n                replace item (tile#) of [render v] with (item ((tiling i) + (8)) of [tiling v])\n            end\n        end\n    end\nend\n\nadd [49] to [tiling v]\n\ndefine render tile\n@tile (x position) (y position)\nif <(editing?) = [1]> then\n    if <not <(item (@tile) of [render v]) = [0]>> then\n        clear graphic effects\n        switch costume to (item (@tile) of [render v])\n        stamp\n    end\nelse\n    clear graphic effects\n    if <not <<(item (@tile) of [render v]) = [0]> or <(letter (1) of (item (@tile) of [render v])) = [e]>>> then\n        switch costume to (item (@tile) of [render v])\n        if <(item (@tile) of [level v]) = [2]> then\n            set [color v] effect to (([sin v] of ((tick) * (5)) ) * (10))\n        else\n            if <(item (@tile) of [level v]) = [3]> then\n                set [whirl v] effect to ((([sqrt v] of ([abs v] of ([sin v] of ((tick) * (5)) ) ) ) * (8)) * (([abs v] of ([sin v] of ((tick) * (5)) ) ) / ([sin v] of ((tick) * (5)) )))\n            end\n        end\n        stamp\n    end\nend\n\nwhen I receive [render v]\nrender\n@tile (mouse x) (mouse y)\nif <(editing?) = [1]> then\n    if <mouse down?> then\n        if <not <(item (@tile) of [level v]) = (tile edit)>> then\n            replace item (@tile) of [level v] with (tile edit)\n            setUp\n        end\n    end\n    show\n    go to x: (mouse x) y: (mouse y)\n    if <(tile edit) = [0]> then\n        switch costume to (0 v)\n    else\n        if <(tile edit) = [1]> then\n            switch costume to (1 v)\n        else\n            if <(tile edit) = [2]> then\n                switch costume to (16 v)\n            else\n                if <(tile edit) = [3]> then\n                    switch costume to (33 v)\n                else\n                    if <(tile edit) = [4]> then\n                        switch costume to (50 v)\n                    else\n                        switch costume to (tile edit)\n                    end\n                end\n            end\n        end\n    end\nelse\n    hide\nend\n\nset [@tile v] to [0]\n\nreplace item (1) of [level v] with [thing]\n\nif <key (9 v) pressed?> then\n    set [tile edit v] to [e01]\nend\n\nwhen [9 v] key pressed\nif <(editing?) = [1]> then\n    if <(tile edit) = [e01]> then\n        set [tile edit v] to [e02]\n    else\n        if <(tile edit) = [e02]> then\n            set [tile edit v] to [e03]\n        else\n            if <(tile edit) = [e03]> then\n                set [tile edit v] to [e04]\n            else\n                if <(tile edit) = [e04]> then\n                    set [tile edit v] to [e05]\n                else\n                    if <(tile edit) = [e05]> then\n                        set [tile edit v] to [e06]\n                    else\n                        if <(tile edit) = [e06]> then\n                            set [tile edit v] to [e07]\n                        else\n                            set [tile edit v] to [e01]\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\nrepeat (5)\n    add [50] to [tiling v]\nend\n\nset [editing? v] to [1]\n\nwhen [1 v] key pressed\nif <(editing?) = [1]> then\n    if <(tile edit) = [0]> then\n        set [tile edit v] to [1]\n    else\n        if <(tile edit) = [1]> then\n            set [tile edit v] to [4]\n        else\n            set [tile edit v] to [0]\n        end\n    end\nend\n\nwhen [2 v] key pressed\nif <(editing?) = [1]> then\n    if <(tile edit) = [2]> then\n        set [tile edit v] to [3]\n    else\n        set [tile edit v] to [2]\n    end\nend\n\nset [editing? v] to [0]\n\nset [editing? v] to [0]\n\nadd [3] to [attatch? v]\n\nwhen [e v] key pressed\nif <(editing?) = [1]> then\n    set [editing? v] to [0]\nelse\n    set [editing? v] to [1]\nend\n\n@playerSprite2\n\ndefine touching ground? (x) (y)\nset [@tile v] to (item ((([floor v] of ((x) / (24)) ) * (level height)) + ([floor v] of ((y) / (24)) )) of [level v])\n\nwhen flag clicked\nset [player x v] to [256]\nset [player y v] to [200]\nchange [editing? v] by (0)\nforever\n    reset timer\n    set [fps v] to (frames)\n    set [frames v] to [0]\n    repeat until <(timer) > [1]>\n        set [respawn? v] to [0]\n        delete all of [e dir v]\n        delete all of [e type v]\n        delete all of [e x v]\n        delete all of [e y v]\n        change [frames v] by (1)\n        erase all\n        if <(editing?) = [1]> then\n            switch costume to (air1 v)\n            if <key (w v) pressed?> then\n                change [player y v] by (10)\n            end\n            if <key (s v) pressed?> then\n                change [player y v] by (-10)\n            end\n            if <key (a v) pressed?> then\n                change [player x v] by (-10)\n            end\n            if <key (d v) pressed?> then\n                change [player x v] by (10)\n            end\n            cam\n            broadcast (back v)\n            broadcast (render v)\n        else\n            broadcast (y moving platforms v)\n            broadcast (y phys v)\n            broadcast (x moving platforms v)\n            broadcast (x phys v)\n            cam\n            broadcast (back v)\n            broadcast (par v)\n            broadcast (render v)\n            change [tick v] by (1)\n            render player\n            respawn check\n        end\n    end\nend\n\ndefine y phys\nset [touching floor? v] to [0]\nchange [player y vel v] by (-1.5)\nrepeat (5)\n    change [player y v] by ((player y vel) / (5))\n    if <(player y vel) < [0]> then\n        if <([floor v] of (((player y) - (player y vel)) / (24)) ) > ([floor v] of ((player y) / (24)) )> then\n            touching ground? (player x) ((player y) - (24))\n            if <<(@tile) = [1]> or <(@tile) = [4]>> then\n                set [player y vel v] to [0]\n                change [player y v] by ((24) - ((player y) mod (24)))\n                set [touching floor? v] to [1]\n            end\n        end\n        if <([floor v] of (((player y) - (player y vel)) / (24)) ) > ([floor v] of ((player y) / (24)) )> then\n            touching ground? ((player x) - (24)) ((player y) - (24))\n            if <<(@tile) = [1]> or <(@tile) = [4]>> then\n                set [player y vel v] to [0]\n                change [player y v] by ((24) - ((player y) mod (24)))\n                set [touching floor? v] to [1]\n            end\n        end\n        if <([floor v] of (((player y) - (player y vel)) / (24)) ) > ([floor v] of ((player y) / (24)) )> then\n            touching ground? ((player x) + (24)) ((player y) - (24))\n            if <<(@tile) = [1]> or <(@tile) = [4]>> then\n                set [player y vel v] to [0]\n                change [player y v] by ((24) - ((player y) mod (24)))\n                set [touching floor? v] to [1]\n            end\n        end\n    else\n        touching ground? (player x) ((player y) + (48))\n        if <(@tile) = [1]> then\n            set [player y vel v] to [0]\n            change [player y v] by ((-.01) - ((player y) mod (24)))\n        end\n        touching ground? ((player x) - (24)) ((player y) + (48))\n        if <(@tile) = [1]> then\n            set [player y vel v] to [0]\n            change [player y v] by ((-.01) - ((player y) mod (24)))\n        end\n        touching ground? ((player x) + (24)) ((player y) + (48))\n        if <(@tile) = [1]> then\n            set [player y vel v] to [0]\n            change [player y v] by ((-.01) - ((player y) mod (24)))\n        end\n    end\nend\n\ndefine x phys\nif <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n    change [player x vel v] by (-1.8)\nend\nif <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n    change [player x vel v] by (1.8)\nend\nset [player x vel v] to ((player x vel) * (.82))\nchange [player x v] by (player x vel)\ntouching ground? ((player x) - (24)) (player y)\nif <(@tile) = [1]> then\n    set [player x vel v] to [0]\n    change [player x v] by ((24) - ((player x) mod (24)))\nend\ntouching ground? ((player x) - (24)) ((player y) - (24))\nif <(@tile) = [1]> then\n    set [player x vel v] to [0]\n    change [player x v] by ((24) - ((player x) mod (24)))\nend\ntouching ground? ((player x) - (24)) ((player y) + (24))\nif <(@tile) = [1]> then\n    set [player x vel v] to [0]\n    change [player x v] by ((24) - ((player x) mod (24)))\nend\ntouching ground? ((player x) - (24)) ((player y) + (48))\nif <(@tile) = [1]> then\n    set [player x vel v] to [0]\n    change [player x v] by ((24) - ((player x) mod (24)))\nend\ntouching ground? ((player x) + (24)) (player y)\nif <(@tile) = [1]> then\n    set [player x vel v] to [0]\n    change [player x v] by ((-.01) - ((player x) mod (24)))\nend\ntouching ground? ((player x) + (24)) ((player y) - (24))\nif <(@tile) = [1]> then\n    set [player x vel v] to [0]\n    change [player x v] by ((-.01) - ((player x) mod (24)))\nend\ntouching ground? ((player x) + (24)) ((player y) + (24))\nif <(@tile) = [1]> then\n    set [player x vel v] to [0]\n    change [player x v] by ((-.01) - ((player x) mod (24)))\nend\ntouching ground? ((player x) + (24)) ((player y) + (48))\nif <(@tile) = [1]> then\n    set [player x vel v] to [0]\n    change [player x v] by ((-.01) - ((player x) mod (24)))\nend\n\ndefine cam\nset [x scroll v] to (((((x scroll) * (4)) + (player x)) / (5)) + ((player x vel) * (2)))\nset [y scroll v] to (((((y scroll) * (4)) + (player y)) / (5)) + ((player y vel) * (1)))\nif <(x scroll) < [264]> then\n    set [x scroll v] to [264]\nend\nif <[2160] < (x scroll)> then\n    set [x scroll v] to [2159.9]\nend\nif <(y scroll) < [180]> then\n    set [y scroll v] to [180]\nend\nif <[1224] < (y scroll)> then\n    set [y scroll v] to [1224]\nend\ngo to x: ((player x) - (x scroll)) y: ((player y) - (y scroll))\n\nset [editing? v] to [1]\n\ndefine moving platforms x\nset [tile i v] to [0]\nrepeat (length of [e type v])\n    change [tile i v] by (1)\n    if <(item (tile i) of [e type v]) = [1]> then\n        obj collide x [36] [12] [0]\n    end\n    if <(item (tile i) of [e type v]) = [2]> then\n        obj collide x [36] [12] [0]\n    end\n    if <(item (tile i) of [e type v]) = [6]> then\n        obj collide x [36] [12] [0]\n    end\n    if <(item (tile i) of [e type v]) = [7]> then\n        if <(item (tile i) of [e dir v]) = [0]> then\n            obj collide x [36] [12] [-4]\n        else\n            obj collide x [36] [12] [0]\n        end\n    end\nend\n\ndefine moving platforms y\nset [tile i v] to [0]\nrepeat (length of [e type v])\n    change [tile i v] by (1)\n    if <(item (tile i) of [e type v]) = [1]> then\n        if <(item (tile i) of [e dir v]) = [0]> then\n            obj collide y [36] [12] [2]\n        else\n            obj collide y [36] [12] [-2]\n        end\n    end\n    if <(item (tile i) of [e type v]) = [2]> then\n        obj collide y [36] [12] [0]\n    end\n    if <(item (tile i) of [e type v]) = [6]> then\n        obj collide y [36] [12] [0]\n    end\n    if <(item (tile i) of [e type v]) = [7]> then\n        obj collide y [36] [12] [0]\n    end\nend\n\nwhen I receive [x phys v]\nx phys\nmoving platforms x\n\nwhen I receive [y phys v]\ny phys\nmoving platforms y\nset [stuck? v] to [0]\ntouching ground? ((player x) - (24)) ((player y) - (23))\nif <(@tile) = [3]> then\n    set [stuck? v] to [1]\n    if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n        if <(touching floor?) = [1]> then\n            set [player y vel v] to [6]\n        end\n    end\nelse\n    touching ground? ((player x) + (24)) ((player y) - (23))\n    if <(@tile) = [3]> then\n        set [stuck? v] to [1]\n        if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n            if <(touching floor?) = [1]> then\n                set [player y vel v] to [6 ]\n            end\n        end\n    else\n        if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then\n            if <(touching floor?) = [1]> then\n                set [player y vel v] to [23]\n            end\n        end\n    end\nend\n\ndefine obj collide x (x size) (y size) (y shift)\nif <<(item (tile i) of [e x v]) < ((player x) + ((24) + (x size)))> and <((player x) - ((24) + (x size))) < (item (tile i) of [e x v])>> then\n    if <<(item (tile i) of [e y v]) < ((player y) + ((48) + (y size)))> and <((player y) - ((24) + (y size))) < (item (tile i) of [e y v])>> then\n        if <(player x) < (item (tile i) of [e x v])> then\n            change [player x v] by (((item (tile i) of [e x v]) - (player x)) - ((24) + (x size)))\n            if <(player x vel) > [0]> then\n                set [player x vel v] to [0]\n            end\n        else\n            change [player x v] by (((item (tile i) of [e x v]) - (player x)) + ((24) + (x size)))\n            if <[0] > (player x vel)> then\n                set [player x vel v] to [0]\n            end\n        end\n    end\n    if <((player y) - ((24) + (y size))) = (item (tile i) of [e y v])> then\n        change [player y v] by (y shift)\n        change [player y vel v] by (y shift)\n    end\nend\n\ndefine obj collide y (x size) (y size) (x shift)\nif <<(item (tile i) of [e x v]) < ((player x) + ((24) + (x size)))> and <((player x) - ((24) + (x size))) < (item (tile i) of [e x v])>> then\n    if <<(item (tile i) of [e y v]) < ((player y) + ((48) + (y size)))> and <((player y) - ((24) + (y size))) < (item (tile i) of [e y v])>> then\n        if <(player y) < (item (tile i) of [e y v])> then\n            change [player y v] by (((item (tile i) of [e y v]) - (player y)) - ((48) + (y size)))\n            if <(player y vel) > [0]> then\n                set [player y vel v] to [0]\n            end\n        else\n            change [player y v] by (((item (tile i) of [e y v]) - (player y)) + ((24) + (y size)))\n            set [touching floor? v] to [1]\n            set [player y vel v] to [0]\n        end\n    end\n    if <<(item (tile i) of [e y v]) < ((player y) + ((48) + (y size)))> and <((player y) - ((26) + (y size))) < (item (tile i) of [e y v])>> then\n        if <(item (tile i) of [e y v]) < (player y)> then\n            set [touching floor? v] to [1]\n            change [player x v] by (x shift)\n        end\n    end\nend\n\nset [editing? v] to [0]\n\nset [editing? v] to [1]\n\nif <(item (tile i) of [e type v]) = [6]> then\n    obj collide x [12] [12] []\nend\n\ndefine render player\nif <<<key (a v) pressed?> or <key (left arrow v) pressed?>> and <<key (d v) pressed?> or <key (right arrow v) pressed?>>> then\n    if <(player x vel) > [1]> then\n        point in direction (90)\n    else\n        if <[-1] > (player x vel)> then\n            point in direction (-90)\n        end\n    end\nelse\n    if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then\n        point in direction (90)\n    else\n        if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then\n            point in direction (-90)\n        end\n    end\nend\nif <(touching floor?) = [1]> then\n    if <(stuck?) = [1]> then\n        switch costume to (join [stuckidle] ((([floor v] of ((tick) / (3)) ) mod (4)) + (1)))\n        if <(player x vel) > [2]> then\n            switch costume to (join [stuckrun] ((([floor v] of ((tick) / (3)) ) mod (6)) + (1)))\n        end\n        if <[-2] > (player x vel)> then\n            switch costume to (join [stuckrun] ((([floor v] of ((tick) / (3)) ) mod (6)) + (1)))\n        end\n    else\n        switch costume to (join [idle] ((([floor v] of ((tick) / (3)) ) mod (4)) + (1)))\n        if <(player x vel) > [2]> then\n            switch costume to (join [run] ((([floor v] of ((tick) / (3)) ) mod (6)) + (1)))\n        end\n        if <[-2] > (player x vel)> then\n            switch costume to (join [run] ((([floor v] of ((tick) / (3)) ) mod (6)) + (1)))\n        end\n    end\nelse\n    if <(stuck?) = [1]> then\n        if <[2] > ([abs v] of (player y vel) )> then\n            switch costume to (join [stuckair] ((([floor v] of ((tick) / (3)) ) mod (3)) + (1)))\n        else\n            if <(player y vel) > [0]> then\n                switch costume to (join [stuckjump] ((([floor v] of ((tick) / (3)) ) mod (3)) + (1)))\n            else\n                switch costume to (join [stuckfall] ((([floor v] of ((tick) / (3)) ) mod (3)) + (1)))\n            end\n        end\n    else\n        if <[2] > ([abs v] of (player y vel) )> then\n            switch costume to (join [air] ((([floor v] of ((tick) / (3)) ) mod (3)) + (1)))\n        else\n            if <(player y vel) > [0]> then\n                switch costume to (join [jump] ((([floor v] of ((tick) / (3)) ) mod (3)) + (1)))\n            else\n                switch costume to (join [fall] ((([floor v] of ((tick) / (3)) ) mod (3)) + (1)))\n            end\n        end\n    end\nend\n\ndefine respawn check\ntouching ground? ((player x) - (24)) ((player y) + (48))\nif <(@tile) = [1]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) + (24)) ((player y) + (48))\nif <(@tile) = [1]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) - (24)) ((player y) + (24))\nif <(@tile) = [1]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) + (24)) ((player y) + (24))\nif <(@tile) = [1]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) - (24)) ((player y) - (16))\nif <(@tile) = [1]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) + (24)) ((player y) - (16))\nif <(@tile) = [1]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) - (24)) ((player y) + (40))\nif <(@tile) = [2]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) + (24)) ((player y) + (40))\nif <(@tile) = [2]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) - (24)) ((player y) + (24))\nif <(@tile) = [2]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) + (24)) ((player y) + (24))\nif <(@tile) = [2]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) - (24)) ((player y) - (24))\nif <(@tile) = [2]> then\n    set [respawn? v] to [1]\nend\ntouching ground? ((player x) + (24)) ((player y) - (24))\nif <(@tile) = [2]> then\n    set [respawn? v] to [1]\nend\nif <(respawn?) = [1]> then\n    broadcast (respawn v)\n    repeat (3)\n        set [brightness v] effect to (100)\n        wait (.1) seconds\n        clear graphic effects\n        wait (.1) seconds\n    end\n    set [player x v] to [256]\n    set [player y v] to [200]\nend\n\nset [player x v] to [256]\nset [player x v] to [200]\n\nswitch costume to (air1 v)\n\n@Sprite1\n\nwhen I receive [back v]\ngo to x: (() - (((x scroll) / (1.5)) mod (24))) y: (() - (((y scroll) / (1.5)) mod (24)))\nstamp\n\nwhen flag clicked\nset [brightness v] effect to (-30)\nswitch costume to (costume1 v)\nset size to (300) %\nswitch costume to (back v)\n\n@entities\n\ndefine scan for entities\ndelete all of [e x v]\ndelete all of [e y v]\ndelete all of [e type v]\ndelete all of [e dir v]\nset [tile x v] to [0]\nrepeat (100)\n    set [tile y v] to [0]\n    repeat (level height)\n        change [tile y v] by (1)\n        if <(letter (1) of (item (((tile x) * (level height)) + (tile y)) of [level v])) = [e]> then\n            if <not <(item (((tile x) * (level height)) + (tile y)) of [level v]) = [e05]>> then\n                set [obj x v] to (((tile x) * (24)) + (12))\n                set [obj y v] to (((tile y) * (24)) + (12))\n                set [obj type v] to (join (letter (2) of (item (((tile x) * (level height)) + (tile y)) of [level v])) (letter (3) of (item (((tile x) * (level height)) + (tile y)) of [level v])))\n                set [obj id v] to [1]\n                create clone of (_myself_ v)\n            end\n        end\n    end\n    change [tile x v] by (1)\nend\nset [obj id v] to [0]\n\nwhen I receive [x moving platforms v]\nif <not <(obj id) = [0]>> then\n    if <(obj type) = [1]> then\n        switch costume to (1 v)\n        if <(obj dir) = [0]> then\n            change [obj x v] by (2)\n            tile@ ((obj x) + (37)) (obj y)\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                set [obj dir v] to [1]\n            end\n        else\n            change [obj x v] by (-2)\n            tile@ ((obj x) + (-37)) (obj y)\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                set [obj dir v] to [0]\n            end\n        end\n        add (obj x) to [e x v]\n        add (obj y) to [e y v]\n        add (obj dir) to [e dir v]\n        add (obj type) to [e type v]\n    end\n    if <(obj type) = [3]> then\n        switch costume to (3 v)\n        if <(obj dir) = [0]> then\n            turn right (15) degrees\n            change [obj x v] by (3)\n            tile@ ((obj x) + (13)) (obj y)\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                set [obj dir v] to [1]\n            end\n        else\n            turn left (15) degrees\n            change [obj x v] by (-3)\n            tile@ ((obj x) + (-13)) (obj y)\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                set [obj dir v] to [0]\n            end\n        end\n    end\nend\n\nwhen flag clicked\nshow\nscan for entities\nhide\n\ndefine tile@ (x) (y)\nset [@tile v] to ((([floor v] of ((x) / (24)) ) * (level height)) + ([floor v] of ((y) / (24)) ))\n\nwhen I receive [y moving platforms v]\nif <not <(obj id) = [0]>> then\n    if <(obj type) = [1]> then\n        add (obj x) to [e x v]\n        add (obj y) to [e y v]\n        add (obj dir) to [e dir v]\n        add (obj type) to [e type v]\n    end\n    if <(obj type) = [2]> then\n        switch costume to (2 v)\n        if <(obj dir) = [0]> then\n            change [obj y v] by (2)\n            tile@ (obj x) ((obj y) + (13))\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                set [obj dir v] to [1]\n            end\n        else\n            change [obj y v] by (-2)\n            tile@ (obj x) ((obj y) + (-13))\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                set [obj dir v] to [0]\n            end\n        end\n        add (obj x) to [e x v]\n        add (obj y) to [e y v]\n        add (obj dir) to [e dir v]\n        add (obj type) to [e type v]\n    end\n    if <(obj type) = [4]> then\n        switch costume to (3 v)\n        if <(obj dir) = [0]> then\n            turn right (15) degrees\n            change [obj y v] by (3)\n            tile@ (obj x) ((obj y) + (13))\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                set [obj dir v] to [1]\n            end\n        else\n            turn left (15) degrees\n            change [obj y v] by (-3)\n            tile@ (obj x) ((obj y) + (-13))\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                set [obj dir v] to [0]\n            end\n        end\n    end\n    if <(obj type) = [6]> then\n        switch costume to (4 v)\n        if <(obj dir) < [18]> then\n            add (obj x) to [e x v]\n            add (obj y) to [e y v]\n            add [0] to [e dir v]\n            add (obj type) to [e type v]\n        end\n        if <(obj dir) = [0]> then\n            if <((obj y) + (36)) = (player y)> then\n                if <<(player x) > ((obj x) - (60))> and <((obj x) - (-60)) > (player x)>> then\n                    set [obj dir v] to [1]\n                end\n            end\n        else\n            change [obj dir v] by (1)\n        end\n        if <(obj dir) > [90]> then\n            if <not <<(player x) > ((obj x) + (24))> and <(obj x) > ((player x) - (48))>>> then\n                if <not <<(player x) > ((obj x) - (60))> and <((obj x) - (-60)) > (player x)>>> then\n                    set [obj dir v] to [0]\n                end\n            end\n        end\n    end\n    if <(obj type) = [7]> then\n        switch costume to (5 v)\n        add (obj x) to [e x v]\n        add (obj y) to [e y v]\n        add (obj type) to [e type v]\n        if <<<((obj y) + (36.01)) > (player y)> and <(player y) > ((obj y) + (28))>> and <<(player x) > ((obj x) - (60))> and <((obj x) - (-60)) > (player x)>>> then\n            tile@ (obj x) ((obj y) + (-17))\n            if <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>> then\n                add [1] to [e dir v]\n            else\n                add [0] to [e dir v]\n                change [obj y v] by (-4)\n            end\n        else\n            add [1] to [e dir v]\n            tile@ (obj x) ((obj y) + (15))\n            if <not <<(item (@tile) of [level v]) = [1]> or <(item (@tile) of [level v]) = [e05]>>> then\n                change [obj y v] by (2)\n            end\n        end\n    end\nend\n\nwhen I receive [render v]\nif <not <(obj id) = [0]>> then\n    go to x: ((obj x) - (x scroll)) y: ((obj y) - (y scroll))\n    set size to (300) %\n    if <(obj type) = [6]> then\n        if <not <(obj dir) = [0]>> then\n            go to x: (((obj x) - (x scroll)) + (pick random (-2) to (2))) y: (((obj y) - (y scroll)) + (pick random (-2) to (2)))\n        end\n        clear graphic effects\n        if <(obj dir) > [10]> then\n            set [ghost v] effect to (((obj dir) - (10)) * (10))\n        end\n        if <(obj dir) > [15]> then\n            change y by (((obj dir) - (15)) * (-20))\n        end\n    end\nend\n\nwhen I start as a clone\nif <(obj type) = [1]> then\n    switch costume to (1 v)\nend\nif <(obj type) = [2]> then\n    switch costume to (2 v)\nend\nif <(obj type) = [3]> then\n    switch costume to (3 v)\nend\nif <(obj type) = [4]> then\n    switch costume to (3 v)\nend\nif <(obj type) = [6]> then\n    switch costume to (4 v)\nend\nif <(obj type) = [7]> then\n    switch costume to (5 v)\nend\n\nset [editing? v] to [0]\n\nset [@tile v] to [0]\n\n