Skip to content
Permalink
Browse files

Removing buildings now works!

  • Loading branch information...
dfloer committed Nov 7, 2018
1 parent de11948 commit 924e6fd4904f1d5c3dc0c73256ffef16e7b5bc92
Showing with 6 additions and 3 deletions.
  1. +6 −3 cocos2d.py
@@ -355,13 +355,14 @@ def __init__(self):

def draw_buildings(self):
self.children = []
print('')
for k, building in terrain_map.buildings.items():
print(k, building)
position = hex_math.hex_to_pixel(layout, k, False)
anchor = sprite_width / 2, sprite_height / 2
sprite = Sprite(sprite_images[building.sprite_id], position=position, anchor=anchor)
self.buildings_batch.add(sprite, z=-k.r)
try:
self.buildings_batch.add(sprite, z=-k.r, name=f"{k.q}_{k.r}_{k.s}")
except Exception:
pass # This sprite must already exist, so we skip it.
self.add(self.buildings_batch)

def plop_building(self, cell, building):
@@ -392,7 +393,9 @@ def remove_building(self, cell):
elif terrain_map.buildings[cell].building_id == 0:
print("Can't remove city cores.")
else:
name = f"{cell.q}_{cell.r}_{cell.s}"
terrain_map.remove_building(cell)
self.buildings_batch.remove(name)
self.draw_buildings()


0 comments on commit 924e6fd

Please sign in to comment.
You can’t perform that action at this time.