Ejemplo n.º 1
0
def snackxy(grid, w, h):
    # snacks are not transparent but walkable
    for x in range(w):
        for y in range(h):
            if not tcod.map_is_transparent(grid, x, y) and tcod.map_is_walkable(grid, x, y):
                return True, x, y
    return False, 0, 0
Ejemplo n.º 2
0
def test_map():
    map = libtcodpy.map_new(16, 16)
    assert libtcodpy.map_get_width(map) == 16
    assert libtcodpy.map_get_height(map) == 16
    libtcodpy.map_copy(map, map)
    libtcodpy.map_clear(map)
    libtcodpy.map_set_properties(map, 0, 0, True, True)
    assert libtcodpy.map_is_transparent(map, 0, 0)
    assert libtcodpy.map_is_walkable(map, 0, 0)
    libtcodpy.map_is_in_fov(map, 0, 0)
    libtcodpy.map_delete(map)
Ejemplo n.º 3
0
 def print_is_transparent_map(self):
     """
     Prints a map of what this entity can see through.
     """
     for y in range(libtcod.map_get_height(self.dungeon_map)):
         line = ""
         for x in range(libtcod.map_get_width(self.dungeon_map)):
             if libtcod.map_is_transparent(self.dungeon_map, x, y):
                 line += " "
             else:
                 line += "#"
         print(line)
Ejemplo n.º 4
0
 def print_is_transparent_map(self):
     """
     Prints a map of what this entity can see through.
     """
     for y in range(libtcod.map_get_height(self.dungeon_map)):
         line = ""
         for x in range(libtcod.map_get_width(self.dungeon_map)):
             if libtcod.map_is_transparent(self.dungeon_map, x, y):
                 line += " "
             else:
                 line += "#"
         print(line)
Ejemplo n.º 5
0
     snake.insert(0, o)
     tcod.map_set_properties(grid, x, y, False, False)
     if grow:
         growth += 1
         if growth == 5:
             growth = 0
             grow = False
     else:
         tcod.map_set_properties(grid, snake[-1].x, snake[-1].y, True, True)
         snake.pop()
     # gen snack/bait
     if random.randint(0, 100) < chance:
         while True:
             x = random.randint(0, CW)
             y = random.randint(0, CH)
             if tcod.map_is_transparent(grid, x, y):
                 break
         o = Obj(x, y)
         if random.randint(0, 100) < 50:
             bait.append(o)
             tcod.map_set_properties(grid, x, y, False, False)
         else:
             snack.append(o)
             tcod.map_set_properties(grid, x, y, False, True)
 else:
     msg = 'game over man!'
     tcod.console_print(CON, (CW - len(msg)) / 2, CH / 2, msg)
     msg = 'hit ESC to restart'
     tcod.console_print(CON, (CW - len(msg)) / 2, CH / 2 + 2, msg)
 # blit console
 tcod.console_blit(CON, 0, 0, 0, 0, None, W0, H0)
Ejemplo n.º 6
0
	def is_transparent(self, coord):
		return tc.map_is_transparent(self.base_map, *coord)
Ejemplo n.º 7
0
	def unset_temp_blocking(self):
		for actor in self.temporary_blocking:
			libtcod.map_set_properties(self.owner.map.libtcod_map, actor.x, actor.y, libtcod.map_is_transparent(self.owner.map.libtcod_map, actor.x, actor.y), True)
		
		self.temporary_blocking = []
		
Ejemplo n.º 8
0
	def set_temp_blocking(self, actor):
		libtcod.map_set_properties(self.owner.map.libtcod_map, actor.x, actor.y, libtcod.map_is_transparent(self.owner.map.libtcod_map, actor.x, actor.y), False)
		
		self.temporary_blocking.append(actor)