Permalink
Browse files

Fixed error in chunk generation.

  • Loading branch information...
dfloer committed Nov 10, 2018
1 parent 9aa9c65 commit 4f04f3073f8480b76fdaf7d4879ae12b697219d9
Showing with 2 additions and 1 deletion.
  1. +2 −1 cocos2d.py
@@ -80,7 +80,7 @@ def find_visible_chunks(self):
q_offset = self.chunk_size // 2
left = Hexagon(center.q - self.chunk_size, center.r, -(center.q - self.chunk_size) - center.r)
right = Hexagon(center.q + self.chunk_size, center.r, -(center.q + self.chunk_size) - center.r)
up = Hexagon(center.q - q_offset, center.r + self.chunk_size, -(center.q - q_offset) - (center.r + self.chunk_size))
up = Hexagon(center.q - q_offset - 1, center.r + self.chunk_size, -(center.q - q_offset - 1) - (center.r + self.chunk_size))
down = Hexagon(center.q + q_offset + 1, center.r - self.chunk_size, -(center.q + q_offset + 1) - (center.r - self.chunk_size))
# And the four diagonals, based on the previous ones.
up_left = Hexagon(up.q - self.chunk_size, up.r, -(up.q - self.chunk_size) - up.r)
@@ -119,6 +119,7 @@ def generate_chunk(self, center):
for k, v in chunk.chunk_cells.items():
# Todo: this is a hack, figure out why overlapping chunks are ever generated.
if k in self.hexagon_map.keys():
print(f"duplicate hex: {k}.")
continue
self.hexagon_map[k] = v
if k == Hexagon(0, 0, 0):

0 comments on commit 4f04f30

Please sign in to comment.