Intersections - A Platformer

Instructions: Unfinished game. See if you can figure out what's going on :D\n\nArrow keys to move.

@Stage\n\n@Sprite1\n\nwhen flag clicked\nset [size v] to [40]\nset [thick v] to [5]\nhide\nCreate Level\nset [x v] to (round ((Size) * (-0.5)))\nset [y v] to [25]\nset [xv v] to [0]\nset [yv v] to [0]\nset [in air v] to [10]\nforever\n    physics\n    cam\n    render\nend\n\ndefine Add block (type) to level from (x) (y) to (x2) (y2) color (color)\nadd (type) to [level v]\nadd (x) to [level v]\nadd (y) to [level v]\nadd (x2) to [level v]\nadd (y2) to [level v]\nadd (pick random (1) to (6)) to [level v]\n\ndefine render\nerase all\nset [i v] to [1]\nrepeat ((length of [level v]) / (6))\n    set pen size to (Thick)\n    Set Pen Color to (item ((i) + (5)) of [level v])\n    set pen (transparency v) to (65)\n    change pen size by ((([sin v] of ((timer) * (125)) ) + (1)) * (3))\n    Shift, Rotate and Draw Rect from (item ((i) + (1)) of [level v]) (item ((i) + (2)) of [level v]) to (item ((i) + (3)) of [level v]) (item ((i) + (4)) of [level v])\n    change pen size by ((([sin v] of ((timer) * (125)) ) + (1)) * (-3))\n    set pen (transparency v) to (0)\n    Shift, Rotate and Draw Rect from (item ((i) + (1)) of [level v]) (item ((i) + (2)) of [level v]) to (item ((i) + (3)) of [level v]) (item ((i) + (4)) of [level v])\n    change [i v] by (6)\nend\nSet Pen Color to [0]\nShift, Rotate and Draw Rect from ((X) + (Thick)) ((Y) + (Thick)) to (((X) + (Size)) - (Thick)) (((Y) + (Size)) - (Thick))\n\ndefine Go to (x) (y)\ngo to x: (((x) - (Cam X)) - (Smooth Cam X)) y: (((y) - (Cam Y)) - (Smooth Cam Y))\n\ndefine Shift, Rotate and Draw Rect from (x) (y) to (x2) (y2)\nRotate and Draw Rect from (((((x) - (Cam X)) * (XScale)) + (Cam X)) + ((Size) * ((-0.5) * (([abs v] of (XScale) ) - (1))))) (((((y) - (Cam Y)) * (YScale)) + (Cam Y)) + ((Size) * ((-0.5) * (([abs v] of (YScale) ) - (1))))) to (((((x2) - (Cam X)) * (XScale)) + (Cam X)) + ((Size) * ((0.5) * (([abs v] of (XScale) ) - (1))))) (((((y2) - (Cam Y)) * (YScale)) + (Cam Y)) + ((Size) * ((0.5) * (([abs v] of (YScale) ) - (1)))))\n\ndefine Set Pen Color to (color)\nset [color v] to (color)\nset [xscale v] to [1]\nset [yscale v] to [1]\nset [rotate? v] to [0]\nif <(color) = [0]> then\n    set pen color to (#c9c9c9)\nend\nif <(color) = [1]> then\n    set pen color to (#5978ff)\nend\nif <(color) = [2]> then\n    set pen color to (#5bff59)\n    set [xscale v] to [1.5]\nend\nif <(color) = [3]> then\n    set pen color to (#ff3578)\n    set [xscale v] to [-1]\nend\nif <(color) = [4]> then\n    set pen color to (#c21cff)\n    set [xscale v] to [-1]\n    set [yscale v] to [-1]\nend\nif <(color) = [5]> then\n    set pen color to (#ffd91c)\n    set [xscale v] to [-1]\n    set [rotate? v] to [1]\nend\nif <(color) = [6]> then\n    set pen color to (#ff951c)\n    set [xscale v] to [-1]\n    set [rotate? v] to [1]\n    set [yscale v] to [-1]\nend\n\ndefine cam\nset [cam x v] to ((X) + ((Size) * (0.5)))\nset [cam y v] to ((Y) + ((Size) * (0.5)))\nset [smooth cam x v] to [0]\nset [smooth cam y v] to [0]\n\ndefine physics\nif <<key (left arrow v) pressed?> or <key (a v) pressed?>> then\n    change [xv v] by (-4)\nend\nif <<key (right arrow v) pressed?> or <key (d v) pressed?>> then\n    change [xv v] by (4)\nend\nset [xv v] to ((Xv) * (0.7))\nchange [x v] by (round (Xv))\nCollisions\nif <(Collision) > [0]> then\n    if <(Xv) > [0]> then\n        set [x v] to ((item ((Collision) + (1)) of [level v]) - (Size))\n    else\n        set [x v] to (item ((Collision) + (3)) of [level v])\n    end\n    set [xv v] to [0]\nend\nchange [yv v] by (-1)\nif <<<key (up arrow v) pressed?> or <key (w v) pressed?>> and <(in air) < [4]>> then\n    set [yv v] to [10]\nend\nchange [y v] by (Yv)\nCollisions\nif <(in air) < [10]> then\n    change [in air v] by (1)\nend\nif <(Collision) > [0]> then\n    if <(Yv) > [0]> then\n        set [y v] to ((item ((Collision) + (2)) of [level v]) - (Size))\n    else\n        set [y v] to (item ((Collision) + (4)) of [level v])\n        set [in air v] to [0]\n    end\n    set [yv v] to [0]\nend\n\ndefine Collisions\nset [collision v] to [1]\nrepeat ((length of [level v]) / (6))\n    if <<<((X) + (Size)) > (item ((Collision) + (1)) of [level v])> and <((Y) + (Size)) > (item ((Collision) + (2)) of [level v])>> and <<(item ((Collision) + (3)) of [level v]) > (X)> and <(item ((Collision) + (4)) of [level v]) > (Y)>>> then\n        stop [this script v]\n    end\n    change [collision v] by (6)\nend\nset [collision v] to [0]\n\ndefine Rotate and Draw Rect from (x) (y) to (x2) (y2)\nif <(Rotate?) = [1]> then\n    Draw Rect from (((y) + (Cam X)) - (Cam Y)) (((x) + (Cam Y)) - (Cam X)) to (((y2) + (Cam X)) - (Cam Y)) (((x2) + (Cam Y)) - (Cam X))\nelse\n    Draw Rect from (x) (y) to (x2) (y2)\nend\n\nset [xscale v] to [1]\n\ndefine Create Level\ndelete all of [level v]\nset [i v] to [1]\nrepeat (2)\n    Add block [1] to level from [0] [-50] to [200] [0] color (i)\n    Add block [1] to level from [250] [-50] to [350] [0] color (i)\n    Add block [1] to level from [350] [-50] to [400] [50] color (i)\n    Add block [1] to level from [400] [0] to [500] [50] color (i)\n    Add block [1] to level from [600] [20] to [850] [50] color (i)\n    Add block [1] to level from [670] [50] to [780] [80] color (i)\n    Add block [1] to level from [975] [75] to [1200] [125] color (i)\n    Add block [1] to level from [1100] [-30] to [1400] [0] color (i)\n    if <(i) = [5]> then\n        Add block [1] to level from [1400] [50] to [1500] [75] color (i)\n    end\n    if <(i) = [1]> then\n        Add block [1] to level from [1600] [50] to [1750] [100] color (i)\n    end\n    Add block [1] to level from [1875] [0] to [1900] [115] color (i)\n    Add block [1] to level from [1900] [60] to [2200] [90] color (i)\n    change [i v] by (4)\nend\n\ndefine Draw Rect from (x) (y) to (x2) (y2)\npen up\nGo to (x) (y)\npen down\nGo to (x2) (y)\nGo to (x2) (y2)\nGo to (x) (y2)\nGo to (x) (y)\n\nchange [smooth cam x v] by (round ((((Xv) * (-2)) - (Smooth Cam X)) / (5)))\nchange [smooth cam y v] by (round ((((Yv) * (-2)) - (Smooth Cam Y)) / (5)))\n\n