Tag Info

New answers tagged

0

You can store the direction with 2 bits: 1 for axis and 1 for pos/neg. As such, storage-wise it will be more efficient regardless of the number of bends -- about ~2.5 KB for 10,000 tiles. Store it as a bitmask as well (1.25 KB for 10K tiles) and then you have fast collision checks ("is snake on tile"). The slowest operation would be "Access nth body part" ...


0

In the worst case it looks to me like you're going to use more memory this way. Picture a snake that goes something like this: ‾|_|‾|_|‾ as much as possible. There are a few spots at the edge of the screen where it must go straight for a few squares but those aren't enough to overcome the higher memory storage per location unless the world is small. While ...



Top 50 recent answers are included