Outline (A 100% Pen Scrolling Platformer Engine)


@Stage\n\n@THE ENGINE\n\ndefine tri fill (ax) (ay) (bx) (by) (cx) (cy) resolution: (res)\nset [z lena v] to ([sqrt v] of ((((bx) - (cx)) * ((bx) - (cx))) + (((by) - (cy)) * ((by) - (cy)))) )\nset [z lenb v] to ([sqrt v] of ((((ax) - (cx)) * ((ax) - (cx))) + (((ay) - (cy)) * ((ay) - (cy)))) )\nset [z lenc v] to ([sqrt v] of ((((ax) - (bx)) * ((ax) - (bx))) + (((ay) - (by)) * ((ay) - (by)))) )\nset [z peri v] to ((1) / (((Z lena) + (Z lenb)) + (Z lenc)))\nset [z incx v] to (((((Z lena) * (ax)) + ((Z lenb) * (bx))) + ((Z lenc) * (cx))) * (Z peri))\nset [z incy v] to (((((Z lena) * (ay)) + ((Z lenb) * (by))) + ((Z lenc) * (cy))) * (Z peri))\nset [z ind v] to ([sqrt v] of ((((((Z lenb) + (Z lenc)) - (Z lena)) * (((Z lenc) + (Z lena)) - (Z lenb))) * (((Z lena) + (Z lenb)) - (Z lenc))) * (Z peri)) )\nset [z aox v] to ((Z incx) - (ax))\nset [z aoy v] to ((Z incy) - (ay))\nset [z box v] to ((Z incx) - (bx))\nset [z boy v] to ((Z incy) - (by))\nset [z cox v] to ((Z incx) - (cx))\nset [z coy v] to ((Z incy) - (cy))\nif <<(Z lena) < (Z lenb)> and <(Z lena) < (Z lenc)>> then\n    set [z td v] to ([sqrt v] of (((Z Aox) * (Z Aox)) + ((Z Aoy) * (Z Aoy))) )\nelse\n    if <<(Z lenb) > (Z lena)> or <(Z lenb) > (Z lenc)>> then\n        set [z td v] to ([sqrt v] of (((Z Cox) * (Z Cox)) + ((Z Coy) * (Z Coy))) )\n    else\n        set [z td v] to ([sqrt v] of (((Z Box) * (Z Box)) + ((Z Boy) * (Z Boy))) )\n    end\nend\nset [z rate v] to ((((Z td) * (2)) - (Z ind)) / ((Z td) * (4)))\nset [z td v] to ((1) + (0))\ngo to x: (round (Z incx)) y: (round (Z incy))\nset pen size to (Z ind)\npen down\nrepeat ([ceiling v] of (([log v] of ((res) / (Z ind)) ) / ([log v] of (Z rate) )) )\n    set [z td v] to ((Z td) * (Z rate))\n    set pen size to ((Z ind) * (Z td))\n    go to x: (((Z Aox) * (Z td)) + (ax)) y: (((Z Aoy) * (Z td)) + (ay))\n    go to x: (((Z Box) * (Z td)) + (bx)) y: (((Z Boy) * (Z td)) + (by))\n    go to x: (((Z Cox) * (Z td)) + (cx)) y: (((Z Coy) * (Z td)) + (cy))\n    go to x: (((Z Aox) * (Z td)) + (ax)) y: (((Z Aoy) * (Z td)) + (ay))\nend\nset pen size to (res)\ngo to x: (ax) y: (ay)\ngo to x: (bx) y: (by)\ngo to x: (cx) y: (cy)\ngo to x: (ax) y: (ay)\npen up\n\ndefine rect fill (x1) (y1) (x2) (y2) (res)\nswitch costume to (costume1 v)\nset size to (5000) %\nswitch costume to (costume2 v)\nset pen size to (3)\npen up\ngo to x: (x1) y: (y1)\npen down\ngo to x: (x2) y: (y1)\ngo to x: (x2) y: (y2)\ngo to x: (x1) y: (y2)\ngo to x: (x1) y: (y1)\npen up\n\ntri fill (x1) (y1) (x2) (y1) (x1) (y2) resolution: (res)\ntri fill (x1) (y2) (x2) (y1) (x2) (y2) resolution: (res)\n\nwhen flag clicked\nset [@level v] to [1]\nforever\n    Reset\n    repeat until <(@DIE) > []>\n        erase all\n        Game\n        FPS Counter\n    end\n    if <(@DIE) = [Die]> then\n        Die\n    else\n        wait (0.7) seconds\n        change [@level v] by (1)\n    end\nend\n\ndefine Game\nRender Background\nRender Player ((@X) - (@CAM X)) ((@Y) - (@CAM Y)) [20] [10]\nRender Level\nPhysics\n\ndefine Render Player (x) (y) (size) (res)\nset pen color to (#2aff00)\nrect fill ((x) - ((size) / (2))) ((y) + ((size) / (2))) ((x) + ((size) / (2))) ((y) - ((size) / (2))) (res)\n\ndefine Physics\nif <(@YV) > [-20]> then\n    change [@yv v] by (-1)\nend\nif <key (left arrow v) pressed?> then\n    change [@xv v] by (-1)\nend\nif <key (right arrow v) pressed?> then\n    change [@xv v] by (1)\nend\nset [@xv v] to ((@XV) * (0.9))\nChange x by (@XV)\nchange [@y v] by (-2)\nCollision - Ground\nif <<(_touching ground?) = [1]> and <key (up arrow v) pressed?>> then\n    set [@yv v] to [16]\nend\nif <<(_touching mv?) = [1]> and <key (up arrow v) pressed?>> then\n    set [@yv v] to [16]\nend\nchange [@y v] by (2)\nChange y by (@YV)\nchange [@cam x v] by (((@X) - (@CAM X)) / (10))\nchange [@cam y v] by (((@Y) - (@CAM Y)) / (10))\nif <(@CAM X) < [0]> then\n    set [@cam x v] to [0]\nend\nif <(@CAM Y) < [0]> then\n    set [@cam y v] to [0]\nend\nif <(@Y) < [-180]> then\n    set [@die v] to [die]\nend\nCollision - Lava\nif <(_touching danger?) = [1]> then\n    set [@die v] to [die]\nend\nset [@x v] to (round (@X))\nset [@y v] to (round (@Y))\nCollision - Bouncy\nif <(_touching bouncy?) = [1]> then\n    set [@yv v] to [20]\nend\nCollision - End\nif <(_touching end?) = [1]> then\n    set [@die v] to [Win]\nend\n\ndefine Reset\nset [@x v] to [-174]\nset [@y v] to [-124]\nset [@cam x v] to [0]\nset [@cam y v] to [0]\nset [@xv v] to [0]\nset [@yv v] to [0]\nset [@player size v] to [25]\nset [@die v] to []\nset [f frames v] to [0]\nset [f next second v] to [1]\n\ndefine Change x by (xv)\nchange [@x v] by (xv)\nCollision - Ground\nif <(_touching ground?) = [1]> then\n    repeat (12)\n        change [@y v] by (1)\n        Collision - Ground\n        if <not <(_touching ground?) = [1]>> then\n            stop [this script v]\n        end\n    end\n    change [@y v] by (-12)\n    Collision - Ground\n    if <(_touching ground?) = [1]> then\n        repeat until <not <(_touching ground?) = [1]>>\n            if <(xv) > [0]> then\n                change [@x v] by (-1)\n            else\n                change [@x v] by (1)\n            end\n            Collision - Ground\n        end\n        set [@xv v] to [0]\n    end\nend\n\ndefine Change y by (yv)\nchange [@y v] by (yv)\nCollision - Ground\nif <(_touching ground?) = [1]> then\n    repeat until <not <(_touching ground?) = [1]>>\n        if <(yv) > [0]> then\n            change [@y v] by (-1)\n        else\n            change [@y v] by (1)\n        end\n        Collision - Ground\n    end\n    set [@yv v] to [0]\nend\n\ndefine Render Level\ndelete all of [g r x1 v]\ndelete all of [g r y1 v]\ndelete all of [g r x2 v]\ndelete all of [g r y2 v]\ndelete all of [mv r x1 v]\ndelete all of [mv r y1 v]\ndelete all of [mv r x2 v]\ndelete all of [mv r y2 v]\ndelete all of [l x1 v]\ndelete all of [l x2 v]\ndelete all of [l y1 v]\ndelete all of [l y2 v]\ndelete all of [b x1 v]\ndelete all of [b x2 v]\ndelete all of [b y1 v]\ndelete all of [b y2 v]\ndelete all of [e x1 v]\ndelete all of [e x2 v]\ndelete all of [e y1 v]\ndelete all of [e x2 v]\nif <(@LEVEL) = [1]> then\n    Render Ground - x1/x2/y1/y2 [-240] [-140] [200] [-180]\n    Render Ground - x1/x2/y1/y2 [160] [200] [200] [-20]\n    Render Ground - x1/x2/y1/y2 [-100] [-80] [-80] [-100]\n    Render Ground - x1/x2/y1/y2 [0] [0] [20] [-20]\n    Render Ground - x1/x2/y1/y2 [80] [80] [100] [60]\n    Render Ground - x1/x2/y1/y2 [250] [200] [500] [160]\n    Render Lava - x1/x2 [503] [597] base y [160] height [20] rise fall speed/range [40] [12]\n    Render Ground - x1/x2/y1/y2 [600] [200] [650] [160]\n    Render Lava - x1/x2 [503] [597] base y [160] height [20] rise fall speed/range [40] [12]\n    Render Ground - x1/x2/y1/y2 [600] [200] [650] [160]\n    Render Lava - x1/x2 [653] [747] base y [160] height [20] rise fall speed/range [40] [12]\n    Render Ground - x1/x2/y1/y2 [750] [200] [800] [160]\n    Render Ground - x1/x2/y1/y2 [850] [100] [950] [60]\n    Render Ground - x1/x2/y1/y2 [1000] [0] [1100] [-40]\n    Render Ground - x1/x2/y1/y2 [1150] [-100] [1250] [-140]\n    Render Bouncy x1/y1/x2/y2 [1253] [-100] [1332] [-140]\n    Render Ground - x1/x2/y1/y2 [1335] [50] [1400] [-140]\n    Render End x1/y1/x2/y2 [1480] [130] [1520] [170]\nend\nif <(@LEVEL) = [2]> then\n    Render Ground - x1/x2/y1/y2 [-240] [-140] [200] [-180]\n    Render Lava - x1/x2 [-140] [-120] base y [-140] height [100] rise fall speed/range [90] [90]\n    Render Lava - x1/x2 [60] [80] base y [-140] height [100] rise fall speed/range [90] [90]\n    Render Ground - x1/x2/y1/y2 ((230) + (([cos v] of (((days since 2000) * (100000)) * (100)) ) * (100))) [-40] [340] [-80]\n    Render Ground - x1/x2/y1/y2 [380] [70] ((490) + (([cos v] of (((days since 2000) * (100000)) * (100)) ) * (100))) [30]\n    Render Bouncy x1/y1/x2/y2 [650] [70] [900] [30]\n    Render Lava - x1/x2 [650] [850] base y [250] height [40] rise fall speed/range [0] [0]\n    Render End x1/y1/x2/y2 [1000] [250] [1040] [210]\nend\nif <(@LEVEL) = [3]> then\n    Render Ground - x1/x2/y1/y2 [-240] [-140] [-140] [-180]\nend\n\ndefine Render Ground - x1/x2/y1/y2 (x1) (y1) (x2) (y2)\nset pen color to (#000000)\nrect fill ((x1) - (@CAM X)) ((y1) - (@CAM Y)) ((x2) - (@CAM X)) ((y2) - (@CAM Y)) [1]\nadd (x1) to [g r x1 v]\nadd (y1) to [g r y1 v]\nadd (x2) to [g r x2 v]\nadd (y2) to [g r y2 v]\n\ndefine Collision - Ground\nset [# v] to [1]\nset [_touching ground? v] to [0]\nrepeat (length of [g r x1 v])\n    if <((@X) + ((@PLAYER SIZE) / (2))) > (item (#) of [g r x1 v])> then\n        if <((@X) - ((@PLAYER SIZE) / (2))) < (item (#) of [g r x2 v])> then\n            if <((@Y) - ((@PLAYER SIZE) / (2))) < (item (#) of [g r y1 v])> then\n                if <((@Y) + ((@PLAYER SIZE) / (2))) > (item (#) of [g r y2 v])> then\n                    set [_touching ground? v] to [1]\n                end\n            end\n        end\n    end\n    change [# v] by (1)\nend\nset [# v] to [1]\nset [_touching mv? v] to [0]\nrepeat (length of [mv r x1 v])\n    if <((@X) + ((@PLAYER SIZE) / (2))) > (item (#) of [mv r x1 v])> then\n        if <((@X) - ((@PLAYER SIZE) / (2))) < (item (#) of [mv r x2 v])> then\n            if <((@Y) - ((@PLAYER SIZE) / (2))) < (item (#) of [mv r y1 v])> then\n                if <((@Y) + ((@PLAYER SIZE) / (2))) > (item (#) of [mv r y2 v])> then\n                    set [_touching mv? v] to [1]\n                end\n            end\n        end\n    end\n    change [# v] by (1)\nend\n\ndefine Render Background\ngo to x: (0) y: (0)\nset pen color to (#ffffff)\nset pen size to (1000)\npen down\npen up\n\ndefine Die\nset [@die v] to []\nFPS Counter\nwait (1) seconds\n\ndefine FPS Counter\nchange [f frames v] by (1)\nif <(timer) > (F next second)> then\n    set [fps v] to (F frames)\n    set [f frames v] to [0]\n    change [f next second v] by (1)\nend\n\ndefine Render Lava - x1/x2 (x1) (x2) base y (base y) height (height) rise fall speed/range (speed) (range)\nset pen color to (#ff0000)\nrect fill ((x1) - (@CAM X)) ((((base y) + (height)) + ([abs v] of (([cos v] of (((days since 2000) * (100000)) * (speed)) ) * (range)) )) - (@CAM Y)) ((x2) - (@CAM X)) ((base y) - (@CAM Y)) [1]\nadd (x1) to [l x1 v]\nadd (((base y) + (height)) + ([abs v] of (([cos v] of (((days since 2000) * (100000)) * (speed)) ) * (range)) )) to [l y1 v]\nadd (x2) to [l x2 v]\nadd (base y) to [l y2 v]\n\nwhen [timer v] > (0.01)\nerase all\n\ndefine Collision - Lava\nset [# v] to [1]\nset [_touching danger? v] to [0]\nrepeat (length of [l y1 v])\n    if <((@X) + ((@PLAYER SIZE) / (2))) > (item (#) of [l x1 v])> then\n        if <((@X) - ((@PLAYER SIZE) / (2))) < (item (#) of [l x2 v])> then\n            if <((@Y) - ((@PLAYER SIZE) / (2))) < (item (#) of [l y1 v])> then\n                if <((@Y) + ((@PLAYER SIZE) / (2))) > (item (#) of [l y2 v])> then\n                    set [_touching danger? v] to [1]\n                end\n            end\n        end\n    end\n    change [# v] by (1)\nend\n\ndefine Render Bouncy x1/y1/x2/y2 (x1) (y1) (x2) (y2)\nset pen color to (#ffae00)\nrect fill ((x1) - (@CAM X)) ((y1) - (@CAM Y)) ((x2) - (@CAM X)) ((y2) - (@CAM Y)) [1]\nadd (x1) to [b x1 v]\nadd (y1) to [b y1 v]\nadd (x2) to [b x2 v]\nadd (y2) to [b y2 v]\n\ndefine Collision - Bouncy\nset [# v] to [1]\nset [_touching bouncy? v] to [0]\nrepeat (length of [b x1 v])\n    if <((@X) + ((@PLAYER SIZE) / (2))) > (item (#) of [b x1 v])> then\n        if <((@X) - ((@PLAYER SIZE) / (2))) < (item (#) of [b x2 v])> then\n            if <((@Y) - ((@PLAYER SIZE) / (2))) < (item (#) of [b y1 v])> then\n                if <((@Y) + ((@PLAYER SIZE) / (2))) > (item (#) of [b y2 v])> then\n                    set [_touching bouncy? v] to [1]\n                end\n            end\n        end\n    end\n    change [# v] by (1)\nend\n\ndefine Render End x1/y1/x2/y2 (x1) (y1) (x2) (y2)\nset pen color to (#00aeff)\nrect fill ((x1) - (@CAM X)) ((y1) - (@CAM Y)) ((x2) - (@CAM X)) ((y2) - (@CAM Y)) [1]\nadd (x1) to [e x1 v]\nadd (y1) to [e y1 v]\nadd (x2) to [e x2 v]\nadd (y2) to [e y2 v]\n\ndefine Collision - End\nset [# v] to [1]\nset [_touching end? v] to [0]\nrepeat (length of [e x1 v])\n    if <((@X) + ((@PLAYER SIZE) / (2))) > (item (#) of [e x1 v])> then\n        if <((@X) - ((@PLAYER SIZE) / (2))) < (item (#) of [e x2 v])> then\n            if <((@Y) - ((@PLAYER SIZE) / (2))) < (item (#) of [e y1 v])> then\n                if <((@Y) + ((@PLAYER SIZE) / (2))) > (item (#) of [e y2 v])> then\n                    set [_touching end? v] to [1]\n                end\n            end\n        end\n    end\n    change [# v] by (1)\nend\n\n@Thumbnail\n\nwhen flag clicked\nset [ghost v] effect to (100)\nforever\n    go to [front v] layer\nend\n\n@Username Collector\n\nwhen flag clicked\nif <(username) = [icmy123]> then\n    forever\n        Check Cloud\n        wait (0.1) seconds\n    end\nelse\n    if <not <[usernames v] contains (username)?>> then\n        Encode (username)\n        set [☁ tran v] to (@ans)\n    end\nend\n\ndefine Encode (item)\nset [#2 v] to [1]\nset [@ans v] to []\nrepeat (length of (item))\n    switch costume to (letter (#2) of (item))\n    set [@ans v] to (join (@ans) (costume [number v]))\n    change [#2 v] by (1)\nend\n\ndefine Decode (item)\nset [#2 v] to [1]\nset [@ans v] to []\nrepeat ((length of (item)) / (2))\n    switch costume to (join (letter (#2) of (item)) (letter ((#2) + (1)) of (item)))\n    set [@ans v] to (join (@ans) (costume [name v]))\n    change [#2 v] by (2)\nend\n\ndefine Check Cloud\nif <not <(☁ Tran) = [0]>> then\n    Decode (☁ Tran)\n    set [☁ tran v] to [0]\n    if <not <[usernames v] contains (@ans)?>> then\n        add (@ans) to [usernames v]\n        start sound [Car Horn v]\n    end\nend\n\n