Skip to content

Commit

Permalink
Fog of war drawing doesn't suck anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfloer committed Nov 13, 2018
1 parent 9d13000 commit 995045f
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions cocos2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 995045f

Please sign in to comment.