{"id":95,"date":"2008-04-21T02:08:26","date_gmt":"2008-04-21T06:08:26","guid":{"rendered":"http:\/\/patorjk.com\/blog\/?p=95"},"modified":"2014-01-25T18:01:59","modified_gmt":"2014-01-25T22:01:59","slug":"javascript-snake","status":"publish","type":"post","link":"https:\/\/patorjk.com\/blog\/2008\/04\/21\/javascript-snake\/","title":{"rendered":"JavaScript Snake"},"content":{"rendered":"<p>During my senior year of high school, I took an independent study course in C++. Originally it had been a full fledged C++ course, but since only 4 students signed up, the school put us all in its independent study program instead. The program worked by allowing students to work by themselves to create a project, and at the end of the semester each student would present their project to a committee to show that they had actually learned something.<\/p>\n<p>On the surface it seemed like a great program, but the school did its hardest to keep us from learning anything. The lady in charge of the program forbid us from using the computers that had C++ compilers, claiming they were &#8220;too old&#8221;, and we weren&#8217;t allowed to install anything on the computers we did have access to. <\/p>\n<p>At first we were resilient and installed compilers we found online anyway. But getting caught got us in a lot of trouble, and this lady was mean &#8211; at one point yelling at me for a solid 20 minutes for breaking one of her rules. This environment wore us down, and eventually we resided ourselves to knowing that we weren&#8217;t going to efficiently learn anything about C++ while we were at school, so we used a lot of our time to goof off.<\/p>\n<p>It was during this time that I discovered the game of Snake. When I was tired of reading up on programming or dealing with crap from the lady in charge of the computer lab, I&#8217;d blow off steam by playing online games. Sometimes I&#8217;d spend the whole hour and a half period playing games. Of these games, Snake ended up being my favorite. I honestly sucked at it then and still suck at it now, but it was pretty mindless and actually pretty fun. <\/p>\n<p>A few days ago, while working on some other JavaScript project for this site, I randomly started thinking about these olden days. After remembering how much I loved Snake I thought to myself &#8220;Hrm, I bet I could write a version of Snake entirely in JavaScript&#8221;. Since Snake is such a simple game, I decided to run with the idea and try and crank out a JavaScript version as quick as possible. You can see what I&#8217;ve got so far by following the below link:<\/p>\n<p><a href=\"http:\/\/patorjk.com\/games\/snake\/\">http:\/\/patorjk.com\/games\/snake<\/a><\/p>\n<p>That is fresh from my hard drive, and it&#8217;s a really bare bones version. I hope to add a couple more features and to optimize it some over the next week. Since JavaScript is interpreted, the game may be a little jumpy on some of your computers (let me know if you have any major problems). When it&#8217;s totally done I&#8217;ll probably also post the source as a JavaScript example. You could peak at it right now if you wanted, but it&#8217;s in a not-ready-for-prime-time state right now.<\/p>\n<p>As an aside, under the hood the snake is a linked list. I googled &#8220;JavaScript linked list&#8221; for some quick linked list code and came across this <a href=\"http:\/\/blog.jcoglan.com\/2007\/07\/23\/writing-a-linked-list-in-javascript\/\">link<\/a>, which is actually pretty nifty. It&#8217;s worth a look if it&#8217;s been a while since you&#8217;ve done anything with linked lists.<\/p>\n<p>TAAG<\/p>\n<p><a href=\"http:\/\/patorjk.com\/software\/taag\/\">TAAG<\/a> was updated with a couple of fonts (they all start with &#8220;JS&#8221;) and I fixed up the feature that allows you to share messages you create with others.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>During my senior year of high school, I took an independent study course in C++. Originally it had been a full fledged C++ course, but since only 4 students signed up, the school put us all in its independent study program instead. The program worked by allowing students to work by themselves to create a &hellip; <a href=\"https:\/\/patorjk.com\/blog\/2008\/04\/21\/javascript-snake\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">JavaScript Snake<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5],"tags":[],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-general-news","category-software"],"_links":{"self":[{"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":8,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":2756,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions\/2756"}],"wp:attachment":[{"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}