News for hackers. Stuff that matters.
Re:Show HN: My current App Store Featured Game was written e... by TuringTest on Friday March 07, 2014 @02:43PM (#7362283)
Oh? How do you traverse vertical and horizontal structures that are wider than one block? If you have vertical lists, following a horizontal row wild involve lots of find-nth-position calls, which I wouldn't call "natural"
Re:Show HN: My current App Store Featured Game was written e... by rrradical on Friday March 07, 2014 @02:48PM (#7362314)
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.