Thursday 14 October 2010

Tetris Version 2 Part 1

To read my tetris version one click here


Tetris Version 2, is a quantum leap compare to version one. 
  • Reduce code; No more position management for each blocks
  • Run faster; Taking advantage of groups and HTML ability.
The position are now handle using CSS and HTML. We are now using css properties float, allow DOM object to self align to the top left or right corner.

With out float


With Float, the object inside auto align. Instead of position each block, we can now just put 10 block in and they auto align.

For performance increase, instead of creating and destroying dom object, all object we use are now created before hand and reuse. With grouping and css float, we have our biggest gain come when the row are filled with blocks. In the previous version the blocks have to be remove and all the blocks on top have to move down. The new approach we just move the row to the top (O1).






No comments:

Post a Comment