3D Platformer Engine
@Stage\n\nwhen flag clicked\nset volume to (30) %\nwait (0.4) seconds\nforever\n    play sound [Sonic Colours OST - Sweet Mountain Map.mp3 v] until done\nend\n\nwhen [m v] key pressed\nif <(volume) = [0]> then\n    set volume to (30) %\nelse\n    set volume to (0) %\nend\n\n@Pen1\n\nwhen flag clicked\nset pen size to (2)\nset pen color to (#30cebd)\nswitch costume to (medium v)\nset size to (100) %\n\ndefine Set Point 1: (x1) (y1) (z1)\nset [x1 v] to (x1)\nset [y1 v] to (y1)\nset [z1 v] to (z1)\n\ndefine Set Point 2: (x2) (y2) (z2)\nset [x2 v] to (x2)\nset [y2 v] to (y2)\nset [z2 v] to (z2)\n\ndefine Draw Line (x1) (y1) (z1) to (x2) (y2) (z2)\nSet Point 1: ((x1) - (cam x)) ((y1) - (cam y)) ((z1) - (cam z))\nSet Point 2: ((x2) - (cam x)) ((y2) - (cam y)) ((z2) - (cam z))\nSet Point 1: (((z1) * (sin Y)) + ((x1) * (cos Y))) (y1) (((z1) * (cos Y)) - ((x1) * (sin Y)))\nSet Point 2: (((z2) * (sin Y)) + ((x2) * (cos Y))) (y2) (((z2) * (cos Y)) - ((x2) * (sin Y)))\nSet Point 1: (x1) (((y1) * (cos X)) - ((z1) * (sin X))) (((y1) * (sin X)) + ((z1) * (cos X)))\nSet Point 2: (x2) (((y2) * (cos X)) - ((z2) * (sin X))) (((y2) * (sin X)) + ((z2) * (cos X)))\nif <not <<(z1) < (near plane)> and <(z2) < (near plane)>>> then\n    Z Clipping\n    Set Screen Point 1: ((view factor) * ((x1) / (z1))) ((view factor) * ((y1) / (z1)))\n    Set Screen Point 2: ((view factor) * ((x2) / (z2))) ((view factor) * ((y2) / (z2)))\n    XY Clipping\n    go to x: (x1) y: (y1)\n    pen down\n    go to x: (x2) y: (y2)\n    pen up\nend\n\ndefine Set Screen Point 1: (x1) (y1)\nset [x1 v] to (x1)\nset [y1 v] to (y1)\n\ndefine Set Screen Point 2: (x2) (y2)\nset [x2 v] to (x2)\nset [y2 v] to (y2)\n\ndefine Go to x: (x) y: (y) z: (z) with shift\ngo to x: ((view factor) * (((x) - (cam x)) / ((z) - (cam z)))) y: ((view factor) * (((y) - (cam y)) / ((z) - (cam z))))\n\ndefine --- (label)\n\ndefine Calculate Trig Values\nset [sin x v] to ([sin v] of (rot X) )\nset [cos x v] to ([cos v] of (rot X) )\nset [sin y v] to ([sin v] of (rot Y) )\nset [cos y v] to ([cos v] of (rot Y) )\n\ndefine Z Clipping\nif <<(z1) < (near plane)> or <(z2) < (near plane)>> then\n    set [percent v] to (((near plane) - (z1)) / ((z2) - (z1)))\n    if <(z1) < (near plane)> then\n        Set Point 1: ((x1) + (((x2) - (x1)) * (percent))) ((y1) + (((y2) - (y1)) * (percent))) (near plane)\n    else\n        if <(z2) < (near plane)> then\n            Set Point 2: ((x1) + (((x2) - (x1)) * (percent))) ((y1) + (((y2) - (y1)) * (percent))) (near plane)\n        end\n    end\nend\n\ndefine XY Clipping\nset [m v] to (((y2) - (y1)) / ((x2) - (x1)))\nif <(x1) > [240]> then\n    if <(x2) > [240]> then\n        stop [this script v]\n    else\n        Set Screen Point 1: (240) ((y1) + (((240) - (x1)) * (m)))\n    end\nend\nif <(y1) > [180]> then\n    if <(y2) > [180]> then\n        stop [this script v]\n    else\n        Set Screen Point 1: ((x1) + (((180) - (y1)) / (m))) (180)\n    end\nend\nif <(x1) < [-240]> then\n    if <(x2) < [-240]> then\n        stop [this script v]\n    else\n        Set Screen Point 1: (-240) ((y1) + (((-240) - (x1)) * (m)))\n    end\nend\nif <(y1) < [-180]> then\n    if <(y2) < [-180]> then\n        stop [this script v]\n    else\n        Set Screen Point 1: ((x1) + (((-180) - (y1)) / (m))) (-180)\n    end\nend\nif <(x2) > [240]> then\n    Set Screen Point 2: (240) ((y1) + (((240) - (x1)) * (m)))\nend\nif <(y2) > [180]> then\n    Set Screen Point 2: ((x1) + (((180) - (y1)) / (m))) (180)\nend\nif <(x2) < [-240]> then\n    Set Screen Point 2: (-240) ((y1) + (((-240) - (x1)) * (m)))\nend\nif <(y2) < [-180]> then\n    Set Screen Point 2: ((x1) + (((-180) - (y1)) / (m))) (-180)\nend\n\ndefine Cube at (x) (y) (z) with size (size)\nCalculate Trig Values\n--- [Back of Cube]\nDraw Line ((x) + (size)) ((y) + (size)) ((z) + (size)) to ((x) + (size)) ((y) - (size)) ((z) + (size))\nDraw Line ((x) + (size)) ((y) - (size)) ((z) + (size)) to ((x) - (size)) ((y) - (size)) ((z) + (size))\nDraw Line ((x) - (size)) ((y) - (size)) ((z) + (size)) to ((x) - (size)) ((y) + (size)) ((z) + (size))\nDraw Line ((x) - (size)) ((y) + (size)) ((z) + (size)) to ((x) + (size)) ((y) + (size)) ((z) + (size))\n--- [Front of Cube]\nDraw Line ((x) + (size)) ((y) + (size)) ((z) - (size)) to ((x) + (size)) ((y) - (size)) ((z) - (size))\nDraw Line ((x) + (size)) ((y) - (size)) ((z) - (size)) to ((x) - (size)) ((y) - (size)) ((z) - (size))\nDraw Line ((x) - (size)) ((y) - (size)) ((z) - (size)) to ((x) - (size)) ((y) + (size)) ((z) - (size))\nDraw Line ((x) - (size)) ((y) + (size)) ((z) - (size)) to ((x) + (size)) ((y) + (size)) ((z) - (size))\n--- [Lines from Front to Back]\nDraw Line ((x) + (size)) ((y) + (size)) ((z) + (size)) to ((x) + (size)) ((y) + (size)) ((z) - (size))\nDraw Line ((x) + (size)) ((y) - (size)) ((z) + (size)) to ((x) + (size)) ((y) - (size)) ((z) - (size))\nDraw Line ((x) - (size)) ((y) - (size)) ((z) + (size)) to ((x) - (size)) ((y) - (size)) ((z) - (size))\nDraw Line ((x) - (size)) ((y) + (size)) ((z) + (size)) to ((x) - (size)) ((y) + (size)) ((z) - (size))\n\nwhen flag clicked\nforever\n    Reset\n    repeat until <(___die?) > []>\n        erase all\n        Game\n    end\n    Die\nend\n\ndefine Game\nLevel\nPhysics\n\ndefine Level\ndelete all of [x1 v]\ndelete all of [x2 v]\ndelete all of [y1 v]\ndelete all of [y2 v]\ndelete all of [z1 v]\ndelete all of [z2 v]\ndelete all of [type v]\nTile at [0] [0] [0] with size [30] type [g]\nTile at [60] [0] [0] with size [30] type [g]\nTile at [120] [0] [0] with size [30] type [g]\nTile at [120] [60] [0] with size [30] type [g]\nTile at [120] [120] [0] with size [30] type [g]\nTile at [120] [180] [0] with size [30] type [g]\nTile at [0] [120] [0] with size [30] type [g]\nTile at [60] [0] [60] with size [30] type [g]\nTile at [60] [0] [120] with size [30] type [g]\nTile at [60] [60] [120] with size [30] type [g]\nTile at [60] [0] [180] with size [30] type [g]\nTile at [60] [0] [240] with size [30] type [g]\nTile at [60] [0] [360] with size [30] type [g]\nTile at [60] [0] [420] with size [30] type [d]\nTile at [60] [0] [480] with size [30] type [g]\nTile at [60] [0] [540] with size [30] type [g]\nset pen color to (#ff9d2d)\nCube at (__player x) (__player y) (__player z) with size (__player s)\n\ndefine Physics\nchange [_player yv v] by (-1)\nif <key (left arrow v) pressed?> then\n    change [_rot rxv v] by (0.8)\nend\nif <key (right arrow v) pressed?> then\n    change [_rot rxv v] by (-0.8)\nend\nset [_rot rxv v] to ((_rot rxv) * (0.6))\nchange [rot y v] by (_rot rxv)\nif <key (up arrow v) pressed?> then\n    change [_rot ryv v] by (0.8)\nend\nif <key (down arrow v) pressed?> then\n    change [_rot ryv v] by (-0.8)\nend\nset [_rot ryv v] to ((_rot ryv) * (0.6))\nchange [rot x v] by (_rot ryv)\nif <key (a v) pressed?> then\n    change [_player xv v] by (-1)\nend\nif <key (d v) pressed?> then\n    change [_player xv v] by (1)\nend\nset [_player xv v] to ((_player xv) * (0.75))\nchange x by xv\nif <key (w v) pressed?> then\n    change [_player zv v] by (1)\nend\nif <key (s v) pressed?> then\n    change [_player zv v] by (-1)\nend\nset [_player zv v] to ((_player zv) * (0.75))\nchange z by zv\nchange [__player y v] by (-2)\nCollision\nif <<key (space v) pressed?> and <(___touching ground?) = [1]>> then\n    set [_player yv v] to [12]\nend\nCollision\nif <(___touching bouncy?) = [1]> then\n    if  then\n        set [_player yv v] to [12]\n    end\nend\nchange [__player y v] by (2)\nchange y by yv\nchange [cam x v] by ((((__player x) + (((sin Y) * (cos X)) * (150))) - (cam x)) / (10))\nchange [cam y v] by ((((__player y) + ((sin X) * (-150))) - (cam y)) / (10))\nchange [cam z v] by ((((__player z) + (((cos Y) * (cos X)) * (-150))) - (cam z)) / (10))\nif <(__player y) < [-70]> then\n    set [___die? v] to [die]\nend\nif <(___touching danger?) = [1]> then\n    set [___die? v] to [die]\nend\n\ndefine Collision\nset [___i v] to [0]\nset [___touching ground? v] to [0]\nset [___touching danger? v] to [0]\nrepeat (length of [x1 v])\n    change [___i v] by (1)\n    if <((__player x) + (__player s)) > (item (___i) of [x1 v])> then\n        if <((__player x) - (__player s)) < (item (___i) of [x2 v])> then\n            if <((__player y) - (__player s)) < (item (___i) of [y1 v])> then\n                if <((__player y) + (__player s)) > (item (___i) of [y2 v])> then\n                    if <((__player z) - (__player s)) < (item (___i) of [z1 v])> then\n                        if <((__player z) + (__player s)) > (item (___i) of [z2 v])> then\n                            if <(item (___i) of [type v]) = [g]> then\n                                set [___touching ground? v] to [1]\n                            else\n                                if <(item (___i) of [type v]) = [d]> then\n                                    set [___touching danger? v] to [1]\n                                else\n                                    set [___touching bouncy? v] to [1]\n                                end\n                            end\n                        end\n                    end\n                end\n            end\n        end\n    end\nend\n\ndefine Tile at (x) (y) (z) with size (size) type (type)\nif <(type) = [g]> then\n    set pen color to (#c5c5c5)\nelse\n    if <(type) = [d]> then\n        set pen color to (#c56262)\n    else\n        set pen color to (#7f62c5)\n    end\nend\nset pen (transparency v) to (([abs v] of ((__player z) - ((z) - (size))) ) / (3))\nCalculate Trig Values\n--- [Back of Cube]\nDraw Line ((x) + (size)) ((y) + (size)) ((z) + (size)) to ((x) + (size)) ((y) - (size)) ((z) + (size))\nDraw Line ((x) + (size)) ((y) - (size)) ((z) + (size)) to ((x) - (size)) ((y) - (size)) ((z) + (size))\nDraw Line ((x) - (size)) ((y) - (size)) ((z) + (size)) to ((x) - (size)) ((y) + (size)) ((z) + (size))\nDraw Line ((x) - (size)) ((y) + (size)) ((z) + (size)) to ((x) + (size)) ((y) + (size)) ((z) + (size))\n--- [Front of Cube]\nDraw Line ((x) + (size)) ((y) + (size)) ((z) - (size)) to ((x) + (size)) ((y) - (size)) ((z) - (size))\nDraw Line ((x) + (size)) ((y) - (size)) ((z) - (size)) to ((x) - (size)) ((y) - (size)) ((z) - (size))\nDraw Line ((x) - (size)) ((y) - (size)) ((z) - (size)) to ((x) - (size)) ((y) + (size)) ((z) - (size))\nDraw Line ((x) - (size)) ((y) + (size)) ((z) - (size)) to ((x) + (size)) ((y) + (size)) ((z) - (size))\n--- [Lines from Front to Back]\nDraw Line ((x) + (size)) ((y) + (size)) ((z) + (size)) to ((x) + (size)) ((y) + (size)) ((z) - (size))\nDraw Line ((x) + (size)) ((y) - (size)) ((z) + (size)) to ((x) + (size)) ((y) - (size)) ((z) - (size))\nDraw Line ((x) - (size)) ((y) - (size)) ((z) + (size)) to ((x) - (size)) ((y) - (size)) ((z) - (size))\nDraw Line ((x) - (size)) ((y) + (size)) ((z) + (size)) to ((x) - (size)) ((y) + (size)) ((z) - (size))\nadd ((x) - (size)) to [x1 v]\nadd ((x) + (size)) to [x2 v]\nadd ((y) + (size)) to [y1 v]\nadd ((y) - (size)) to [y2 v]\nadd ((z) + (size)) to [z1 v]\nadd ((z) - (size)) to [z2 v]\nadd (type) to [type v]\n\ndefine change y by yv\nchange [__player y v] by (round (_player yv))\nCollision\nif <(___touching ground?) = [1]> then\n    repeat until <not <(___touching ground?) = [1]>>\n        Collision\n        if <(_player yv) > [0]> then\n            change [__player y v] by (-1)\n        else\n            change [__player y v] by (1)\n        end\n    end\n    set [_player yv v] to [0]\n    change [__player y v] by (-1)\nend\n\ndefine change x by xv\nchange [__player x v] by (round (_player xv))\nCollision\nif <(___touching ground?) = [1]> then\n    change [__player y v] by (12)\n    Collision\n    if <not <(___touching ground?) = [1]>> then\n        stop [this script v]\n    end\n    change [__player y v] by (-12)\n    Collision\n    if <(___touching ground?) = [1]> then\n        repeat until <not <(___touching ground?) = [1]>>\n            Collision\n            if <(_player xv) > [0]> then\n                change [__player x v] by (-1)\n            else\n                change [__player x v] by (1)\n            end\n        end\n        if <(_player xv) > [0]> then\n            change [__player x v] by (1)\n        else\n            change [__player x v] by (-1)\n        end\n        set [_player xv v] to [0]\n    end\nend\n\ndefine change z by zv\nchange [__player z v] by (round (_player zv))\nCollision\nif <(___touching ground?) = [1]> then\n    change [__player y v] by (12)\n    Collision\n    if <not <(___touching ground?) = [1]>> then\n        stop [this script v]\n    end\n    change [__player y v] by (-12)\n    Collision\n    if <(___touching ground?) = [1]> then\n        repeat until <not <(___touching ground?) = [1]>>\n            Collision\n            if <(_player zv) > [0]> then\n                change [__player z v] by (-1)\n            else\n                change [__player z v] by (1)\n            end\n        end\n        if <(_player zv) > [0]> then\n            change [__player z v] by (1)\n        else\n            change [__player z v] by (-1)\n        end\n        set [_player zv v] to [0]\n    end\nend\n\ndefine Reset\nset [_player yv v] to [0]\nset [_player xv v] to [0]\nset [__player x v] to [60]\nset [__player y v] to [50]\nset [__player z v] to [60]\nset [view factor v] to [300]\nset [cam x v] to [60]\nset [cam y v] to [50]\nset [cam z v] to [-140]\nset [rot x v] to [3]\nset [rot y v] to [355]\nset [___touching danger? v] to [0]\nset [___touching bouncy? v] to [0]\n\ndefine Die\nwait (0.7) seconds\nset [___die? v] to []\n\n@TN\n\nwhen flag clicked\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n
WASD to move\nArrow Keys to look around\nSpace to jump\n\nThis is just an engine so there is not much to play.