Pages

Friday, July 15, 2016

Generated a gridded spiral for repositioning!

When a player builds on top of itself, it needs automatically jump (teleport) to the nearest adjacent spot in the game. There are various solutions to this problem, but I chose to create a gridded spiral to solve it, which is kind of a unique solution but should be more time-efficient.

What happens is, I create and store something like a gridded Archimedean spiral with unique points when the game starts. Then, when a player builds on top of itself, the game runs through this spiral (in an outward fashion) and checks each space until it finds an empty one.

Forty third step complete (orange lines drawn in Paint for illustration):
 Here is what the spiral algorithm would generate if I spaced it out 3 times (not using this one):

I'm in the middle of adding more features in regards to building and moving, so more progress updates on that coming soon!

No comments:

Post a Comment