Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The basic data structure is this

((0 (73 84 92)) (1 (17 95 31)))

Where the 2 digit numbers are id numbers for the blocks. The single digit number to left of each row is the horizontal offset.

So, shifting a row, the most elementary operation in the game, just requires incrementing the offset.

Vertical shifts are done with a 90 degree rotation operation, then a horizontal shift, then a -90 degree rotation.

Sometimes traversing the lists is necessary, but the most common operations are fast, and then rest are fast enough.

The limiting factor in performance is definitely rendering, not the game logic.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: