Restart - Pen Platformer 

Instructions: Game Controls:\n- WASD or Arrow Keys to move\n- To wall jump, move against a wall (keep the movement key held) and jump and move in the opposite direction at roughly the same time (it's easiest to continue holding the jump button); it is possible to wall jump with only a single wall\n\nRed kills you.\nPink is bouncy.\nThe green line lets you go to another level.\nEnjoy!

@Stage\n\n@Game 1\n\nwhen flag clicked\nhide\ncreate level\nget colors\nset [goal v] to [0]\nrepeat until <(goal) = [1]>\n    physics [8] <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <key (space v) pressed?>>> <<key (left arrow v) pressed?> or <key (a v) pressed?>> <<key (right arrow v) pressed?> or <key (d v) pressed?>>\n    set [camoffsetx v] to (((0.8) * (camOffsetX)) + ((0.2) * ((-3) * (velX))))\n    set [camoffsety v] to (((0.8) * (camOffsetY)) + ((0.2) * ((-3) * (velY))))\n    set [camx v] to ((playerX) + (camOffsetX))\n    set [camy v] to ((playerY) + (camOffsetY))\n    draw\n    if <<(death) = [1]> or <(playerY) < [-500]>> then\n        reset\n    end\nend\nset [goal v] to [0]\nset [start new game v] to [1]\nbroadcast (Next Level v)\nstop [this script v]\n\ndefine create level\nset [playerx v] to [0]\nset [playery v] to [0]\nset [camoffsetx v] to [0]\nset [camoffsety v] to [0]\nset [slopemove v] to [0]\nset [onground v] to [0]\nset [walljump v] to [0]\ndelete all of [linetype v]\ndelete all of [linex0 v]\ndelete all of [linex1 v]\ndelete all of [liney0 v]\ndelete all of [liney1 v]\nadd line | type [0] (X0, Y0) [-200] [-50] (X1, Y1) [200] [-50]\nadd line | type [0] (X0, Y0) [50] [-50] (X1, Y1) [50] [50]\nadd line | type [0] (X0, Y0) [50] [50] (X1, Y1) [150] [50]\nadd line | type [0] (X0, Y0) [150] [50] (X1, Y1) [150] [-50]\nadd line | type [0] (X0, Y0) [200] [-50] (X1, Y1) [200] [50]\nadd line | type [0] (X0, Y0) [200] [50] (X1, Y1) [1000] [50]\nadd line | type [3] (X0, Y0) [400] [50] (X1, Y1) [450] [100]\nadd line | type [3] (X0, Y0) [450] [100] (X1, Y1) [500] [50]\nadd line | type [3] (X0, Y0) [600] [50] (X1, Y1) [700] [150]\nadd line | type [3] (X0, Y0) [700] [150] (X1, Y1) [800] [50]\nadd line | type [0] (X0, Y0) [1000] [50] (X1, Y1) [1000] [400]\nadd line | type [0] (X0, Y0) [950] [100] (X1, Y1) [950] [600]\nadd line | type [3] (X0, Y0) [950] [600] (X1, Y1) [1200] [600]\nadd line | type [0] (X0, Y0) [1000] [400] (X1, Y1) [1600] [400]\nadd line | type [3] (X0, Y0) [1200] [400] (X1, Y1) [1300] [450]\nadd line | type [3] (X0, Y0) [1300] [450] (X1, Y1) [1400] [400]\nadd line | type [1] (X0, Y0) [1600] [400] (X1, Y1) [1800] [400]\nadd line | type [1] (X0, Y0) [1800] [400] (X1, Y1) [1800] [800]\nadd line | type [1] (X0, Y0) [1700] [500] (X1, Y1) [1700] [650]\nadd line | type [1] (X0, Y0) [1800] [900] (X1, Y1) [1800] [1000]\nadd line | type [1] (X0, Y0) [1700] [850] (X1, Y1) [1700] [1000]\nadd line | type [0] (X0, Y0) [1700] [750] (X1, Y1) [1700] [850]\nadd line | type [0] (X0, Y0) [1700] [650] (X1, Y1) [1700] [750]\nadd line | type [0] (X0, Y0) [1800] [800] (X1, Y1) [1800] [900]\nadd line | type [0] (X0, Y0) [1800] [1000] (X1, Y1) [2000] [1000]\nadd line | type [1] (X0, Y0) [1900] [1200] (X1, Y1) [1800] [1200]\nadd line | type [1] (X0, Y0) [2000] [1000] (X1, Y1) [2100] [1100]\nadd line | type [1] (X0, Y0) [1900] [1200] (X1, Y1) [1800] [1300]\nadd line | type [1] (X0, Y0) [1900] [1400] (X1, Y1) [2000] [1400]\nadd line | type [2] (X0, Y0) [2000] [1600] (X1, Y1) [2100] [1600]\n\ndefine physics (steps) <up> <left> <right>\nget physics platforms ((playerX) - (80)) ((playerX) + (80)) ((playerY) - (80)) ((playerY) + (80))\nset [death v] to [0]\nchange [walljump v] by (-1)\nrepeat (steps)\n    change [onground v] by ((-1) / (steps))\n    if <up> then\n        if <(onground) > [0]> then\n            set [vely v] to [22]\n            set [onground v] to [0]\n            set [slopemove v] to [0]\n        else\n            if <(walljump) > [0]> then\n                if <<(walldir) = [right]> and <left>> then\n                    set [vely v] to [15]\n                    set [velx v] to [-12]\n                else\n                    if <<(walldir) = [left]> and <right>> then\n                        set [vely v] to [15]\n                        set [velx v] to [12]\n                    end\n                end\n            end\n        end\n    end\n    if <left> then\n        change [velx v] by ((-3) / (steps))\n    end\n    if <right> then\n        change [velx v] by ((3) / (steps))\n    end\n    if <(slopemove) > [0]> then\n        set [vely v] to ((steps) * (slopemove))\n    else\n        change [vely v] by ((-1.5) / (steps))\n    end\n    if <(velY) > [65]> then\n        set [vely v] to [65]\n    else\n        if <(velY) < [-65]> then\n            set [vely v] to [-65]\n        end\n    end\n    move Y ((velY) / (steps)) (playerY) ((playerX) - (10)) ((playerX) + (10)) ((playerY) - (10)) ((playerY) + (10))\n    if <(death) = [1]> then\n        set [goal v] to [0]\n        stop [this script v]\n    end\n    if <(goal) = [1]> then\n        stop [this script v]\n    end\n    if <not <(slopemove) = [0]>> then\n        set [velx v] to ((steps) * (slopemove))\n    end\n    if <(velX) > [65]> then\n        set [velx v] to [65]\n    else\n        if <(velX) < [-65]> then\n            set [velx v] to [-65]\n        end\n    end\n    move X ((velX) / (steps)) (playerX) ((playerX) - (10)) ((playerX) + (10)) ((playerY) - (10)) ((playerY) + (10))\n    if <(death) = [1]> then\n        set [goal v] to [0]\n        stop [this script v]\n    end\n    if <(goal) = [1]> then\n        stop [this script v]\n    end\nend\nset [velx v] to ((0.8) * (velX))\nif <([abs v] of (velX) ) < [0.5]> then\n    set [velx v] to [0]\nend\nset [vely v] to ((0.96) * (velY))\nif <([abs v] of (velY) ) < [0.5]> then\n    set [vely v] to [0]\nend\n\ndefine draw\nget draw lines\npen up\nerase all\nset pen color to ((1) * (16777215))\nset pen size to (200)\ngo to x: (-250) y: (-90)\npen down\nset x to (250)\nset y to (90)\nset x to (-250)\nset y to (-90)\npen up\nset pen size to (6)\nset [_i0 v] to [0]\nrepeat (4)\n    set pen color to (item ((_i0) + (1)) of [colors v])\n    set [_i1 v] to [1]\n    repeat ((length of [drawlines v]) / (5))\n        if <(item (_i1) of [drawlines v]) = (_i0)> then\n            go to x: (item ((_i1) + (1)) of [drawlines v]) y: (item ((_i1) + (2)) of [drawlines v])\n            pen down\n            go to x: (item ((_i1) + (3)) of [drawlines v]) y: (item ((_i1) + (4)) of [drawlines v])\n            pen up\n        end\n        change [_i1 v] by (5)\n    end\n    change [_i0 v] by (1)\nend\ndraw player ((playerX) - (camX)) ((playerY) - (camY))\n\ndefine reset\nset [playerx v] to [0]\nset [playery v] to [0]\nset [velx v] to [0]\nset [vely v] to [0]\nset [camoffsetx v] to (camX)\nset [camoffsety v] to (camY)\nset [slopemove v] to [0]\nset [onground v] to [0]\nset [walljump v] to [0]\n\ndefine add line | type (type) (X0, Y0) (x0) (y0) (X1, Y1) (x1) (y1)\nadd (type) to [linetype v]\nadd (x0) to [linex0 v]\nadd (y0) to [liney0 v]\nadd (x1) to [linex1 v]\nadd (y1) to [liney1 v]\n\ndefine get draw lines\ndelete all of [drawlines v]\nset [_i0 v] to [1]\nrepeat (length of [linetype v])\n    add draw line (item (_i0) of [linetype v]) ((item (_i0) of [linex0 v]) - (camX)) ((item (_i0) of [liney0 v]) - (camY)) ((item (_i0) of [linex1 v]) - (camX)) ((item (_i0) of [liney1 v]) - (camY))\n    change [_i0 v] by (1)\nend\n\ndefine add draw line (type) (x0) (y0) (x1) (y1)\nif <(x0) < (x1)> then\n    set [_x0 v] to (x0)\n    set [_y0 v] to (y0)\n    set [_x1 v] to (x1)\n    set [_y1 v] to (y1)\nelse\n    set [_x0 v] to (x1)\n    set [_y0 v] to (y1)\n    set [_x1 v] to (x0)\n    set [_y1 v] to (y0)\nend\nif <<(_x1) < [-250]> or <(_x0) > [250]>> then\n    stop [this script v]\nend\nif <(_y0) < (_y1)> then\n    if <<(_y1) < [-190]> or <(_y0) > [190]>> then\n        stop [this script v]\n    end\nelse\n    if <<(_y0) < [-190]> or <(_y1) > [190]>> then\n        stop [this script v]\n    end\nend\nif <(_x0) < [-250]> then\n    set [_y0 v] to ((_y0) + (((_y1) - (_y0)) * (((-250) - (_x0)) / ((_x1) - (_x0)))))\n    set [_x0 v] to [-250]\nend\nif <(_y0) < [-190]> then\n    set [_x0 v] to ((_x0) + (((_x1) - (_x0)) * (((-190) - (_y0)) / ((_y1) - (_y0)))))\n    set [_y0 v] to [-190]\nelse\n    if <(_y0) > [190]> then\n        set [_x0 v] to ((_x0) + (((_x1) - (_x0)) * (((190) - (_y0)) / ((_y1) - (_y0)))))\n        set [_y0 v] to [190]\n    end\nend\nif <(_x0) < [-250]> then\n    stop [this script v]\nend\nif <(_x1) > [250]> then\n    set [_y1 v] to ((_y0) + (((_y1) - (_y0)) * (((250) - (_x0)) / ((_x1) - (_x0)))))\n    set [_x1 v] to [250]\nend\nif <(_y1) < [-190]> then\n    set [_x1 v] to ((_x0) + (((_x1) - (_x0)) * (((-190) - (_y0)) / ((_y1) - (_y0)))))\n    set [_y1 v] to [-190]\nelse\n    if <(_y1) > [190]> then\n        set [_x1 v] to ((_x0) + (((_x1) - (_x0)) * (((190) - (_y0)) / ((_y1) - (_y0)))))\n        set [_y1 v] to [190]\n    end\nend\nif <(_x1) > [250]> then\n    stop [this script v]\nend\nadd (type) to [drawlines v]\nadd (_x0) to [drawlines v]\nadd (_y0) to [drawlines v]\nadd (_x1) to [drawlines v]\nadd (_y1) to [drawlines v]\n\ndefine get colors\ndelete all of [colors v]\nadd ((((65536) * (0)) + ((256) * (0))) + (0)) to [colors v]\nadd ((((65536) * (255)) + ((256) * (63))) + (247)) to [colors v]\nadd ((((65536) * (63)) + ((256) * (247))) + (63)) to [colors v]\nadd ((((65536) * (255)) + ((256) * (95))) + (63)) to [colors v]\nadd ((((65536) * (0)) + ((256) * (127))) + (255)) to [colors v]\n\ndefine draw player (x) (y)\nset pen size to (4)\nset pen color to (item (5) of [colors v])\ngo to x: ((x) - (8)) y: ((y) - (8))\npen down\nchange x by (16)\nchange y by (16)\nchange x by (-16)\nchange y by (-16)\npen up\n\ndefine get physics platforms (xmin) (xmax) (ymin) (ymax)\ndelete all of [physicsplats v]\nset [_i0 v] to [1]\nrepeat (length of [linetype v])\n    set [_i1 v] to [1]\n    if <(item (_i0) of [linex0 v]) < (item (_i0) of [linex1 v])> then\n        if <<(item (_i0) of [linex1 v]) < (xmin)> or <(item (_i0) of [linex0 v]) > (xmax)>> then\n            set [_i1 v] to [0]\n        end\n    else\n        if <<(item (_i0) of [linex0 v]) < (xmin)> or <(item (_i0) of [linex1 v]) > (xmax)>> then\n            set [_i1 v] to [0]\n        end\n    end\n    if <(item (_i0) of [liney0 v]) < (item (_i0) of [liney1 v])> then\n        if <<(item (_i0) of [liney1 v]) < (ymin)> or <(item (_i0) of [liney0 v]) > (ymax)>> then\n            set [_i1 v] to [0]\n        end\n    else\n        if <<(item (_i0) of [liney0 v]) < (ymin)> or <(item (_i0) of [liney1 v]) > (ymax)>> then\n            set [_i1 v] to [0]\n        end\n    end\n    if <(_i1) = [1]> then\n        add (_i0) to [physicsplats v]\n    end\n    change [_i0 v] by (1)\nend\n\ndefine move Y (vel) (cy) (xmin) (xmax) (ymin) (ymax)\nset [slopemove v] to [0]\nif <(vel) = [0]> then\n    stop [this script v]\nend\nset [_highid v] to [none]\nset [_hightype v] to [-1]\nset [_lowid v] to [none]\nset [_lowtype v] to [-1]\nif <(vel) > [0]> then\n    set [_highpos v] to ((ymax) + (vel))\n    set [_lowpos v] to (cy)\nelse\n    set [_highpos v] to (cy)\n    set [_lowpos v] to ((ymin) + (vel))\nend\nset [_i0 v] to [1]\nrepeat (length of [physicsplats v])\n    set [_i1 v] to (item (_i0) of [physicsplats v])\n    set [_i2 v] to [1]\n    if <(item (_i1) of [linex0 v]) < (item (_i1) of [linex1 v])> then\n        if <not <<(item (_i1) of [linex1 v]) > (xmin)> and <(item (_i1) of [linex0 v]) < (xmax)>>> then\n            set [_i2 v] to [0]\n        end\n    else\n        if <not <<(item (_i1) of [linex0 v]) > (xmin)> and <(item (_i1) of [linex1 v]) < (xmax)>>> then\n            set [_i2 v] to [0]\n        end\n    end\n    if <(_i2) = [1]> then\n        platform collision (item (_i1) of [liney0 v]) (item (_i1) of [linex0 v]) (item (_i1) of [liney1 v]) (item (_i1) of [linex1 v]) (cy) (xmin) (xmax)\n    end\n    change [_i0 v] by (1)\nend\nif <(vel) > [0]> then\n    change [playery v] by ((_highPos) - (ymax))\n    set [_i0 v] to (_highType)\n    set [_i1 v] to (_highID)\nelse\n    change [playery v] by ((_lowPos) - (ymin))\n    set [_i0 v] to (_lowType)\n    set [_i1 v] to (_lowID)\nend\nif <(_i0) = [3]> then\n    set [death v] to [1]\nelse\n    if <(_i0) = [2]> then\n        set [goal v] to [1]\n    else\n        if <(_i0) = [1]> then\n            set [vely v] to ((-40) * ((velY) / ([abs v] of (velY) )))\n        else\n            if <(_i0) = [0]> then\n                if <(vel) < [0]> then\n                    set [_i2 v] to [0]\n                    if <(item (_i1) of [liney0 v]) < (item (_i1) of [liney1 v])> then\n                        if <(item (_i1) of [liney1 v]) > (ymin)> then\n                            set [_i2 v] to [1]\n                        end\n                    else\n                        if <(item (_i1) of [liney0 v]) > (ymin)> then\n                            set [_i2 v] to [1]\n                        end\n                    end\n                    if <(_i2) = [1]> then\n                        set [_i2 v] to (((item (_i1) of [linex1 v]) - (item (_i1) of [linex0 v])) / ((item (_i1) of [liney1 v]) - (item (_i1) of [liney0 v])))\n                        if <([abs v] of (_i2) ) < [1]> then\n                            set [slopemove v] to ((_i2) * (vel))\n                            set [onground v] to [0]\n                        end\n                    end\n                end\n                if <(slopemove) = [0]> then\n                    set [vely v] to [0]\n                    if <(vel) < [0]> then\n                        set [onground v] to [4]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine move X (vel) (cx) (xmin) (xmax) (ymin) (ymax)\nset [slopemove v] to [0]\nif <(vel) = [0]> then\n    stop [this script v]\nend\nset [_highid v] to [none]\nset [_hightype v] to [-1]\nset [_lowid v] to [none]\nset [_lowtype v] to [-1]\nif <(vel) > [0]> then\n    set [_highpos v] to ((xmax) + (vel))\n    set [_lowpos v] to (cx)\nelse\n    set [_highpos v] to (cx)\n    set [_lowpos v] to ((xmin) + (vel))\nend\nset [_i0 v] to [1]\nrepeat (length of [physicsplats v])\n    set [_i1 v] to (item (_i0) of [physicsplats v])\n    set [_i2 v] to [1]\n    if <(item (_i1) of [liney0 v]) < (item (_i1) of [liney1 v])> then\n        if <not <<(item (_i1) of [liney1 v]) > (ymin)> and <(item (_i1) of [liney0 v]) < (ymax)>>> then\n            set [_i2 v] to [0]\n        end\n    else\n        if <not <<(item (_i1) of [liney0 v]) > (ymin)> and <(item (_i1) of [liney1 v]) < (ymax)>>> then\n            set [_i2 v] to [0]\n        end\n    end\n    if <(_i2) = [1]> then\n        platform collision (item (_i1) of [linex0 v]) (item (_i1) of [liney0 v]) (item (_i1) of [linex1 v]) (item (_i1) of [liney1 v]) (cx) (ymin) (ymax)\n    end\n    change [_i0 v] by (1)\nend\nif <(vel) > [0]> then\n    change [playerx v] by ((_highPos) - (xmax))\n    set [_i0 v] to (_highType)\n    set [_i1 v] to (_highID)\nelse\n    change [playerx v] by ((_lowPos) - (xmin))\n    set [_i0 v] to (_lowType)\n    set [_i1 v] to (_lowID)\nend\nif <(_i0) = [3]> then\n    set [death v] to [1]\nelse\n    if <(_i0) = [2]> then\n        set [goal v] to [1]\n    else\n        if <(_i0) = [1]> then\n            set [velx v] to ((-40) * ((velX) / ([abs v] of (velX) )))\n        else\n            if <(_i0) = [0]> then\n                set [_i2 v] to (((item (_i1) of [liney1 v]) - (item (_i1) of [liney0 v])) / ((item (_i1) of [linex1 v]) - (item (_i1) of [linex0 v])))\n                if <<<(vel) > [0]> and <<(_i2) < [1]> and <(_i2) > [0]>>> or <<(vel) < [0]> and <<(_i2) > [-1]> and <(_i2) < [0]>>>> then\n                    set [slopemove v] to ([abs v] of ((_i2) * (vel)) )\n                    set [onground v] to [3]\n                end\n                if <(slopemove) = [0]> then\n                    set [velx v] to [0]\n                    if <(item (_i1) of [linex0 v]) = (item (_i1) of [linex1 v])> then\n                        if <(vel) > [0]> then\n                            set [walldir v] to [right]\n                        else\n                            set [walldir v] to [left]\n                        end\n                        set [walljump v] to [8]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine platform collision (x0) (y0) (x1) (y1) (cx) (ymin) (ymax)\nset [_i2 v] to (item (_i1) of [linetype v])\nif <(y0) < (ymin)> then\n    set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymin) - (y0)) / ((y1) - (y0)))))\nelse\n    if <(y0) > (ymax)> then\n        set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymax) - (y0)) / ((y1) - (y0)))))\n    else\n        set [_x0 v] to (x0)\n    end\nend\nif <(_x0) > (cx)> then\n    if <<(_x0) < (_highPos)> or <<(_i2) > (_highType)> and <(_x0) = (_highPos)>>> then\n        set [_highid v] to (_i1)\n        set [_hightype v] to (_i2)\n        set [_highpos v] to (_x0)\n    end\nelse\n    if <(_x0) < (cx)> then\n        if <<(_x0) > (_lowPos)> or <<(_i2) > (_lowType)> and <(_x0) = (_lowPos)>>> then\n            set [_lowid v] to (_i1)\n            set [_lowtype v] to (_i2)\n            set [_lowpos v] to (_x0)\n        end\n    end\nend\nif <(y1) < (ymin)> then\n    set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymin) - (y0)) / ((y1) - (y0)))))\nelse\n    if <(y1) > (ymax)> then\n        set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymax) - (y0)) / ((y1) - (y0)))))\n    else\n        set [_x0 v] to (x1)\n    end\nend\nif <(_x0) > (cx)> then\n    if <<(_x0) < (_highPos)> or <<(_i2) > (_highType)> and <(_x0) = (_highPos)>>> then\n        set [_highid v] to (_i1)\n        set [_hightype v] to (_i2)\n        set [_highpos v] to (_x0)\n    end\nelse\n    if <(_x0) < (cx)> then\n        if <<(_x0) > (_lowPos)> or <<(_i2) > (_lowType)> and <(_x0) = (_lowPos)>>> then\n            set [_lowid v] to (_i1)\n            set [_lowtype v] to (_i2)\n            set [_lowpos v] to (_x0)\n        end\n    end\nend\n\n@BEGINNING/END\n\nwhen I receive [winwinwinwin v]\nswitch costume to (costume2 v)\nshow\n\nwhen flag clicked\ngo to [front v] layer\ngo to x: (0) y: (0)\nswitch costume to (costume1 v)\nshow\nwait (1) seconds\nhide\n\nwhen I receive [next level v]\nswitch costume to (costume3 v)\nshow\nwait (2) seconds\nhide\n\n@Game 2\n\nwhen flag clicked\nset [start new game v] to [0]\nwait until <(start new game) = [1]>\nhide\ncreate level\nget colors\nset [goal v] to [0]\nrepeat until <(goal) = [1]>\n    physics [8] <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <key (space v) pressed?>>> <<key (left arrow v) pressed?> or <key (a v) pressed?>> <<key (right arrow v) pressed?> or <key (d v) pressed?>>\n    set [camoffsetx v] to (((0.8) * (camOffsetX)) + ((0.2) * ((-3) * (velX))))\n    set [camoffsety v] to (((0.8) * (camOffsetY)) + ((0.2) * ((-3) * (velY))))\n    set [camx v] to ((playerX) + (camOffsetX))\n    set [camy v] to ((playerY) + (camOffsetY))\n    draw\n    if <<(death) = [1]> or <(playerY) < [-500]>> then\n        reset\n    end\nend\nset [goal v] to [0]\nset [start new game v] to [2]\nbroadcast (Next Level v)\nstop [this script v]\n\ndefine create level\nset [playerx v] to [0]\nset [playery v] to [0]\nset [camoffsetx v] to [0]\nset [camoffsety v] to [0]\nset [slopemove v] to [0]\nset [onground v] to [0]\nset [walljump v] to [0]\ndelete all of [linetype v]\ndelete all of [linex0 v]\ndelete all of [linex1 v]\ndelete all of [liney0 v]\ndelete all of [liney1 v]\nadd line | type [0] (X0, Y0) [-100 ] [-50] (X1, Y1) [100] [-50]\nadd line | type [0] (X0, Y0) [200] [50] (X1, Y1) [300] [50]\nset [platform var x v] to [200]\nset [platform var y v] to [50]\nrepeat (10)\n    set [platform var x v] to ((platform var x) + (100))\n    set [platform var y v] to ((platform var y) + (100))\n    add line | type [0] (X0, Y0) (platform var x) (platform var y) (X1, Y1) ((platform var x) + (50)) (platform var y)\nend\nset [platform var x v] to [1200]\nset [platform var y v] to [1050]\nrepeat (10)\n    set [platform var x v] to ((platform var x) + (100))\n    set [platform var y v] to ((platform var y) - (100))\n    add line | type [0] (X0, Y0) (platform var x) (platform var y) (X1, Y1) ((platform var x) + (100)) (platform var y)\nend\nadd line | type [0] (X0, Y0) [2000] [-50] (X1, Y1) [2300] [-50]\nadd line | type [3] (X0, Y0) [2300] [-50] (X1, Y1) [2400] [-50]\nadd line | type [2] (X0, Y0) [2400] [-50] (X1, Y1) [2500] [-50]\n\ndefine physics (steps) <up> <left> <right>\nget physics platforms ((playerX) - (80)) ((playerX) + (80)) ((playerY) - (80)) ((playerY) + (80))\nset [death v] to [0]\nchange [walljump v] by (-1)\nrepeat (steps)\n    change [onground v] by ((-1) / (steps))\n    if <up> then\n        if <(onground) > [0]> then\n            set [vely v] to [22]\n            set [onground v] to [0]\n            set [slopemove v] to [0]\n        else\n            if <(walljump) > [0]> then\n                if <<(walldir) = [right]> and <left>> then\n                    set [vely v] to [15]\n                    set [velx v] to [-12]\n                else\n                    if <<(walldir) = [left]> and <right>> then\n                        set [vely v] to [15]\n                        set [velx v] to [12]\n                    end\n                end\n            end\n        end\n    end\n    if <left> then\n        change [velx v] by ((-3) / (steps))\n    end\n    if <right> then\n        change [velx v] by ((3) / (steps))\n    end\n    if <(slopemove) > [0]> then\n        set [vely v] to ((steps) * (slopemove))\n    else\n        change [vely v] by ((-1.5) / (steps))\n    end\n    if <(velY) > [65]> then\n        set [vely v] to [65]\n    else\n        if <(velY) < [-65]> then\n            set [vely v] to [-65]\n        end\n    end\n    move Y ((velY) / (steps)) (playerY) ((playerX) - (10)) ((playerX) + (10)) ((playerY) - (10)) ((playerY) + (10))\n    if <(death) = [1]> then\n        set [goal v] to [0]\n        stop [this script v]\n    end\n    if <(goal) = [1]> then\n        stop [this script v]\n    end\n    if <not <(slopemove) = [0]>> then\n        set [velx v] to ((steps) * (slopemove))\n    end\n    if <(velX) > [65]> then\n        set [velx v] to [65]\n    else\n        if <(velX) < [-65]> then\n            set [velx v] to [-65]\n        end\n    end\n    move X ((velX) / (steps)) (playerX) ((playerX) - (10)) ((playerX) + (10)) ((playerY) - (10)) ((playerY) + (10))\n    if <(death) = [1]> then\n        set [goal v] to [0]\n        stop [this script v]\n    end\n    if <(goal) = [1]> then\n        stop [this script v]\n    end\nend\nset [velx v] to ((0.8) * (velX))\nif <([abs v] of (velX) ) < [0.5]> then\n    set [velx v] to [0]\nend\nset [vely v] to ((0.96) * (velY))\nif <([abs v] of (velY) ) < [0.5]> then\n    set [vely v] to [0]\nend\n\ndefine draw\nget draw lines\npen up\nerase all\nset pen color to ((1) * (16777215))\nset pen size to (200)\ngo to x: (-250) y: (-90)\npen down\nset x to (250)\nset y to (90)\nset x to (-250)\nset y to (-90)\npen up\nset pen size to (6)\nset [_i0 v] to [0]\nrepeat (4)\n    set pen color to (item ((_i0) + (1)) of [colors v])\n    set [_i1 v] to [1]\n    repeat ((length of [drawlines v]) / (5))\n        if <(item (_i1) of [drawlines v]) = (_i0)> then\n            go to x: (item ((_i1) + (1)) of [drawlines v]) y: (item ((_i1) + (2)) of [drawlines v])\n            pen down\n            go to x: (item ((_i1) + (3)) of [drawlines v]) y: (item ((_i1) + (4)) of [drawlines v])\n            pen up\n        end\n        change [_i1 v] by (5)\n    end\n    change [_i0 v] by (1)\nend\ndraw player ((playerX) - (camX)) ((playerY) - (camY))\n\ndefine reset\nset [playerx v] to [0]\nset [playery v] to [0]\nset [velx v] to [0]\nset [vely v] to [0]\nset [camoffsetx v] to (camX)\nset [camoffsety v] to (camY)\nset [slopemove v] to [0]\nset [onground v] to [0]\nset [walljump v] to [0]\n\ndefine add line | type (type) (X0, Y0) (x0) (y0) (X1, Y1) (x1) (y1)\nadd (type) to [linetype v]\nadd (x0) to [linex0 v]\nadd (y0) to [liney0 v]\nadd (x1) to [linex1 v]\nadd (y1) to [liney1 v]\n\ndefine get draw lines\ndelete all of [drawlines v]\nset [_i0 v] to [1]\nrepeat (length of [linetype v])\n    add draw line (item (_i0) of [linetype v]) ((item (_i0) of [linex0 v]) - (camX)) ((item (_i0) of [liney0 v]) - (camY)) ((item (_i0) of [linex1 v]) - (camX)) ((item (_i0) of [liney1 v]) - (camY))\n    change [_i0 v] by (1)\nend\n\ndefine add draw line (type) (x0) (y0) (x1) (y1)\nif <(x0) < (x1)> then\n    set [_x0 v] to (x0)\n    set [_y0 v] to (y0)\n    set [_x1 v] to (x1)\n    set [_y1 v] to (y1)\nelse\n    set [_x0 v] to (x1)\n    set [_y0 v] to (y1)\n    set [_x1 v] to (x0)\n    set [_y1 v] to (y0)\nend\nif <<(_x1) < [-250]> or <(_x0) > [250]>> then\n    stop [this script v]\nend\nif <(_y0) < (_y1)> then\n    if <<(_y1) < [-190]> or <(_y0) > [190]>> then\n        stop [this script v]\n    end\nelse\n    if <<(_y0) < [-190]> or <(_y1) > [190]>> then\n        stop [this script v]\n    end\nend\nif <(_x0) < [-250]> then\n    set [_y0 v] to ((_y0) + (((_y1) - (_y0)) * (((-250) - (_x0)) / ((_x1) - (_x0)))))\n    set [_x0 v] to [-250]\nend\nif <(_y0) < [-190]> then\n    set [_x0 v] to ((_x0) + (((_x1) - (_x0)) * (((-190) - (_y0)) / ((_y1) - (_y0)))))\n    set [_y0 v] to [-190]\nelse\n    if <(_y0) > [190]> then\n        set [_x0 v] to ((_x0) + (((_x1) - (_x0)) * (((190) - (_y0)) / ((_y1) - (_y0)))))\n        set [_y0 v] to [190]\n    end\nend\nif <(_x0) < [-250]> then\n    stop [this script v]\nend\nif <(_x1) > [250]> then\n    set [_y1 v] to ((_y0) + (((_y1) - (_y0)) * (((250) - (_x0)) / ((_x1) - (_x0)))))\n    set [_x1 v] to [250]\nend\nif <(_y1) < [-190]> then\n    set [_x1 v] to ((_x0) + (((_x1) - (_x0)) * (((-190) - (_y0)) / ((_y1) - (_y0)))))\n    set [_y1 v] to [-190]\nelse\n    if <(_y1) > [190]> then\n        set [_x1 v] to ((_x0) + (((_x1) - (_x0)) * (((190) - (_y0)) / ((_y1) - (_y0)))))\n        set [_y1 v] to [190]\n    end\nend\nif <(_x1) > [250]> then\n    stop [this script v]\nend\nadd (type) to [drawlines v]\nadd (_x0) to [drawlines v]\nadd (_y0) to [drawlines v]\nadd (_x1) to [drawlines v]\nadd (_y1) to [drawlines v]\n\ndefine get colors\ndelete all of [colors v]\nadd ((((65536) * (0)) + ((256) * (0))) + (0)) to [colors v]\nadd ((((65536) * (255)) + ((256) * (63))) + (247)) to [colors v]\nadd ((((65536) * (63)) + ((256) * (247))) + (63)) to [colors v]\nadd ((((65536) * (255)) + ((256) * (95))) + (63)) to [colors v]\nadd ((((65536) * (0)) + ((256) * (127))) + (255)) to [colors v]\n\ndefine draw player (x) (y)\nset pen size to (4)\nset pen color to (item (5) of [colors v])\ngo to x: ((x) - (8)) y: ((y) - (8))\npen down\nchange x by (16)\nchange y by (16)\nchange x by (-16)\nchange y by (-16)\npen up\n\ndefine get physics platforms (xmin) (xmax) (ymin) (ymax)\ndelete all of [physicsplats v]\nset [_i0 v] to [1]\nrepeat (length of [linetype v])\n    set [_i1 v] to [1]\n    if <(item (_i0) of [linex0 v]) < (item (_i0) of [linex1 v])> then\n        if <<(item (_i0) of [linex1 v]) < (xmin)> or <(item (_i0) of [linex0 v]) > (xmax)>> then\n            set [_i1 v] to [0]\n        end\n    else\n        if <<(item (_i0) of [linex0 v]) < (xmin)> or <(item (_i0) of [linex1 v]) > (xmax)>> then\n            set [_i1 v] to [0]\n        end\n    end\n    if <(item (_i0) of [liney0 v]) < (item (_i0) of [liney1 v])> then\n        if <<(item (_i0) of [liney1 v]) < (ymin)> or <(item (_i0) of [liney0 v]) > (ymax)>> then\n            set [_i1 v] to [0]\n        end\n    else\n        if <<(item (_i0) of [liney0 v]) < (ymin)> or <(item (_i0) of [liney1 v]) > (ymax)>> then\n            set [_i1 v] to [0]\n        end\n    end\n    if <(_i1) = [1]> then\n        add (_i0) to [physicsplats v]\n    end\n    change [_i0 v] by (1)\nend\n\ndefine move Y (vel) (cy) (xmin) (xmax) (ymin) (ymax)\nset [slopemove v] to [0]\nif <(vel) = [0]> then\n    stop [this script v]\nend\nset [_highid v] to [none]\nset [_hightype v] to [-1]\nset [_lowid v] to [none]\nset [_lowtype v] to [-1]\nif <(vel) > [0]> then\n    set [_highpos v] to ((ymax) + (vel))\n    set [_lowpos v] to (cy)\nelse\n    set [_highpos v] to (cy)\n    set [_lowpos v] to ((ymin) + (vel))\nend\nset [_i0 v] to [1]\nrepeat (length of [physicsplats v])\n    set [_i1 v] to (item (_i0) of [physicsplats v])\n    set [_i2 v] to [1]\n    if <(item (_i1) of [linex0 v]) < (item (_i1) of [linex1 v])> then\n        if <not <<(item (_i1) of [linex1 v]) > (xmin)> and <(item (_i1) of [linex0 v]) < (xmax)>>> then\n            set [_i2 v] to [0]\n        end\n    else\n        if <not <<(item (_i1) of [linex0 v]) > (xmin)> and <(item (_i1) of [linex1 v]) < (xmax)>>> then\n            set [_i2 v] to [0]\n        end\n    end\n    if <(_i2) = [1]> then\n        platform collision (item (_i1) of [liney0 v]) (item (_i1) of [linex0 v]) (item (_i1) of [liney1 v]) (item (_i1) of [linex1 v]) (cy) (xmin) (xmax)\n    end\n    change [_i0 v] by (1)\nend\nif <(vel) > [0]> then\n    change [playery v] by ((_highPos) - (ymax))\n    set [_i0 v] to (_highType)\n    set [_i1 v] to (_highID)\nelse\n    change [playery v] by ((_lowPos) - (ymin))\n    set [_i0 v] to (_lowType)\n    set [_i1 v] to (_lowID)\nend\nif <(_i0) = [3]> then\n    set [death v] to [1]\nelse\n    if <(_i0) = [2]> then\n        set [goal v] to [1]\n    else\n        if <(_i0) = [1]> then\n            set [vely v] to ((-40) * ((velY) / ([abs v] of (velY) )))\n        else\n            if <(_i0) = [0]> then\n                if <(vel) < [0]> then\n                    set [_i2 v] to [0]\n                    if <(item (_i1) of [liney0 v]) < (item (_i1) of [liney1 v])> then\n                        if <(item (_i1) of [liney1 v]) > (ymin)> then\n                            set [_i2 v] to [1]\n                        end\n                    else\n                        if <(item (_i1) of [liney0 v]) > (ymin)> then\n                            set [_i2 v] to [1]\n                        end\n                    end\n                    if <(_i2) = [1]> then\n                        set [_i2 v] to (((item (_i1) of [linex1 v]) - (item (_i1) of [linex0 v])) / ((item (_i1) of [liney1 v]) - (item (_i1) of [liney0 v])))\n                        if <([abs v] of (_i2) ) < [1]> then\n                            set [slopemove v] to ((_i2) * (vel))\n                            set [onground v] to [0]\n                        end\n                    end\n                end\n                if <(slopemove) = [0]> then\n                    set [vely v] to [0]\n                    if <(vel) < [0]> then\n                        set [onground v] to [4]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine move X (vel) (cx) (xmin) (xmax) (ymin) (ymax)\nset [slopemove v] to [0]\nif <(vel) = [0]> then\n    stop [this script v]\nend\nset [_highid v] to [none]\nset [_hightype v] to [-1]\nset [_lowid v] to [none]\nset [_lowtype v] to [-1]\nif <(vel) > [0]> then\n    set [_highpos v] to ((xmax) + (vel))\n    set [_lowpos v] to (cx)\nelse\n    set [_highpos v] to (cx)\n    set [_lowpos v] to ((xmin) + (vel))\nend\nset [_i0 v] to [1]\nrepeat (length of [physicsplats v])\n    set [_i1 v] to (item (_i0) of [physicsplats v])\n    set [_i2 v] to [1]\n    if <(item (_i1) of [liney0 v]) < (item (_i1) of [liney1 v])> then\n        if <not <<(item (_i1) of [liney1 v]) > (ymin)> and <(item (_i1) of [liney0 v]) < (ymax)>>> then\n            set [_i2 v] to [0]\n        end\n    else\n        if <not <<(item (_i1) of [liney0 v]) > (ymin)> and <(item (_i1) of [liney1 v]) < (ymax)>>> then\n            set [_i2 v] to [0]\n        end\n    end\n    if <(_i2) = [1]> then\n        platform collision (item (_i1) of [linex0 v]) (item (_i1) of [liney0 v]) (item (_i1) of [linex1 v]) (item (_i1) of [liney1 v]) (cx) (ymin) (ymax)\n    end\n    change [_i0 v] by (1)\nend\nif <(vel) > [0]> then\n    change [playerx v] by ((_highPos) - (xmax))\n    set [_i0 v] to (_highType)\n    set [_i1 v] to (_highID)\nelse\n    change [playerx v] by ((_lowPos) - (xmin))\n    set [_i0 v] to (_lowType)\n    set [_i1 v] to (_lowID)\nend\nif <(_i0) = [3]> then\n    set [death v] to [1]\nelse\n    if <(_i0) = [2]> then\n        set [goal v] to [1]\n    else\n        if <(_i0) = [1]> then\n            set [velx v] to ((-40) * ((velX) / ([abs v] of (velX) )))\n        else\n            if <(_i0) = [0]> then\n                set [_i2 v] to (((item (_i1) of [liney1 v]) - (item (_i1) of [liney0 v])) / ((item (_i1) of [linex1 v]) - (item (_i1) of [linex0 v])))\n                if <<<(vel) > [0]> and <<(_i2) < [1]> and <(_i2) > [0]>>> or <<(vel) < [0]> and <<(_i2) > [-1]> and <(_i2) < [0]>>>> then\n                    set [slopemove v] to ([abs v] of ((_i2) * (vel)) )\n                    set [onground v] to [3]\n                end\n                if <(slopemove) = [0]> then\n                    set [velx v] to [0]\n                    if <(item (_i1) of [linex0 v]) = (item (_i1) of [linex1 v])> then\n                        if <(vel) > [0]> then\n                            set [walldir v] to [right]\n                        else\n                            set [walldir v] to [left]\n                        end\n                        set [walljump v] to [8]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine platform collision (x0) (y0) (x1) (y1) (cx) (ymin) (ymax)\nset [_i2 v] to (item (_i1) of [linetype v])\nif <(y0) < (ymin)> then\n    set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymin) - (y0)) / ((y1) - (y0)))))\nelse\n    if <(y0) > (ymax)> then\n        set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymax) - (y0)) / ((y1) - (y0)))))\n    else\n        set [_x0 v] to (x0)\n    end\nend\nif <(_x0) > (cx)> then\n    if <<(_x0) < (_highPos)> or <<(_i2) > (_highType)> and <(_x0) = (_highPos)>>> then\n        set [_highid v] to (_i1)\n        set [_hightype v] to (_i2)\n        set [_highpos v] to (_x0)\n    end\nelse\n    if <(_x0) < (cx)> then\n        if <<(_x0) > (_lowPos)> or <<(_i2) > (_lowType)> and <(_x0) = (_lowPos)>>> then\n            set [_lowid v] to (_i1)\n            set [_lowtype v] to (_i2)\n            set [_lowpos v] to (_x0)\n        end\n    end\nend\nif <(y1) < (ymin)> then\n    set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymin) - (y0)) / ((y1) - (y0)))))\nelse\n    if <(y1) > (ymax)> then\n        set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymax) - (y0)) / ((y1) - (y0)))))\n    else\n        set [_x0 v] to (x1)\n    end\nend\nif <(_x0) > (cx)> then\n    if <<(_x0) < (_highPos)> or <<(_i2) > (_highType)> and <(_x0) = (_highPos)>>> then\n        set [_highid v] to (_i1)\n        set [_hightype v] to (_i2)\n        set [_highpos v] to (_x0)\n    end\nelse\n    if <(_x0) < (cx)> then\n        if <<(_x0) > (_lowPos)> or <<(_i2) > (_lowType)> and <(_x0) = (_lowPos)>>> then\n            set [_lowid v] to (_i1)\n            set [_lowtype v] to (_i2)\n            set [_lowpos v] to (_x0)\n        end\n    end\nend\n\n@Game 3\n\nset [platform var x v] to [0]\n\nwhen flag clicked\nset [start new game v] to [0]\nwait until <(start new game) = [2]>\nhide\ncreate level\nget colors\nset [goal v] to [0]\nrepeat until <(goal) = [1]>\n    physics [8] <<key (up arrow v) pressed?> or <<key (w v) pressed?> or <key (space v) pressed?>>> <<key (left arrow v) pressed?> or <key (a v) pressed?>> <<key (right arrow v) pressed?> or <key (d v) pressed?>>\n    set [camoffsetx v] to (((0.8) * (camOffsetX)) + ((0.2) * ((-3) * (velX))))\n    set [camoffsety v] to (((0.8) * (camOffsetY)) + ((0.2) * ((-3) * (velY))))\n    set [camx v] to ((playerX) + (camOffsetX))\n    set [camy v] to ((playerY) + (camOffsetY))\n    draw\n    if <<(death) = [1]> or <(playerY) < [-500]>> then\n        reset\n    end\nend\nset [goal v] to [0]\nset [start new game v] to [3]\nbroadcast (WINWINWINWIN v)\nstop [this script v]\n\ndefine create level\nset [playerx v] to [0]\nset [playery v] to [0]\nset [camoffsetx v] to [0]\nset [camoffsety v] to [0]\nset [slopemove v] to [0]\nset [onground v] to [0]\nset [walljump v] to [0]\ndelete all of [linetype v]\ndelete all of [linex0 v]\ndelete all of [linex1 v]\ndelete all of [liney0 v]\ndelete all of [liney1 v]\nadd line | type [0] (X0, Y0) [-100] [-50] (X1, Y1) [100] [-50]\nadd line | type [0] (X0, Y0) [100] [-50] (X1, Y1) [100] [550]\nadd line | type [0] (X0, Y0) [-100] [-50] (X1, Y1) [-100] [550]\nadd line | type [0] (X0, Y0) [100] [550] (X1, Y1) [500] [550]\nadd line | type [0] (X0, Y0) [550] [0] (X1, Y1) [550] [600]\nadd line | type [0] (X0, Y0) [550] [-50] (X1, Y1) [750] [-50]\nadd line | type [1] (X0, Y0) [550] [600] (X1, Y1) [850] [600]\nadd line | type [3] (X0, Y0) [350] [900] (X1, Y1) [850] [900]\nadd line | type [0] (X0, Y0) [750] [0] (X1, Y1) [1500] [0]\nset [platform var x v] to [850]\nrepeat (5)\n    add line | type [3] (X0, Y0) (platform var x) [0] (X1, Y1) (platform var x) [100]\n    change [platform var x v] by (100)\nend\nchange [platform var x v] by (-50)\nadd line | type [3] (X0, Y0) (platform var x) [0] (X1, Y1) (platform var x) [100]\nadd line | type [2] (X0, Y0) [1500] [0] (X1, Y1) [1600] [100]\n\ndefine physics (steps) <up> <left> <right>\nget physics platforms ((playerX) - (80)) ((playerX) + (80)) ((playerY) - (80)) ((playerY) + (80))\nset [death v] to [0]\nchange [walljump v] by (-1)\nrepeat (steps)\n    change [onground v] by ((-1) / (steps))\n    if <up> then\n        if <(onground) > [0]> then\n            set [vely v] to [22]\n            set [onground v] to [0]\n            set [slopemove v] to [0]\n        else\n            if <(walljump) > [0]> then\n                if <<(walldir) = [right]> and <left>> then\n                    set [vely v] to [15]\n                    set [velx v] to [-12]\n                else\n                    if <<(walldir) = [left]> and <right>> then\n                        set [vely v] to [15]\n                        set [velx v] to [12]\n                    end\n                end\n            end\n        end\n    end\n    if <left> then\n        change [velx v] by ((-3) / (steps))\n    end\n    if <right> then\n        change [velx v] by ((3) / (steps))\n    end\n    if <(slopemove) > [0]> then\n        set [vely v] to ((steps) * (slopemove))\n    else\n        change [vely v] by ((-1.5) / (steps))\n    end\n    if <(velY) > [65]> then\n        set [vely v] to [65]\n    else\n        if <(velY) < [-65]> then\n            set [vely v] to [-65]\n        end\n    end\n    move Y ((velY) / (steps)) (playerY) ((playerX) - (10)) ((playerX) + (10)) ((playerY) - (10)) ((playerY) + (10))\n    if <(death) = [1]> then\n        set [goal v] to [0]\n        stop [this script v]\n    end\n    if <(goal) = [1]> then\n        stop [this script v]\n    end\n    if <not <(slopemove) = [0]>> then\n        set [velx v] to ((steps) * (slopemove))\n    end\n    if <(velX) > [65]> then\n        set [velx v] to [65]\n    else\n        if <(velX) < [-65]> then\n            set [velx v] to [-65]\n        end\n    end\n    move X ((velX) / (steps)) (playerX) ((playerX) - (10)) ((playerX) + (10)) ((playerY) - (10)) ((playerY) + (10))\n    if <(death) = [1]> then\n        set [goal v] to [0]\n        stop [this script v]\n    end\n    if <(goal) = [1]> then\n        stop [this script v]\n    end\nend\nset [velx v] to ((0.8) * (velX))\nif <([abs v] of (velX) ) < [0.5]> then\n    set [velx v] to [0]\nend\nset [vely v] to ((0.96) * (velY))\nif <([abs v] of (velY) ) < [0.5]> then\n    set [vely v] to [0]\nend\n\ndefine draw\nget draw lines\npen up\nerase all\nset pen color to ((1) * (16777215))\nset pen size to (200)\ngo to x: (-250) y: (-90)\npen down\nset x to (250)\nset y to (90)\nset x to (-250)\nset y to (-90)\npen up\nset pen size to (6)\nset [_i0 v] to [0]\nrepeat (4)\n    set pen color to (item ((_i0) + (1)) of [colors v])\n    set [_i1 v] to [1]\n    repeat ((length of [drawlines v]) / (5))\n        if <(item (_i1) of [drawlines v]) = (_i0)> then\n            go to x: (item ((_i1) + (1)) of [drawlines v]) y: (item ((_i1) + (2)) of [drawlines v])\n            pen down\n            go to x: (item ((_i1) + (3)) of [drawlines v]) y: (item ((_i1) + (4)) of [drawlines v])\n            pen up\n        end\n        change [_i1 v] by (5)\n    end\n    change [_i0 v] by (1)\nend\ndraw player ((playerX) - (camX)) ((playerY) - (camY))\n\ndefine reset\nset [playerx v] to [0]\nset [playery v] to [0]\nset [velx v] to [0]\nset [vely v] to [0]\nset [camoffsetx v] to (camX)\nset [camoffsety v] to (camY)\nset [slopemove v] to [0]\nset [onground v] to [0]\nset [walljump v] to [0]\n\ndefine add line | type (type) (X0, Y0) (x0) (y0) (X1, Y1) (x1) (y1)\nadd (type) to [linetype v]\nadd (x0) to [linex0 v]\nadd (y0) to [liney0 v]\nadd (x1) to [linex1 v]\nadd (y1) to [liney1 v]\n\ndefine get draw lines\ndelete all of [drawlines v]\nset [_i0 v] to [1]\nrepeat (length of [linetype v])\n    add draw line (item (_i0) of [linetype v]) ((item (_i0) of [linex0 v]) - (camX)) ((item (_i0) of [liney0 v]) - (camY)) ((item (_i0) of [linex1 v]) - (camX)) ((item (_i0) of [liney1 v]) - (camY))\n    change [_i0 v] by (1)\nend\n\ndefine add draw line (type) (x0) (y0) (x1) (y1)\nif <(x0) < (x1)> then\n    set [_x0 v] to (x0)\n    set [_y0 v] to (y0)\n    set [_x1 v] to (x1)\n    set [_y1 v] to (y1)\nelse\n    set [_x0 v] to (x1)\n    set [_y0 v] to (y1)\n    set [_x1 v] to (x0)\n    set [_y1 v] to (y0)\nend\nif <<(_x1) < [-250]> or <(_x0) > [250]>> then\n    stop [this script v]\nend\nif <(_y0) < (_y1)> then\n    if <<(_y1) < [-190]> or <(_y0) > [190]>> then\n        stop [this script v]\n    end\nelse\n    if <<(_y0) < [-190]> or <(_y1) > [190]>> then\n        stop [this script v]\n    end\nend\nif <(_x0) < [-250]> then\n    set [_y0 v] to ((_y0) + (((_y1) - (_y0)) * (((-250) - (_x0)) / ((_x1) - (_x0)))))\n    set [_x0 v] to [-250]\nend\nif <(_y0) < [-190]> then\n    set [_x0 v] to ((_x0) + (((_x1) - (_x0)) * (((-190) - (_y0)) / ((_y1) - (_y0)))))\n    set [_y0 v] to [-190]\nelse\n    if <(_y0) > [190]> then\n        set [_x0 v] to ((_x0) + (((_x1) - (_x0)) * (((190) - (_y0)) / ((_y1) - (_y0)))))\n        set [_y0 v] to [190]\n    end\nend\nif <(_x0) < [-250]> then\n    stop [this script v]\nend\nif <(_x1) > [250]> then\n    set [_y1 v] to ((_y0) + (((_y1) - (_y0)) * (((250) - (_x0)) / ((_x1) - (_x0)))))\n    set [_x1 v] to [250]\nend\nif <(_y1) < [-190]> then\n    set [_x1 v] to ((_x0) + (((_x1) - (_x0)) * (((-190) - (_y0)) / ((_y1) - (_y0)))))\n    set [_y1 v] to [-190]\nelse\n    if <(_y1) > [190]> then\n        set [_x1 v] to ((_x0) + (((_x1) - (_x0)) * (((190) - (_y0)) / ((_y1) - (_y0)))))\n        set [_y1 v] to [190]\n    end\nend\nif <(_x1) > [250]> then\n    stop [this script v]\nend\nadd (type) to [drawlines v]\nadd (_x0) to [drawlines v]\nadd (_y0) to [drawlines v]\nadd (_x1) to [drawlines v]\nadd (_y1) to [drawlines v]\n\ndefine get colors\ndelete all of [colors v]\nadd ((((65536) * (0)) + ((256) * (0))) + (0)) to [colors v]\nadd ((((65536) * (255)) + ((256) * (63))) + (247)) to [colors v]\nadd ((((65536) * (63)) + ((256) * (247))) + (63)) to [colors v]\nadd ((((65536) * (255)) + ((256) * (95))) + (63)) to [colors v]\nadd ((((65536) * (0)) + ((256) * (127))) + (255)) to [colors v]\n\ndefine draw player (x) (y)\nset pen size to (4)\nset pen color to (item (5) of [colors v])\ngo to x: ((x) - (8)) y: ((y) - (8))\npen down\nchange x by (16)\nchange y by (16)\nchange x by (-16)\nchange y by (-16)\npen up\n\ndefine get physics platforms (xmin) (xmax) (ymin) (ymax)\ndelete all of [physicsplats v]\nset [_i0 v] to [1]\nrepeat (length of [linetype v])\n    set [_i1 v] to [1]\n    if <(item (_i0) of [linex0 v]) < (item (_i0) of [linex1 v])> then\n        if <<(item (_i0) of [linex1 v]) < (xmin)> or <(item (_i0) of [linex0 v]) > (xmax)>> then\n            set [_i1 v] to [0]\n        end\n    else\n        if <<(item (_i0) of [linex0 v]) < (xmin)> or <(item (_i0) of [linex1 v]) > (xmax)>> then\n            set [_i1 v] to [0]\n        end\n    end\n    if <(item (_i0) of [liney0 v]) < (item (_i0) of [liney1 v])> then\n        if <<(item (_i0) of [liney1 v]) < (ymin)> or <(item (_i0) of [liney0 v]) > (ymax)>> then\n            set [_i1 v] to [0]\n        end\n    else\n        if <<(item (_i0) of [liney0 v]) < (ymin)> or <(item (_i0) of [liney1 v]) > (ymax)>> then\n            set [_i1 v] to [0]\n        end\n    end\n    if <(_i1) = [1]> then\n        add (_i0) to [physicsplats v]\n    end\n    change [_i0 v] by (1)\nend\n\ndefine move Y (vel) (cy) (xmin) (xmax) (ymin) (ymax)\nset [slopemove v] to [0]\nif <(vel) = [0]> then\n    stop [this script v]\nend\nset [_highid v] to [none]\nset [_hightype v] to [-1]\nset [_lowid v] to [none]\nset [_lowtype v] to [-1]\nif <(vel) > [0]> then\n    set [_highpos v] to ((ymax) + (vel))\n    set [_lowpos v] to (cy)\nelse\n    set [_highpos v] to (cy)\n    set [_lowpos v] to ((ymin) + (vel))\nend\nset [_i0 v] to [1]\nrepeat (length of [physicsplats v])\n    set [_i1 v] to (item (_i0) of [physicsplats v])\n    set [_i2 v] to [1]\n    if <(item (_i1) of [linex0 v]) < (item (_i1) of [linex1 v])> then\n        if <not <<(item (_i1) of [linex1 v]) > (xmin)> and <(item (_i1) of [linex0 v]) < (xmax)>>> then\n            set [_i2 v] to [0]\n        end\n    else\n        if <not <<(item (_i1) of [linex0 v]) > (xmin)> and <(item (_i1) of [linex1 v]) < (xmax)>>> then\n            set [_i2 v] to [0]\n        end\n    end\n    if <(_i2) = [1]> then\n        platform collision (item (_i1) of [liney0 v]) (item (_i1) of [linex0 v]) (item (_i1) of [liney1 v]) (item (_i1) of [linex1 v]) (cy) (xmin) (xmax)\n    end\n    change [_i0 v] by (1)\nend\nif <(vel) > [0]> then\n    change [playery v] by ((_highPos) - (ymax))\n    set [_i0 v] to (_highType)\n    set [_i1 v] to (_highID)\nelse\n    change [playery v] by ((_lowPos) - (ymin))\n    set [_i0 v] to (_lowType)\n    set [_i1 v] to (_lowID)\nend\nif <(_i0) = [3]> then\n    set [death v] to [1]\nelse\n    if <(_i0) = [2]> then\n        set [goal v] to [1]\n    else\n        if <(_i0) = [1]> then\n            set [vely v] to ((-40) * ((velY) / ([abs v] of (velY) )))\n        else\n            if <(_i0) = [0]> then\n                if <(vel) < [0]> then\n                    set [_i2 v] to [0]\n                    if <(item (_i1) of [liney0 v]) < (item (_i1) of [liney1 v])> then\n                        if <(item (_i1) of [liney1 v]) > (ymin)> then\n                            set [_i2 v] to [1]\n                        end\n                    else\n                        if <(item (_i1) of [liney0 v]) > (ymin)> then\n                            set [_i2 v] to [1]\n                        end\n                    end\n                    if <(_i2) = [1]> then\n                        set [_i2 v] to (((item (_i1) of [linex1 v]) - (item (_i1) of [linex0 v])) / ((item (_i1) of [liney1 v]) - (item (_i1) of [liney0 v])))\n                        if <([abs v] of (_i2) ) < [1]> then\n                            set [slopemove v] to ((_i2) * (vel))\n                            set [onground v] to [0]\n                        end\n                    end\n                end\n                if <(slopemove) = [0]> then\n                    set [vely v] to [0]\n                    if <(vel) < [0]> then\n                        set [onground v] to [4]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine move X (vel) (cx) (xmin) (xmax) (ymin) (ymax)\nset [slopemove v] to [0]\nif <(vel) = [0]> then\n    stop [this script v]\nend\nset [_highid v] to [none]\nset [_hightype v] to [-1]\nset [_lowid v] to [none]\nset [_lowtype v] to [-1]\nif <(vel) > [0]> then\n    set [_highpos v] to ((xmax) + (vel))\n    set [_lowpos v] to (cx)\nelse\n    set [_highpos v] to (cx)\n    set [_lowpos v] to ((xmin) + (vel))\nend\nset [_i0 v] to [1]\nrepeat (length of [physicsplats v])\n    set [_i1 v] to (item (_i0) of [physicsplats v])\n    set [_i2 v] to [1]\n    if <(item (_i1) of [liney0 v]) < (item (_i1) of [liney1 v])> then\n        if <not <<(item (_i1) of [liney1 v]) > (ymin)> and <(item (_i1) of [liney0 v]) < (ymax)>>> then\n            set [_i2 v] to [0]\n        end\n    else\n        if <not <<(item (_i1) of [liney0 v]) > (ymin)> and <(item (_i1) of [liney1 v]) < (ymax)>>> then\n            set [_i2 v] to [0]\n        end\n    end\n    if <(_i2) = [1]> then\n        platform collision (item (_i1) of [linex0 v]) (item (_i1) of [liney0 v]) (item (_i1) of [linex1 v]) (item (_i1) of [liney1 v]) (cx) (ymin) (ymax)\n    end\n    change [_i0 v] by (1)\nend\nif <(vel) > [0]> then\n    change [playerx v] by ((_highPos) - (xmax))\n    set [_i0 v] to (_highType)\n    set [_i1 v] to (_highID)\nelse\n    change [playerx v] by ((_lowPos) - (xmin))\n    set [_i0 v] to (_lowType)\n    set [_i1 v] to (_lowID)\nend\nif <(_i0) = [3]> then\n    set [death v] to [1]\nelse\n    if <(_i0) = [2]> then\n        set [goal v] to [1]\n    else\n        if <(_i0) = [1]> then\n            set [velx v] to ((-40) * ((velX) / ([abs v] of (velX) )))\n        else\n            if <(_i0) = [0]> then\n                set [_i2 v] to (((item (_i1) of [liney1 v]) - (item (_i1) of [liney0 v])) / ((item (_i1) of [linex1 v]) - (item (_i1) of [linex0 v])))\n                if <<<(vel) > [0]> and <<(_i2) < [1]> and <(_i2) > [0]>>> or <<(vel) < [0]> and <<(_i2) > [-1]> and <(_i2) < [0]>>>> then\n                    set [slopemove v] to ([abs v] of ((_i2) * (vel)) )\n                    set [onground v] to [3]\n                end\n                if <(slopemove) = [0]> then\n                    set [velx v] to [0]\n                    if <(item (_i1) of [linex0 v]) = (item (_i1) of [linex1 v])> then\n                        if <(vel) > [0]> then\n                            set [walldir v] to [right]\n                        else\n                            set [walldir v] to [left]\n                        end\n                        set [walljump v] to [8]\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine platform collision (x0) (y0) (x1) (y1) (cx) (ymin) (ymax)\nset [_i2 v] to (item (_i1) of [linetype v])\nif <(y0) < (ymin)> then\n    set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymin) - (y0)) / ((y1) - (y0)))))\nelse\n    if <(y0) > (ymax)> then\n        set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymax) - (y0)) / ((y1) - (y0)))))\n    else\n        set [_x0 v] to (x0)\n    end\nend\nif <(_x0) > (cx)> then\n    if <<(_x0) < (_highPos)> or <<(_i2) > (_highType)> and <(_x0) = (_highPos)>>> then\n        set [_highid v] to (_i1)\n        set [_hightype v] to (_i2)\n        set [_highpos v] to (_x0)\n    end\nelse\n    if <(_x0) < (cx)> then\n        if <<(_x0) > (_lowPos)> or <<(_i2) > (_lowType)> and <(_x0) = (_lowPos)>>> then\n            set [_lowid v] to (_i1)\n            set [_lowtype v] to (_i2)\n            set [_lowpos v] to (_x0)\n        end\n    end\nend\nif <(y1) < (ymin)> then\n    set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymin) - (y0)) / ((y1) - (y0)))))\nelse\n    if <(y1) > (ymax)> then\n        set [_x0 v] to ((x0) + (((x1) - (x0)) * (((ymax) - (y0)) / ((y1) - (y0)))))\n    else\n        set [_x0 v] to (x1)\n    end\nend\nif <(_x0) > (cx)> then\n    if <<(_x0) < (_highPos)> or <<(_i2) > (_highType)> and <(_x0) = (_highPos)>>> then\n        set [_highid v] to (_i1)\n        set [_hightype v] to (_i2)\n        set [_highpos v] to (_x0)\n    end\nelse\n    if <(_x0) < (cx)> then\n        if <<(_x0) > (_lowPos)> or <<(_i2) > (_lowType)> and <(_x0) = (_lowPos)>>> then\n            set [_lowid v] to (_i1)\n            set [_lowtype v] to (_i2)\n            set [_lowpos v] to (_x0)\n        end\n    end\nend\n\n