Old 3D Platformer Engine (easy) 


@Stage\n\n@Sprite1\n\ndefine goto (x) (y) (z)\ndis/dir (x) (z)\nset [x v] to ((dis) * ([sin v] of ((dir) + (pr -x)) ))\nset [y v] to (y)\nset [z v] to ((dis) * ([cos v] of ((dir) + (pr -x)) ))\ndis/dir (y) (z)\nset [y v] to ((dis) * ([sin v] of ((dir) + (pr - y)) ))\nset [z v] to ((dis) * ([cos v] of ((dir) + (pr - y)) ))\nset [x v] to ((0.6) * ((1100) * ((x) / ((z) + (1000)))))\nset [y v] to ((0.6) * ((1100) * ((y) / ((z) + (1000)))))\n\ndefine dis/dir (x) (y)\nset [dir v] to ((([atan v] of ((x) / (y)) ) + ((180) * <(y) < [0]>)) mod (360))\nset [dis v] to ([sqrt v] of (((x) * (x)) + ((y) * (y))) )\nif <(y) = [0]> then\n    set [dir v] to [90]\n    if <[0] > (x)> then\n        set [dir v] to [270]\n    end\nend\n\npen up\n\ndefine render face (x1) (y1) (z1) (x2) (y2) (z2) (x3) (y3) (z3) (x4) (y4) (z4) fill (t/f) color (c)\nset [az v] to [0]\ngoto (x1) (y1) (z1)\nchange [az v] by (z)\ngoto (x2) (y2) (z2)\nchange [az v] by (z)\ngoto (x3) (y3) (z3)\nchange [az v] by (z)\ngoto (x4) (y4) (z4)\nchange [az v] by (z)\nif <(t/f) = [t]> then\n    set pen size to (5)\n    pen up\n    goto (x1) (y1) (z1)\n    go to x: (x) y: (y)\n    pen down\n    goto (x2) (y2) (z2)\n    go to x: (x) y: (y)\n    goto (x4) (y4) (z4)\n    go to x: (x) y: (y)\n    goto (x3) (y3) (z3)\n    go to x: (x) y: (y)\n    goto (x1) (y1) (z1)\n    go to x: (x) y: (y)\n    pen up\nelse\nend\nif <(az) < ((((z1) + (z2)) + ((z3) + (z4))) / (4))> then\nend\n\ndefine quad render (x) (y) (x2) (y2) (x3) (y3) (x4) (y4) color (c)\nset [d v] to (([sqrt v] of ((((x) - (x2)) * ((x) - (x2))) + (((y) - (y2)) * ((y) - (y2)))) ) / (1.5))\nset pen size to (1.6)\nset [i v] to [0]\nset pen color to (#51b7ea)\nset pen (color v) to (c)\nrepeat ((d) + (1))\n    set pen (brightness v) to ((50) - ((50) + (((() - (i)) / (d)) * (50))))\n    render row ((x) + ((((x2) - (x)) / (d)) * (i))) ((y) + ((((y2) - (y)) / (d)) * (i))) ((x3) + ((((x4) - (x3)) / (d)) * (i))) ((y3) + ((((y4) - (y3)) / (d)) * (i)))\n    change [i v] by (1)\nend\n\ndefine render row (x1) (y1) (x2) (y2)\npen up\ngo to x: (x1) y: (y1)\npen down\ngo to x: (x2) y: (y2)\npen up\n\ndefine cube C1: (x1) (y1) (z1) C2: (x2) (y2) (z2)\nrender face (x2) (y1) (z1) (x1) (y1) (z1) (x2) (y2) (z1) (x1) (y2) (z1) fill [t] color [60]\nrender face (x2) (y1) (z2) (x1) (y1) (z2) (x2) (y2) (z2) (x1) (y2) (z2) fill [t] color [40]\nrender face (x2) (y1) (z2) (x2) (y1) (z1) (x2) (y2) (z2) (x2) (y2) (z1) fill [t] color [4]\nrender face (x1) (y1) (z2) (x1) (y1) (z1) (x1) (y2) (z2) (x1) (y2) (z1) fill [t] color [80]\nrender face (x2) (y2) (z1) (x1) (y2) (z1) (x2) (y2) (z2) (x1) (y2) (z2) fill [t] color [12]\n\nwhen flag clicked\nhide\nswitch costume to (costume1 v)\nset size to (5000) %\nswitch costume to (costume2 v)\nreset\ndelete all of [cube x1 v]\ndelete all of [cube x2 v]\ndelete all of [cube y1 v]\ndelete all of [cube y2 v]\ndelete all of [cube z1 v]\ndelete all of [cube z2 v]\ncreate cube - [100] [100] [100] [-100] [-100] [-100]\ncreate cube - [300] [300] [300] [100] [100] [100]\ncreate cube - [100] [100] [100] [0] [200] [200]\ncreate cube - [500] [-100] [500] [300] [0] [300]\n\ndefine create cube - (x1) (y1) (z1) (x2) (y2) (z2)\nadd (x1) to [cube x1 v]\nadd (x2) to [cube x2 v]\nadd (y1) to [cube y1 v]\nadd (y2) to [cube y2 v]\nadd (z1) to [cube z1 v]\nadd (z2) to [cube z2 v]\n\nrepeat until <[] > (loops)>\n    cube C1: ((item (loops) of [cube x1 v]) - (scroll x)) ((item (loops) of [cube y1 v]) - (scroll y)) ((item (loops) of [cube z1 v]) - (scroll z)) C2: ((item (loops) of [cube x2 v]) - (scroll x)) ((item (loops) of [cube y2 v]) - (scroll y)) ((item (loops) of [cube z2 v]) - (scroll z))\n    change [loops v] by (1)\nend\n\ndefine touching - detect\nset [loops v] to [1]\ndelete all of [touching v]\nrepeat (length of [cube x1 v])\n    delete all of [compare - result v]\n    detect cube if (item (loops) of [cube x1 v]) > ((player - x) - (-50)) > (item (loops) of [cube x2 v]) ; [x]\n    detect cube if (item (loops) of [cube x1 v]) > ((player - x) - (50)) > (item (loops) of [cube x2 v]) ; [x]\n    detect cube if (item (loops) of [cube x2 v]) > ((player - x) - (-50)) > (item (loops) of [cube x1 v]) ; [x]\n    detect cube if (item (loops) of [cube x2 v]) > ((player - x) - (50)) > (item (loops) of [cube x1 v]) ; [x]\n    detect cube if (item (loops) of [cube y1 v]) > ((player - y) - (-50)) > (item (loops) of [cube y2 v]) ; [y]\n    detect cube if (item (loops) of [cube y1 v]) > ((player - y) - (50)) > (item (loops) of [cube y2 v]) ; [y]\n    detect cube if (item (loops) of [cube y2 v]) > ((player - y) - (-50)) > (item (loops) of [cube y1 v]) ; [y]\n    detect cube if (item (loops) of [cube y2 v]) > ((player - y) - (50)) > (item (loops) of [cube y1 v]) ; [y]\n    detect cube if (item (loops) of [cube z1 v]) > ((player - z) - (-50)) > (item (loops) of [cube z2 v]) ; [z]\n    detect cube if (item (loops) of [cube z1 v]) > ((player - z) - (50)) > (item (loops) of [cube z2 v]) ; [z]\n    detect cube if (item (loops) of [cube z2 v]) > ((player - z) - (-50)) > (item (loops) of [cube z1 v]) ; [z]\n    detect cube if (item (loops) of [cube z2 v]) > ((player - z) - (50)) > (item (loops) of [cube z1 v]) ; [z]\n    detect cube if ((player - x) - (-50)) > (item (loops) of [cube x1 v]) > ((player - x) - (50)) ; [x]\n    detect cube if ((player - x) - (-50)) > (item (loops) of [cube x2 v]) > ((player - x) - (50)) ; [x]\n    detect cube if ((player - y) - (-50)) > (item (loops) of [cube y1 v]) > ((player - y) - (50)) ; [y]\n    detect cube if ((player - y) - (-50)) > (item (loops) of [cube y2 v]) > ((player - y) - (50)) ; [y]\n    detect cube if ((player - z) - (-50)) > (item (loops) of [cube z1 v]) > ((player - z) - (50)) ; [z]\n    detect cube if ((player - z) - (-50)) > (item (loops) of [cube z2 v]) > ((player - z) - (50)) ; [z]\n    if <<[compare - result v] contains [x]?> and <<[compare - result v] contains [y]?> and <[compare - result v] contains [z]?>>> then\n        add [1] to [touching v]\n    end\n    change [loops v] by (1)\nend\n\ndefine detect cube if (a) > (b) > (c) ; (t)\nif <<<(a) > (b)> or <(a) = (b)>> and <<(b) > (c)> or <(b) = (c)>>> then\n    add (t) to [compare - result v]\nelse\nend\n\nwhen flag clicked\nforever\n    erase all\n    render\n    x - movement\n    y - movement \n    z -  movement\n    rotate camara\n    camara position\n    specials\nend\n\ndefine y - movement \ntouching - detect\nif <not <[touching v] contains [1]?>> then\n    change [yv v] by (-1)\n    change [player - y v] by (yv)\n    touching - detect\n    if <[touching v] contains [1]?> then\n        change [player - y v] by (() - (yv))\n        set [yv v] to [0]\n    end\nend\nif <[touching v] contains [1]?> then\n    change [player - y v] by (() - (yv))\nend\nif <<key (space v) pressed?> or <mouse down?>> then\n    change [player - y v] by (-1)\n    touching - detect\n    if <[touching v] contains [1]?> then\n        change [yv v] by (18)\n        change [player - y v] by (2)\n    end\nend\n\ndefine the cube (k)\nset pen color to (#54db43)\ncube C1: ((item (k) of [cube x1 v]) - (scroll x)) ((item (k) of [cube y1 v]) - (scroll y)) ((item (k) of [cube z1 v]) - (scroll z)) C2: ((item (k) of [cube x2 v]) - (scroll x)) ((item (k) of [cube y2 v]) - (scroll y)) ((item (k) of [cube z2 v]) - (scroll z))\n\ndefine rotate camara\nif <key (right arrow v) pressed?> then\n    change [pr -x v] by (-5)\nend\nif <key (left arrow v) pressed?> then\n    change [pr -x v] by (5)\nend\nif <key (up arrow v) pressed?> then\n    change [pr - y v] by (-5)\nend\nif <key (down arrow v) pressed?> then\n    change [pr - y v] by (5)\nend\n\ndefine x - movement\ntouching - detect\nif <not <[touching v] contains [1]?>> then\n    if <key (a v) pressed?> then\n        change [xv v] by (() - ([cos v] of (pr -x) ))\n        change [zv v] by (() - ([sin v] of (pr -x) ))\n    end\n    if <key (d v) pressed?> then\n        change [xv v] by ([cos v] of (pr -x) )\n        change [zv v] by ([sin v] of (pr -x) )\n    end\n    change [player - x v] by (xv)\n    touching - detect\n    if <[touching v] contains [1]?> then\n        change [player - x v] by (() - (xv))\n        set [xv v] to [0]\n        change [player - z v] by (() - (zv))\n        set [zv v] to [0]\n    end\nend\nset [xv v] to ((xv) * (0.8))\nif <[touching v] contains [1]?> then\n    change [player - x v] by (() - (xv))\n    change [player - z v] by (() - (zv))\nend\n\ndefine z -  movement\ntouching - detect\nif <not <[touching v] contains [1]?>> then\n    if <key (s v) pressed?> then\n        change [xv v] by (() - ([cos v] of ((pr -x) + (90)) ))\n        change [zv v] by (() - ([sin v] of ((pr -x) + (90)) ))\n    end\n    if <key (w v) pressed?> then\n        change [xv v] by ([cos v] of ((pr -x) + (90)) )\n        change [zv v] by ([sin v] of ((pr -x) + (90)) )\n    end\n    change [player - z v] by (zv)\n    touching - detect\n    if <[touching v] contains [1]?> then\n        change [player - x v] by (() - (xv))\n        set [xv v] to [0]\n        change [player - z v] by (() - (zv))\n        set [zv v] to [0]\n    end\nend\nset [zv v] to ((zv) * (0.8))\nif <[touching v] contains [1]?> then\n    change [player - x v] by (() - (xv))\n    change [player - z v] by (() - (zv))\nend\n\ndefine camara position\nchange [scroll x v] by (((player - x) - (scroll x)) / (10))\nchange [scroll y v] by (((player - y) - (scroll y)) / (10))\nchange [scroll z v] by (((player - z) - (scroll z)) / (10))\n\ndefine reset\nset [pr -x v] to [0]\nset [pr - y v] to [0]\nset [xv v] to [0]\nset [yv v] to [0]\nset [zv v] to [0]\nset [scroll x v] to [0]\nset [scroll y v] to [200]\nset [scroll z v] to [0]\nset [player - x v] to [0]\nset [player - y v] to [200]\nset [player - z v] to [0]\n\ndefine specials\nif <(player - y) < [-2000]> then\n    reset\nend\n\ndefine render\nthe cube [1]\nthe cube [2]\nthe cube [3]\nthe cube [4]\nset pen color to (#ffb518)\ncube C1: (((50) + (player - x)) - (scroll x)) (((50) + (player - y)) - (scroll y)) (((50) + (player - z)) - (scroll z)) C2: (((-50) + (player - x)) - (scroll x)) (((-50) + (player - y)) - (scroll y)) (((-50) + (player - z)) - (scroll z))\n\n