{"id":684,"date":"2012-08-22T18:35:07","date_gmt":"2012-08-22T22:35:07","guid":{"rendered":"http:\/\/www.joshho.com\/blog\/?p=684"},"modified":"2012-08-26T10:08:51","modified_gmt":"2012-08-26T14:08:51","slug":"html5-pacman","status":"publish","type":"post","link":"https:\/\/www.joshho.com\/blog\/2012\/08\/22\/html5-pacman\/","title":{"rendered":"HTML5 &#8211; Pacman"},"content":{"rendered":"<p>I was talking to a colleague the other day about HTML5-Snake, and somehow the conversation drifted to Pacman&#8230;<\/p>\n<p>After a weekend of investigating the Pacman (enemy) strategies, I took a break from doing <a href=\"http:\/\/www.joshho.com\/blog\/category\/tidbit\/project-euler\/\" target=\"_blank\">EulerProject questions<\/a>\u00a0and began work on it.<br \/>\nIt seemed simple enough: the background was pre-made, (sprites were handmade), \u00a0and it seemed very do-able.<\/p>\n<p><a href=\"\/apps\/HTML5\/Pacman\/\" target=\"_blank\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-685\" title=\"Pacman\" src=\"http:\/\/www.joshho.com\/blog\/wp-content\/uploads\/2012\/08\/Pacman-239x300.png\" alt=\"\" width=\"239\" height=\"300\" srcset=\"https:\/\/www.joshho.com\/blog\/wp-content\/uploads\/2012\/08\/Pacman-239x300.png 239w, https:\/\/www.joshho.com\/blog\/wp-content\/uploads\/2012\/08\/Pacman.png 459w\" sizes=\"(max-width: 239px) 100vw, 239px\" \/><\/a><\/p>\n<p>It took me 2 days for the base code, +1 for memory\/cpu profiling.<br \/>\nIt is without sound, but I think it&#8217;s quite playable.<\/p>\n<p>You can try it out <a href=\"\/apps\/HTML5\/Pacman\/\" target=\"_blank\">here<\/a>.<\/p>\n<p><!--more--><\/p>\n<p>Some things I learned from this:<\/p>\n<ol>The JS garbage collection can quickly degrade user experience, keep new objects to a minimum, reuse.<\/ol>\n<ol>For-loops can be optimized into do..while loops, as long as you have a negative counter and a check against zero.<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>I was talking to a colleague the other day about HTML5-Snake, and somehow the conversation drifted to Pacman&#8230;<\/p>\n<p>After a weekend of investigating the Pacman (enemy) strategies, I took a break from doing <a href=\"http:\/\/www.joshho.com\/blog\/category\/tidbit\/project-euler\/\" target=\"_blank\">EulerProject questions<\/a>\u00a0and began work on it.<br \/>\nIt seemed simple enough: the background was pre-made, (sprites were handmade), \u00a0and it seemed very do-able.<\/p>\n<p><a href=\"\/apps\/HTML5\/Pacman\/\" target=\"_blank\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-685\" title=\"Pacman\" src=\"http:\/\/www.joshho.com\/blog\/wp-content\/uploads\/2012\/08\/Pacman-239x300.png\" alt=\"\" width=\"239\" height=\"300\" srcset=\"https:\/\/www.joshho.com\/blog\/wp-content\/uploads\/2012\/08\/Pacman-239x300.png 239w, https:\/\/www.joshho.com\/blog\/wp-content\/uploads\/2012\/08\/Pacman.png 459w\" sizes=\"(max-width: 239px) 100vw, 239px\" \/><\/a><\/p>\n<p>It took me 2 days for the base code, +1 for memory\/cpu profiling.<br \/>\nIt is without sound, but I think it&#8217;s quite playable.<\/p>\n<p>You can try it out <a href=\"\/apps\/HTML5\/Pacman\/\" target=\"_blank\">here<\/a>.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[48,25],"tags":[],"_links":{"self":[{"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/posts\/684"}],"collection":[{"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/comments?post=684"}],"version-history":[{"count":0,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/posts\/684\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/media?parent=684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/categories?post=684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshho.com\/blog\/wp-json\/wp\/v2\/tags?post=684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}