{"id":381,"date":"2025-07-07T16:40:32","date_gmt":"2025-07-07T06:40:32","guid":{"rendered":"https:\/\/nonlinearexperience.com\/?p=381"},"modified":"2025-07-07T16:40:33","modified_gmt":"2025-07-07T06:40:33","slug":"optimisation-tips","status":"publish","type":"post","link":"https:\/\/nonlinearexperience.com\/index.php\/2025\/07\/07\/optimisation-tips\/","title":{"rendered":"Optimisation Tips"},"content":{"rendered":"<h1 class=\"wp-block-post-title\">Optimisation Tips<\/h1>\n\n\n<p class=\"wp-block-paragraph\">See also: <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">for anything that you are using\u2026<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">JS &#8211; is single threaded\u2026 (is this still the case in 2022?) &#8211; yes it is! <a href=\"https:\/\/www.geeksforgeeks.org\/javascript\/mutlithreading-in-javascript\/\">https:\/\/www.geeksforgeeks.org\/javascript\/mutlithreading-in-javascript\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">use anonymous functions (arrow functions) to reduce memory usage<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Off load onto GPU<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Graphics<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Smaller images are usually painted faster than bigger ones<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Scaling is evil<\/strong>.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Sprite sheets work a little slower than the individual images.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Decimal pixels kill performance<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For rectangle collision system &#8211; use Separating Axis Theorem (SAT) developed by the legendary computer scientist Stefan Gottschalk. It capitalizes on the fact that, in any game, the chance that two objects are not colliding is far more likely than that they are colliding. It\u2019s very efficient because you can find out immediately whether two objects might be colliding just by testing one axis. This means the collision function can skip most of the collision code most of the time. That\u2019s great for games because it saves a lot of processing power. You can also use this same system for 3D collision detection. Just add an additional if statement to check for any overlaps on the third (Z) axis.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use broad phase collisions &#8211; then narrow phase if and when needed<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>See also: for anything that you are using\u2026 JS &#8211; is single threaded\u2026 (is this still the case in 2022?) &#8211; yes it is! https:\/\/www.geeksforgeeks.org\/javascript\/mutlithreading-in-javascript\/ use anonymous functions (arrow functions) to reduce memory usage Off load onto GPU Graphics Smaller images are usually painted faster than bigger ones. Scaling is evil.&nbsp; Sprite sheets work a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"wp-custom-template-nlx-the-knowledge-page","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-381","post","type-post","status-publish","format-standard","hentry","category-the-knowledge"],"_links":{"self":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/comments?post=381"}],"version-history":[{"count":1,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/381\/revisions"}],"predecessor-version":[{"id":382,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/posts\/381\/revisions\/382"}],"wp:attachment":[{"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/media?parent=381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/categories?post=381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nonlinearexperience.com\/index.php\/wp-json\/wp\/v2\/tags?post=381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}