Permalink
Browse files

Fog of war drawing doesn't suck anymore.

  • Loading branch information...
dfloer committed Nov 13, 2018
1 parent 9d13000 commit 995045f683d93329edaae6ebc8ae6e3283f8b285
Showing with 21 additions and 22 deletions.
  1. +21 −22 cocos2d.py
@@ -484,28 +484,27 @@ def add_visible_area(self, center, visible_type=0, radius=7):
terrain_map.hexagon_map[h].visible += visible_type

def draw_fog(self):
pass
# print("draw fog")
# viewport_hexes = scroller.visible_hexes
# for k in viewport_hexes:
# h = terrain_map.hexagon_map[k]
# if h.visible == 0:
# pass
# position = hex_math.hex_to_pixel(layout, k, False)
# anchor = sprite_width / 2, sprite_height / 2
# sprite_id = "fog"
# sprite = Sprite(sprite_images[sprite_id], position=position, anchor=anchor)
# try:
# self.fog_batch.add(sprite, z=-k.r, name=f"{k.q}_{k.r}_{k.s}")
# except Exception:
# pass
# else:
# try:
# self.fog_batch.remove(f"{k.q}_{k.r}_{k.s}")
# except Exception:
# pass
# self.add(self.fog_batch) # Todo: figure out why fog drawing is so slow.
# print("draw fog done.")

self.fog_batch.children = []
viewport_hexes = scroller.visible_hexes
for k in viewport_hexes:
h = terrain_map.hexagon_map[k]
if h.visible == 0:
pass
position = hex_math.hex_to_pixel(layout, k, False)
anchor = sprite_width / 2, sprite_height / 2
sprite_id = "fog"
sprite = Sprite(sprite_images[sprite_id], position=position, anchor=anchor)
try:
self.fog_batch.add(sprite, z=-k.r, name=f"{k.q}_{k.r}_{k.s}")
except Exception:
pass
else:
try:
self.fog_batch.remove(f"{k.q}_{k.r}_{k.s}")
except Exception:
pass
self.add(self.fog_batch)


class OverlayLayer(ScrollableLayer):

0 comments on commit 995045f

Please sign in to comment.