dfloer/panda3d-game

Started work on in-game buildings. Protection towers can be plopped.

• Loading branch information...
dfloer committed Nov 6, 2018
1 parent 7f2d09e commit 4986965faaaea070b10aa51cd9f297909b2f0e92
Showing with 8 additions and 2 deletions.
1. +7 −1 cocos2d.py
2. +1 −1 hex_math.py
3. sprites/protection tower.png
 @@ -219,7 +219,7 @@ class Building: """ A class to store the different buildings in. """ _sprite_to_building = {0: "core claimed", 1: "RB"} _sprite_to_building = {0: "core claimed", 1: "RB", 2: "HR", 3: "protection tower"} def __init__(self, building_id): self.building_id = building_id @@ -300,6 +300,9 @@ def on_mouse_press(self, x, y, button, dy): elif self.key is ord('d'): print("delete") building_layer.remove_building(h) elif self.key is ord('p'): b = Building(3) building_layer.plop_building(h, b) def on_mouse_motion(self, x, y, dx, dy): @@ -371,6 +374,9 @@ def plop_building(self, cell, building): """ if cell not in terrain_map.buildings.keys(): terrain_map.add_building(cell, building) if building.building_id == 3: terrain_map.add_safe_area(cell, 2, 3) overlay_layer.draw_safe() self.draw_buildings() else: print("Building already exists, skipping.")
 @@ -153,6 +153,6 @@ def get_hex_chunk(center, radius): r1 = max(-radius, -q - radius) r2 = min(radius, -q + radius) for r in range(r1, r2 + 1): h = Hexagon(center.q + q, center.r + r, -q - r) h = Hexagon(center.q + q, center.r + r, -(center.q + q) - (center.r + r)) hexes += [h] return hexes
Binary file not shown.

0 comments on commit `4986965`

Please sign in to comment.