Rotary Platformer

Instructions: Instructions are in game.\nWASD to move.\nRight arrow to rotate the world clockwise.\nLeft arrow to rotate the world counter-clockwise.\nPress R to restart the level.

@Stage\n\n@Sprite1\n\ndefine goto (x) (y) (angle)\ngo to x: (((x) * ([cos v] of (angle) )) - ((y) * ([sin v] of (angle) ))) y: (((x) * ([sin v] of (angle) )) + ((y) * ([cos v] of (angle) )))\n\ndefine rotate (x) (y) (angle)\nset [rotate x v] to (((x) * ([cos v] of (angle) )) - ((y) * ([sin v] of (angle) )))\nset [rotate y v] to (((x) * ([sin v] of (angle) )) + ((y) * ([cos v] of (angle) )))\n\ndefine rectangle (x) (y) (width) (height) (quality)\ndoes overlap (-300) (300) (300) (-300) (x) (y) ((x) + (width)) ((y) - (height))\nif <(overlap) = [1]> then\n    set [rectnx v] to (x)\n    set [rectny v] to (y)\n    set [rectnwidth v] to (width)\n    set [rectnheight v] to (height)\n    if <(rectnx) < [-300]> then\n        set [rectnwidth v] to ((rectnwidth) + ((rectnx) - (-300)))\n        set [rectnx v] to [-300]\n    end\n    if <[300] < (rectny)> then\n        set [rectnheight v] to ((rectnheight) - ((rectny) - (300)))\n        set [rectny v] to [300]\n    end\n    if <[300] < ((rectnx) + (rectnwidth))> then\n        set [rectnwidth v] to ((rectnwidth) + ((300) - ((rectnx) + (rectnwidth))))\n    end\n    if <((rectny) - (rectnheight)) < [-300]> then\n        set [rectnheight v] to ((rectnheight) - ((-300) - ((rectny) - (rectnheight))))\n    end\n    if <(rectnwidth) > (rectnheight)> then\n        set [pen size v] to (rectnheight)\n    else\n        set [pen size v] to (rectnwidth)\n    end\n    set pen size to (pen size)\n    set [rectx v] to ((rectnx) + ((pen size) / (2)))\n    set [recty v] to ((rectny) - ((pen size) / (2)))\n    goto (rectx) (recty) (@ANGLE)\n    pen down\n    if <(rectnwidth) > (rectnheight)> then\n        change [rectx v] by ((rectnwidth) - (pen size))\n    else\n        change [recty v] by (((rectnheight) - (pen size)) * (-1))\n    end\n    goto (rectx) (recty) (@ANGLE)\n    pen up\n    repeat until <<(pen size) < (quality)> or <(pen size) < [2]>>\n        set [pen size v] to ([ceiling v] of ((pen size) * (0.1464466094067262)) )\n        set pen size to (pen size)\n        set [rectx v] to ((rectnx) + ((pen size) / (2)))\n        set [recty v] to ((rectny) - ((pen size) / (2)))\n        goto (rectx) (recty) (@ANGLE)\n        pen down\n        change [rectx v] by ((rectnwidth) - (pen size))\n        goto (rectx) (recty) (@ANGLE)\n        change [recty v] by (((rectnheight) - (pen size)) * (-1))\n        goto (rectx) (recty) (@ANGLE)\n        change [rectx v] by (((rectnwidth) - (pen size)) * (-1))\n        goto (rectx) (recty) (@ANGLE)\n        change [recty v] by ((rectnheight) - (pen size))\n        goto (rectx) (recty) (@ANGLE)\n        pen up\n    end\n    set pen size to (1)\n    set [rectx v] to (rectnx)\n    set [recty v] to (rectny)\n    goto (rectx) (recty) (@ANGLE)\n    pen down\n    change [rectx v] by (rectnwidth)\n    goto (rectx) (recty) (@ANGLE)\n    change [recty v] by ((rectnheight) * (-1))\n    goto (rectx) (recty) (@ANGLE)\n    change [rectx v] by ((rectnwidth) * (-1))\n    goto (rectx) (recty) (@ANGLE)\n    change [recty v] by (rectnheight)\n    goto (rectx) (recty) (@ANGLE)\n    pen up\n    set [pen size v] to [1]\nend\n\ndefine does overlap (l1x) (l1y) (r1x) (r1y) (l2x) (l2y) (r2x) (r2y)\nif <<(l1x) > (r2x)> or <(l2x) > (r1x)>> then\n    set [overlap v] to [0]\n    stop [this script v]\nend\nif <<(l1y) < (r2y)> or <(l2y) < (r1y)>> then\n    set [overlap v] to [0]\n    stop [this script v]\nend\nset [overlap v] to [1]\n\ndefine get angle (x1) (y1) (x2) (y2)\nset [angle v] to ([atan v] of (((y2) - (y1)) / ((x2) - (x1))) )\nif <[0] > ((x2) - (x1))> then\n    change [angle v] by (180)\nend\n\nwhen flag clicked\nset [@angle v] to (rotary angle)\nset [rotary angle v] to ((round ((rotary angle) / (90))) * (90))\nforever\n    erase all\n    if <key (r v) pressed?> then\n        respawn\n    end\n    backdrop\n    switch costume to (costume1 v)\n    render hurts\n    render goals\n    check for death\n    render walls\n    switch costume to (costume2 v)\n    point in direction ((90) - (@ANGLE))\n    goto ((X) - (Scroll X)) ((Y) - (Scroll Y)) (@ANGLE)\n    rotate [0] [-1] ((0) - (@ANGLE))\n    set [down x v] to (rotate x)\n    set [down y v] to (rotate y)\n    if <(@EDIT_MODE) = [0]> then\n        change [yvel v] by (down y)\n        change [xvel v] by (down x)\n        set [xvel v] to ((xVel) * (0.95))\n        set [yvel v] to ((yVel) * (0.95))\n        change [x v] by (xVel)\n        push out x\n        change [y v] by (yVel)\n        check for win\n        push out y\n        rotate (xVel) (yVel) (@ANGLE)\n        set [temp v] to (rotate y)\n        if <(round ((rotate y) * (1))) = [0]> then\n            set [onground v] to [1]\n            set [xvel v] to ((xVel) * (0.9))\n            set [yvel v] to ((yVel) * (0.9))\n            check below\n            if <(collide) = [0]> then\n                set [onground v] to [0]\n            end\n        else\n            set [onground v] to [0]\n        end\n        if <key (d v) pressed?> then\n            change [xvel v] by ((down y) * (-0.2))\n            change [yvel v] by ((down x) * (0.2))\n        end\n        if <key (a v) pressed?> then\n            change [xvel v] by ((down y) * (0.2))\n            change [yvel v] by ((down x) * (-0.2))\n        end\n        if <(onGround) = [1]> then\n            if <<key (w v) pressed?> or <<key (up arrow v) pressed?> or <key (space v) pressed?>>> then\n                against wall\n                change [xvel v] by ((down x) * (-15))\n                change [yvel v] by ((down y) * (-15))\n            end\n            if <key (d v) pressed?> then\n                change [xvel v] by ((down y) * (-0.8))\n                change [yvel v] by ((down x) * (0.8))\n            end\n            if <key (a v) pressed?> then\n                change [xvel v] by ((down y) * (0.8))\n                change [yvel v] by ((down x) * (-0.8))\n            end\n        end\n        if <(death) = [1]> then\n            respawn\n        end\n        if <<(win level) = [1]> and <not <(death) = [1]>>> then\n            save level\n            respawn\n            change [@level v] by (1)\n            load level (@LEVEL)\n        end\n    else\n        if <key ((join [=] []) v) pressed?> then\n            save level\n            wait until <not <key ((join [=] []) v) pressed?>>\n        end\n        if <key ((join [-] []) v) pressed?> then\n            set [add v] to (((add) + (1)) mod (3))\n            wait until <not <key ((join [-] []) v) pressed?>>\n        end\n        if <key (up arrow v) pressed?> then\n            save level\n            respawn\n            change [@level v] by (1)\n            load level (@LEVEL)\n            wait until <not <key (up arrow v) pressed?>>\n        end\n        if <key (down arrow v) pressed?> then\n            save level\n            respawn\n            change [@level v] by (-1)\n            load level (@LEVEL)\n            wait until <not <key (down arrow v) pressed?>>\n        end\n        if <key (space v) pressed?> then\n            save level\n            change [@level v] by (1)\n            load level (@LEVEL)\n        end\n        if <key (w v) pressed?> then\n            change [x v] by ((down x) * (-5))\n            change [y v] by ((down y) * (-5))\n        end\n        if <key (s v) pressed?> then\n            change [x v] by ((down x) * (5))\n            change [y v] by ((down y) * (5))\n        end\n        if <key (d v) pressed?> then\n            change [x v] by ((down y) * (-5))\n            change [y v] by ((down x) * (5))\n        end\n        if <key (a v) pressed?> then\n            change [x v] by ((down y) * (5))\n            change [y v] by ((down x) * (-5))\n        end\n        find mouse\n        if <mouse down?> then\n            if <<not <([abs v] of (mouse y) ) = [180]>> and <not <([abs v] of (mouse x) ) = [240]>>> then\n                if <(add) = [0]> then\n                    add ((round ((Mouse X) / ((player width) + (1)))) * ((player width) + (1))) to [walls v]\n                    add ((round ((Mouse Y) / ((player height) + (1)))) * ((player height) + (1))) to [walls v]\n                end\n                if <(add) = [1]> then\n                    add ((round ((Mouse X) / ((player width) + (1)))) * ((player width) + (1))) to [hurts v]\n                    add ((round ((Mouse Y) / ((player height) + (1)))) * ((player height) + (1))) to [hurts v]\n                end\n                if <(add) = [2]> then\n                    add ((round ((Mouse X) / ((player width) + (1)))) * ((player width) + (1))) to [goals v]\n                    add ((round ((Mouse Y) / ((player height) + (1)))) * ((player height) + (1))) to [goals v]\n                end\n                wait until <not <mouse down?>>\n            end\n        end\n        if <key (x v) pressed?> then\n            find mouse\n            check mouse\n            if <(collide) = [1]> then\n                repeat (4)\n                    delete (((r) * (4)) + (1)) of [walls v]\n                end\n            end\n            check mouse goals\n            if <(collide) = [1]> then\n                repeat (4)\n                    delete (((r) * (4)) + (1)) of [goals v]\n                end\n            end\n            check mouse hurts\n            if <(collide) = [1]> then\n                repeat (4)\n                    delete (((r) * (4)) + (1)) of [hurts v]\n                end\n            end\n        end\n    end\n    broadcast (tick v) and wait\n    set [scroll x v] to ((((Scroll X) * (5)) + (X)) / (6))\n    set [scroll y v] to ((((Scroll Y) * (5)) + (Y)) / (6))\n    set [@fps v] to (round ((1) / ((timer) - (frametime))))\n    set [frametime v] to (timer)\n    if <key (left arrow v) pressed?> then\n        if <(rotary angle) > (@ANGLE)> then\n    else\n        if <key (right arrow v) pressed?> then\n            if <(@ANGLE) > (rotary angle)> then\n        end\n    end\n    if <not <(@ANGLE) = (rotary angle)>> then\n        if <(@ANGLE) > (rotary angle)> then\n            change [@angle v] by (-5)\n        else\n            change [@angle v] by (5)\n        end\n    end\nend\n\ndefine distance (x1) (y1) (x2) (y2)\nset [distance v] to ([sqrt v] of ((((x1) - (x2)) * ((x1) - (x2))) + (((y1) - (y2)) * ((y1) - (y2)))) )\n\ndefine background\nswitch costume to (costume3 v)\ngoto (() - ((((Scroll X) / (5)) mod (480)) + ((-480) * ((1) - (1))))) ((Scroll Y) / (-5)) (@ANGLE)\nstamp\ngoto (() - ((((Scroll X) / (5)) mod (480)) + ((-480) * ((2) - (1))))) ((Scroll Y) / (-5)) (@ANGLE)\nstamp\nswitch costume to (costume2 v)\n\ndefine does player overlap (x1) (y1) (x2) (y2)\ndoes overlap directionless ((X) - ((player width) / (2))) ((Y) + ((player height) / (2))) ((X) + ((player width) / (2))) ((Y) - ((player height) / (2))) (x1) (y1) (x2) (y2)\n\ndefine render walls\nset pen color to (#848484)\nset [r v] to [0]\nrepeat ([floor v] of ((length of [walls v]) / (4)) )\n    render wall (item (((r) * (4)) + (1)) of [walls v]) (item (((r) * (4)) + (2)) of [walls v]) (item (((r) * (4)) + (3)) of [walls v]) (item (((r) * (4)) + (4)) of [walls v])\n    change [r v] by (1)\nend\n\ndefine render wall (x1) (y1) (x2) (y2)\nrectangle xy ((x1) - (Scroll X)) ((y1) - (Scroll Y)) ((x2) - (Scroll X)) ((y2) - (Scroll Y)) [3]\n\ndefine does screen overlap (x1) (y1) (x2) (y2)\ndoes overlap directionless ((Scroll X) - (240)) ((Scroll Y) + (180)) ((Scroll X) + (240)) ((Scroll Y) - (180)) (x1) (y1) (x2) (y2)\n\ndefine push out x\nset [oq v] to [0]\ncheck for collisions\nrepeat until <<(collide) = [0]> or <(oq) > [9]>>\n    check for collisions\n    if <(collide) = [1]> then\n        change [x v] by ((-0.1) * (xVel))\n    end\n    change [oq v] by (1)\nend\nif <(oq) > [1]> then\n    set [movement lock x v] to [1]\n    set [xvel v] to [0]\nelse\n    set [movement lock x v] to [0]\nend\n\ndefine push out y\nset [oq v] to [0]\ncheck for collisions\nrepeat until <<(collide) = [0]> or <(oq) > [9]>>\n    check for collisions\n    if <(collide) = [1]> then\n        change [y v] by ((-0.1) * (yVel))\n    end\n    change [oq v] by (1)\nend\nif <(oq) > [1]> then\n    if <(yVel) < [0]> then\n    set [yvel v] to [0]\n    set [movement lock y v] to [1]\nelse\n    set [movement lock y v] to [0]\nend\n\ndefine check for collisions\nset [collide v] to [0]\nset [r v] to [0]\nrepeat ([floor v] of ((length of [walls v]) / (4)) )\n    does player overlap (item (((r) * (4)) + (1)) of [walls v]) (item (((r) * (4)) + (2)) of [walls v]) (item (((r) * (4)) + (3)) of [walls v]) (item (((r) * (4)) + (4)) of [walls v])\n    if <(overlap) = [1]> then\n        set [collide v] to [1]\n        stop [this script v]\n    end\n    change [r v] by (1)\nend\n\ndefine does overlap directionless (ax1) (ay1) (ax2) (ay2) (bx1) (by1) (bx2) (by2)\nif <(ax1) > (ax2)> then\n    if <(ay1) > (ay2)> then\n        if <(bx1) > (bx2)> then\n            if <(by1) > (by2)> then\n                does overlap (ax2) (ay1) (ax1) (ay2) (bx2) (by1) (bx1) (by2)\n            else\n                does overlap (ax2) (ay1) (ax1) (ay2) (bx2) (by2) (bx1) (by1)\n            end\n        else\n            if <(by1) > (by2)> then\n                does overlap (ax2) (ay1) (ax1) (ay2) (bx1) (by1) (bx2) (by2)\n            else\n                does overlap (ax2) (ay1) (ax1) (ay2) (bx1) (by2) (bx2) (by1)\n            end\n        end\n    else\n        if <(bx1) > (bx2)> then\n            if <(by1) > (by2)> then\n                does overlap (ax2) (ay2) (ax1) (ay1) (bx2) (by1) (bx1) (by2)\n            else\n                does overlap (ax2) (ay2) (ax1) (ay1) (bx2) (by2) (bx1) (by1)\n            end\n        else\n            if <(by1) > (by2)> then\n                does overlap (ax2) (ay2) (ax1) (ay1) (bx1) (by1) (bx2) (by2)\n            else\n                does overlap (ax2) (ay2) (ax1) (ay1) (bx1) (by2) (bx2) (by1)\n            end\n        end\n    end\nelse\n    if <(ay1) > (ay2)> then\n        if <(bx1) > (bx2)> then\n            if <(by1) > (by2)> then\n                does overlap (ax1) (ay1) (ax2) (ay2) (bx2) (by1) (bx1) (by2)\n            else\n                does overlap (ax1) (ay1) (ax2) (ay2) (bx2) (by2) (bx1) (by1)\n            end\n        else\n            if <(by1) > (by2)> then\n                does overlap (ax1) (ay1) (ax2) (ay2) (bx1) (by1) (bx2) (by2)\n            else\n                does overlap (ax1) (ay1) (ax2) (ay2) (bx1) (by2) (bx2) (by1)\n            end\n        end\n    else\n        if <(bx1) > (bx2)> then\n            if <(by1) > (by2)> then\n                does overlap (ax1) (ay2) (ax2) (ay1) (bx2) (by1) (bx1) (by2)\n            else\n                does overlap (ax1) (ay2) (ax2) (ay1) (bx2) (by2) (bx1) (by1)\n            end\n        else\n            if <(by1) > (by2)> then\n                does overlap (ax1) (ay2) (ax2) (ay1) (bx1) (by1) (bx2) (by2)\n            else\n                does overlap (ax1) (ay2) (ax2) (ay1) (bx1) (by2) (bx2) (by1)\n            end\n        end\n    end\nend\n\ndefine rectangle xy (x1) (y1) (x2) (y2) (quality)\nif <(x1) > (x2)> then\n    if <(y1) > (y2)> then\n        rectangle (x2) (y1) ((x1) - (x2)) ((y1) - (y2)) (quality)\n    else\n        rectangle (x2) (y2) ((x1) - (x2)) ((y2) - (y1)) (quality)\n    end\nelse\n    if <(y1) > (y2)> then\n        rectangle (x1) (y1) ((x2) - (x1)) ((y1) - (y2)) (quality)\n    else\n        rectangle (x1) (y2) ((x2) - (x1)) ((y2) - (y1)) (quality)\n    end\nend\n\ndefine backdrop\npoint in direction (90)\nswitch costume to (backdrop1 \(1\) v)\ngo to x: (0) y: (0)\nstamp\n\nbackground\n\nchange [xvel v] by (0.2)\n\nchange [xvel v] by ((rotate x) * (0.2))\nchange [yvel v] by ((rotate y) * (0.2))\n\nif <key (right arrow v) pressed?> then\n    change [xvel v] by ((rotate x) * (0.2))\nend\nif <key (left arrow v) pressed?> then\n    change [xvel v] by (-0.8)\nend\n\nset [yvel v] to [15]\nset [yvel v] to [15]\n\nchange [xvel v] by ((rotate x) * (-1))\nchange [yvel v] by ((rotate y) * (-1))\n\nset [onground v] to [1]\nset [onground v] to [0]\n\nset [xvel v] to ((xVel) * (0.85))\n\nset [@angle v] to [0]\n\nchange [@angle v] by (180)\n\nchange [@angle v] by (-45)\n\nif <(Scroll Y) < [-20]> then\n    set [scroll y v] to [-20]\nend\n\nforever\n    change [@angle v] by (1)\nend\n\ndefine against wall\nset [jump x v] to [0]\nset [jump y v] to [0]\nchange [x v] by (1)\ncheck for collisions\nif <(collide) = [1]> then\n    change [jump x v] by (1)\nend\nchange [x v] by (-1)\nchange [x v] by (-1)\ncheck for collisions\nif <(collide) = [1]> then\n    change [jump x v] by (-1)\nend\nchange [x v] by (1)\nchange [y v] by (1)\ncheck for collisions\nif <(collide) = [1]> then\n    change [jump y v] by (1)\nend\nchange [y v] by (-1)\nchange [y v] by (-1)\ncheck for collisions\nif <(collide) = [1]> then\n    change [jump y v] by (-1)\nend\nchange [y v] by (1)\nset [temp v] to ([sqrt v] of (([abs v] of (jump x) ) + ([abs v] of (jump y) )) )\nset [jump x v] to ((jump x) / (temp))\nset [jump y v] to ((jump y) / (temp))\n\nset [@angle v] to [0]\n\nchange [xvel v] by ((down x) * (-15))\nchange [yvel v] by ((down y) * (-15))\n\nchange [@angle v] by (1)\nchange [@angle v] by (-1)\n\ndefine compass\npoint in direction ((90) - (@ANGLE))\ngo to x: (200) y: (142)\nswitch costume to (costume4 v)\nstamp\n\ndefine render minimap (x) (y)\nif <(@MINIMAP_SCALE) = [0]> then\n    stop [this script v]\nend\nset [r cache v] to (@ANGLE)\nset [@angle v] to [0]\nset pen color to (#000000)\nrectangle ((x) - (40)) ((y) - (-40)) [80] [80] [3]\nset pen color to (#848484)\nset [r v] to [0]\nrepeat ((length of [walls v]) / (4))\n    render minimap wall (item (((r) * (4)) + (1)) of [walls v]) (item (((r) * (4)) + (2)) of [walls v]) (item (((r) * (4)) + (3)) of [walls v]) (item (((r) * (4)) + (4)) of [walls v]) (x) (y)\n    change [r v] by (1)\nend\nset [@angle v] to (r cache)\nset pen color to (#ffffff)\nset pen size to (1)\ngo to x: ((x) - (40)) y: ((y) - (-40))\npen down\ngo to x: ((x) - (40)) y: ((y) - (40))\ngo to x: ((x) - (-40)) y: ((y) - (40))\ngo to x: ((x) - (-40)) y: ((y) - (-40))\ngo to x: ((x) - (40)) y: ((y) - (-40))\npen up\nset pen size to ((player height) / (@MINIMAP_SCALE))\ngo to x: (round ((x) + (((X) - (Scroll X)) / (@MINIMAP_SCALE)))) y: (round ((y) + (((Y) - (Scroll Y)) / (@MINIMAP_SCALE))))\npen down\npen up\n\ndefine rectangle clipped (x) (y) (width) (height) (quality) (clip width) (clip height) (offset x) (offset y)\ndoes overlap ((clip width) * (-1)) (clip width) (clip height) ((clip height) * (-1)) (x) (y) ((x) + (width)) ((y) - (height))\nif <(overlap) = [1]> then\n    set [rectnx v] to (x)\n    set [rectny v] to (y)\n    set [rectnwidth v] to (width)\n    set [rectnheight v] to (height)\n    if <(rectnx) < ((clip width) * (-1))> then\n        set [rectnwidth v] to ((rectnwidth) + ((rectnx) - ((clip width) * (-1))))\n        set [rectnx v] to ((clip width) * (-1))\n    end\n    if <(clip height) < (rectny)> then\n        set [rectnheight v] to ((rectnheight) - ((rectny) - (clip height)))\n        set [rectny v] to (clip height)\n    end\n    if <(clip width) < ((rectnx) + (rectnwidth))> then\n        set [rectnwidth v] to ((rectnwidth) + ((clip width) - ((rectnx) + (rectnwidth))))\n    end\n    if <((rectny) - (rectnheight)) < ((clip height) * (-1))> then\n        set [rectnheight v] to ((rectnheight) - (((clip height) * (-1)) - ((rectny) - (rectnheight))))\n    end\n    rectangle ((rectnx) + (offset x)) ((rectny) + (offset y)) (rectnwidth) (rectnheight) (quality)\nend\n\ndefine rectangle clipped xy (x1) (y1) (x2) (y2) (quality) (clipped width) (clipped height) (offset x) (offset y)\nif <(x1) > (x2)> then\n    if <(y1) > (y2)> then\n        rectangle clipped (x2) (y1) ((x1) - (x2)) ((y1) - (y2)) (quality) (clipped width) (clipped height) (offset x) (offset y)\n    else\n        rectangle clipped (x2) (y2) ((x1) - (x2)) ((y2) - (y1)) (quality) (clipped width) (clipped height) (offset x) (offset y)\n    end\nelse\n    if <(y1) > (y2)> then\n        rectangle clipped (x1) (y1) ((x2) - (x1)) ((y1) - (y2)) (quality) (clipped width) (clipped height) (offset x) (offset y)\n    else\n        rectangle clipped (x1) (y2) ((x2) - (x1)) ((y2) - (y1)) (quality) (clipped width) (clipped height) (offset x) (offset y)\n    end\nend\n\ndefine render minimap wall (x1) (y1) (x2) (y2) (x) (y)\nrectangle clipped xy (((x1) - (Scroll X)) / (@MINIMAP_SCALE)) (((y1) - (Scroll Y)) / (@MINIMAP_SCALE)) (((x2) - (Scroll X)) / (@MINIMAP_SCALE)) (((y2) - (Scroll Y)) / (@MINIMAP_SCALE)) [2] [40] [40] (x) (y)\n\nset [mouse x v] to [0]\nset [mouse y v] to [0]\n\nset [@edit_mode v] to [0]\n\nwhen [0 v] key pressed\nif <(username) = [greenscripter]> then\n    set [@edit_mode v] to ((1) - (@EDIT_MODE))\n    if <(@EDIT_MODE) = [1]> then\n        show variable [add v]\n        set [xvel v] to [0]\n        set [yvel v] to [0]\n    else\n        hide variable [add v]\n    end\nend\n\ndefine find mouse\nrotate (mouse x) (mouse y) ((0) - (@ANGLE))\nset [mouse x v] to ((rotate x) + (Scroll X))\nset [mouse y v] to ((rotate y) + (Scroll Y))\n\ndefine check mouse\nset [collide v] to [0]\nset [r v] to [0]\nrepeat ([floor v] of ((length of [walls v]) / (4)) )\n    does overlap directionless (item (((r) * (4)) + (1)) of [walls v]) (item (((r) * (4)) + (2)) of [walls v]) (item (((r) * (4)) + (3)) of [walls v]) (item (((r) * (4)) + (4)) of [walls v]) (Mouse X) (Mouse Y) (Mouse X) (Mouse Y)\n    if <(overlap) = [1]> then\n        set [collide v] to [1]\n        stop [this script v]\n    end\n    change [r v] by (1)\nend\n\ndefine check below\nchange [x v] by (down x)\nchange [y v] by (down y)\ncheck for collisions\nchange [x v] by ((0) - (down x))\nchange [y v] by ((0) - (down y))\n\ncompass\n\ndefine render hurts\nset pen color to (#cc0000)\nset [r v] to [0]\nrepeat ([floor v] of ((length of [hurts v]) / (4)) )\n    render wall (item (((r) * (4)) + (1)) of [hurts v]) (item (((r) * (4)) + (2)) of [hurts v]) (item (((r) * (4)) + (3)) of [hurts v]) (item (((r) * (4)) + (4)) of [hurts v])\n    change [r v] by (1)\nend\n\ndefine render goals\nset pen color to (#00af04)\nset [r v] to [0]\nrepeat ([floor v] of ((length of [goals v]) / (4)) )\n    render wall (item (((r) * (4)) + (1)) of [goals v]) (item (((r) * (4)) + (2)) of [goals v]) (item (((r) * (4)) + (3)) of [goals v]) (item (((r) * (4)) + (4)) of [goals v])\n    change [r v] by (1)\nend\n\ndefine check for death\nset [death v] to [0]\nset [r v] to [0]\nrepeat ([floor v] of ((length of [hurts v]) / (4)) )\n    does player overlap (item (((r) * (4)) + (1)) of [hurts v]) (item (((r) * (4)) + (2)) of [hurts v]) (item (((r) * (4)) + (3)) of [hurts v]) (item (((r) * (4)) + (4)) of [hurts v])\n    if <(overlap) = [1]> then\n        set [death v] to [1]\n        stop [this script v]\n    end\n    change [r v] by (1)\nend\n\ndefine check for win\nset [win level v] to [0]\nset [r v] to [0]\nrepeat ([floor v] of ((length of [goals v]) / (4)) )\n    does player overlap (item (((r) * (4)) + (1)) of [goals v]) (item (((r) * (4)) + (2)) of [goals v]) (item (((r) * (4)) + (3)) of [goals v]) (item (((r) * (4)) + (4)) of [goals v])\n    if <(overlap) = [1]> then\n        set [win level v] to [1]\n        stop [this script v]\n    end\n    change [r v] by (1)\nend\n\ndefine check mouse hurts\nset [collide v] to [0]\nset [r v] to [0]\nrepeat ([floor v] of ((length of [hurts v]) / (4)) )\n    does overlap directionless (item (((r) * (4)) + (1)) of [hurts v]) (item (((r) * (4)) + (2)) of [hurts v]) (item (((r) * (4)) + (3)) of [hurts v]) (item (((r) * (4)) + (4)) of [hurts v]) (Mouse X) (Mouse Y) (Mouse X) (Mouse Y)\n    if <(overlap) = [1]> then\n        set [collide v] to [1]\n        stop [this script v]\n    end\n    change [r v] by (1)\nend\n\ndefine check mouse goals\nset [collide v] to [0]\nset [r v] to [0]\nrepeat ([floor v] of ((length of [goals v]) / (4)) )\n    does overlap directionless (item (((r) * (4)) + (1)) of [goals v]) (item (((r) * (4)) + (2)) of [goals v]) (item (((r) * (4)) + (3)) of [goals v]) (item (((r) * (4)) + (4)) of [goals v]) (Mouse X) (Mouse Y) (Mouse X) (Mouse Y)\n    if <(overlap) = [1]> then\n        set [collide v] to [1]\n        stop [this script v]\n    end\n    change [r v] by (1)\nend\n\ndefine save level\nset [join v] to []\nset [r v] to [1]\nrepeat (length of [walls v])\n    set [join v] to (join (join) (join (item (r) of [walls v]) [,]))\n    change [r v] by (1)\nend\nset [join v] to (join (join) [;])\nset [r v] to [1]\nrepeat (length of [hurts v])\n    set [join v] to (join (join) (join (item (r) of [hurts v]) [,]))\n    change [r v] by (1)\nend\nset [join v] to (join (join) [;])\nset [r v] to [1]\nrepeat (length of [goals v])\n    set [join v] to (join (join) (join (item (r) of [goals v]) [,]))\n    change [r v] by (1)\nend\nset [join v] to (join (join) [;])\nif <(@LEVEL) > (length of [levels v])> then\n    add (join) to [levels v]\nelse\n    replace item (@LEVEL) of [levels v] with (join)\nend\n\nsave level\n\ndefine load level (level)\ndelete all of [goals v]\ndelete all of [hurts v]\ndelete all of [walls v]\nset [temp v] to (item (level) of [levels v])\nset [join v] to []\nset [add v] to [0]\nset [r v] to [1]\nrepeat (length of (temp))\n    if <(letter (r) of (temp)) = [,]> then\n        if <(add) = [0]> then\n            add (join) to [walls v]\n        end\n        if <(add) = [1]> then\n            add (join) to [hurts v]\n        end\n        if <(add) = [2]> then\n            add (join) to [goals v]\n        end\n        set [join v] to []\n    else\n        if <(letter (r) of (temp)) = [;]> then\n            set [join v] to []\n            change [add v] by (1)\n        else\n            set [join v] to (join (join) (letter (r) of (temp)))\n        end\n    end\n    change [r v] by (1)\nend\nset [add v] to [0]\nif <(@LEVEL) > (length of [levels v])> then\n    add [1000] to [hurts v]\n    add [1000] to [hurts v]\n    add [1100] to [hurts v]\n    add [-1000] to [hurts v]\n    add [1000] to [hurts v]\n    add [-1000] to [hurts v]\n    add [-1000] to [hurts v]\n    add [-1100] to [hurts v]\n    add [-1000] to [hurts v]\n    add [-1000] to [hurts v]\n    add [-1100] to [hurts v]\n    add [1000] to [hurts v]\n    add [-1000] to [hurts v]\n    add [1000] to [hurts v]\n    add [1000] to [hurts v]\n    add [1100] to [hurts v]\nend\n\nload level [1]\n\ndefine respawn\nset [@angle v] to [0]\nset [rotary angle v] to [0]\nset [x v] to [0]\nset [y v] to [0]\nset [xvel v] to [0]\nset [yvel v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [0]\n\nwhen flag clicked\nset [@level v] to [1]\nrespawn\nload level [1]\n\nset [@angle v] to [240]\nset [rotary angle v] to [240]\n\npoint in direction ((90) - (@ANGLE))\n\ncheck for death\n\n@Sprite2\n\nwhen I receive [tick v]\nhide\nset [intended x v] to [-100000]\nset [intended y v] to [-100000]\nif <(@LEVEL) = [2]> then\n    switch costume to (costume1 v)\n    set [intended x v] to ((20) - (Scroll X))\n    set [intended y v] to ((-150) - (Scroll Y))\nend\nif <(@LEVEL) = [1]> then\n    switch costume to (costume2 v)\n    set [intended x v] to ((0) - (Scroll X))\n    set [intended y v] to ((50) - (Scroll Y))\nend\nif <(@LEVEL) = [3]> then\n    switch costume to (costume3 v)\n    set [intended x v] to ((-54) - (Scroll X))\n    set [intended y v] to ((50) - (Scroll Y))\nend\nif <(@LEVEL) = [14]> then\n    switch costume to (costume4 v)\n    set [intended x v] to ((0) - (Scroll X))\n    set [intended y v] to ((30) - (Scroll Y))\nend\nif <(@LEVEL) = [15]> then\n    switch costume to (costume5 v)\n    set [intended x v] to ((0) - (Scroll X))\n    set [intended y v] to ((30) - (Scroll Y))\nend\nif <(@LEVEL) = [16]> then\n    switch costume to (costume6 v)\n    set [intended x v] to ((0) - (Scroll X))\n    set [intended y v] to ((30) - (Scroll Y))\nend\ngoto (round (intended X)) (round (intended Y)) (@ANGLE)\nif <<(round (intended X)) = (round (x position))> and <(round (intended Y)) = (round (y position))>> then\n    show\n    point in direction ((90) - (@ANGLE))\nend\n\ndefine goto (x) (y) (angle)\ngo to x: (((x) * ([cos v] of (angle) )) - ((y) * ([sin v] of (angle) ))) y: (((x) * ([sin v] of (angle) )) + ((y) * ([cos v] of (angle) )))\nset [intended x v] to (((x) * ([cos v] of (angle) )) - ((y) * ([sin v] of (angle) )))\nset [intended y v] to (((x) * ([sin v] of (angle) )) + ((y) * ([cos v] of (angle) )))\n\n@Sprite3\n\nwhen flag clicked\ngo to [front v] layer\ngo to x: (0) y: (0)\nhide\n\nshow\n\n