To much gap between last commit
Im now working next on shoorting for turret Added new sand map and new cannon tower images aswell as function to play animations, showing range, placing turrets on allowed tiles for towers Buy and cancel button to buy towers
This commit is contained in:
@@ -13,6 +13,8 @@ class Tilemap:
|
||||
self.offgrid_tiles = []
|
||||
self.waypoints=[]
|
||||
|
||||
self.tower_placeable = [{"type": "desert", "variant": 0}]
|
||||
|
||||
def save(self, path):
|
||||
f = open(path, 'w')
|
||||
json.dump({'tilemap': self.tilemap, 'tile_size': self.tile_size, 'waypoints': self.waypoints}, f)
|
||||
@@ -27,6 +29,17 @@ class Tilemap:
|
||||
self.tile_size = map_data['tile_size']
|
||||
self.waypoints = map_data['waypoints']
|
||||
|
||||
def placeable(self, tile_pos):
|
||||
str_tile_pos = f'{tile_pos[0]};{tile_pos[1]}'
|
||||
if str_tile_pos not in self.tilemap:
|
||||
return False
|
||||
|
||||
tile = self.tilemap[str_tile_pos]
|
||||
for ti in self.tower_placeable:
|
||||
if tile['type'] == ti['type'] and tile['variant'] == ti['variant']:
|
||||
return True
|
||||
return False
|
||||
|
||||
def render(self, surf, offset=(0, 0)):
|
||||
for x in range(offset[0] // self.tile_size, (offset[0] + surf.get_width()) // self.tile_size + 1):
|
||||
for y in range(offset[1] // self.tile_size, (offset[1] + surf.get_height()) // self.tile_size + 1):
|
||||
|
||||
Reference in New Issue
Block a user