define('DISALLOW_FILE_EDIT', true);{"id":220,"date":"2009-07-09T01:49:42","date_gmt":"2009-07-09T06:49:42","guid":{"rendered":"http:\/\/www.unfocus.com\/?p=220"},"modified":"2009-07-09T01:49:42","modified_gmt":"2009-07-09T06:49:42","slug":"unfocus-games-tetris-clone","status":"publish","type":"post","link":"http:\/\/www.unfocus.com\/2009\/07\/09\/unfocus-games-tetris-clone\/","title":{"rendered":"unFocus.Games – Tetris clone"},"content":{"rendered":"

I made a promise<\/a> on someone else’s blog to post the code for the Tetris clone<\/a> I made a while back, probably in fatigue induced delirium, a little bit ago, so here it is<\/a> in a new Google Code<\/a> project called unFocus.Games<\/a>.\u00a0The post on bit-101<\/a> post was about game architecture. While developing the code for the clone, I did play with concepts around architecture quite a bit. I also played with learning about Flash 10 features – adding PixelBender<\/a> filters, and even having an Ogg Vorbis<\/a> based soundtrack for a while (tried both the HaXe decoder<\/a>, and the Alchemy decoder<\/a>).\u00a0I took them both out for now though, as well as some of the more unorthodox uses of Actionscript 3.0 I had in there – I was experimenting, and besides, Flash CS4’s compiler is a bit more finicky than Flash CS3’s was. One of these days I’ll get around to blogging about some of that stuff.<\/p>\n

The Tetris<\/a> game has an event driven engine under the graphics. I wanted it to feel close to the old NES and GameBoy version of the game I remember as a kid, and didn’t want the animation stuff to get in the way of that. The text version of the game in the demo I posted is almost a raw dump of the engine data. The field is a 2D array of 1s and 0s (looking to learn bit shifting and similar concepts at some point, by converting that to a ByteArray of ints). I also did the pieces (tetrads) as 2D array representations of bitmaps at one point, but didn’t feel like working out the rotation math, so I ported a pre-calculated coordinate version of the tetrads from an old Actionscript 1.0 version of a basic tetris game I once wrote.<\/p>\n

Quick note about the code – I used TweenLite<\/a> to do some of the quick animations, but I did not include that in the repository. You’ll need to grab a copy of that yourself, and add it to your class path to compile the source code as it is. At some point I plan to remove that either entirely or replace it with Tweener<\/a> (because of the licensing).<\/p>\n

In regards to game architecture, I don’t know if it follows any particular pattern (MVC seems to be quite popular these days – can’t talk about software design without hearing of that).\u00a0Anyway, the code is probably far from efficient, as that hasn’t necessarily\u00a0been a goal as I wrote it, and it’s far from finished, but there are some fun bits in there. Feel free to take a look, and share any thoughts. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"

I made a promise on someone else’s blog to post the code for the Tetris clone I made a while back, probably in fatigue induced delirium, a little bit ago, so here it is in a new Google Code project called unFocus.Games.\u00a0The post on bit-101 post was about game architecture. While developing the code for … Continue reading “unFocus.Games – Tetris clone”<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[33,17,18],"_links":{"self":[{"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/posts\/220"}],"collection":[{"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":2,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":222,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/posts\/220\/revisions\/222"}],"wp:attachment":[{"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.unfocus.com\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}