Esempio n. 1
0
 def _draw_silhouettes(self, pc, tx,ty, ent):
     '''
     #   extend a line from tile tx,ty to a distant tile
     #   which is in the same direction from the player.
     #   Check for lit tiles, and if we find any along the way,
     #   draw a silhouette for the location of interest.
     #   Basically, if the ent is backlit, you can see
     #   a silhouette.
     '''
     world=rog.world()
     if world.has_component(pc, cmp.SenseSight):
         sight=world.component_for_entity(pc, cmp.SenseSight).sight
     else:
         return      
     if not (ent and world.has_component(ent, cmp.Creature)):
         return
     pos=world.component_for_entity(ent, cmp.Position)  
     dist=maths.dist(pos.x,pos.y, tx,ty)
     dx=(tx - pos.x)/dist
     dy=(ty - pos.y)/dist
     xdest=tx + int(dx*sight)
     ydest=ty + int(dy*sight)
     libtcod.line_init(tx,ty, xdest,ydest)
     while True:
         x,y=libtcod.line_step()
         if x is None: return
         if maths.dist(pos.x,pos.y, x,y) > sight: return
         if self.get_blocks_sight(x,y):  return
         if self.get_light_value(x,y):
             libtcod.console_put_char(self.con_map_state, tx,ty, "?")
             return
Esempio n. 2
0
def map_find_line(coords1, coords2, max_range, penetrate_walls,
                  pierce_creature):

    assert max_range is None or isinstance(max_range, int)

    x1, y1 = coords1
    x2, y2 = coords2

    libtcod.line_init(x1, y1, x2, y2)
    calc_x, calc_y = libtcod.line_step()
    coord_list = []

    cnt = 0
    while calc_x is not None:
        if not penetrate_walls and glob.GAME.current_map[calc_x][
                calc_y].block_path:
            return coord_list
        if not pierce_creature and map_check_for_creature(calc_x, calc_y):
            return coord_list

        coord_list.append((calc_x, calc_y))
        cnt += 1
        if (calc_x, calc_y) == coords2 or (max_range is not None
                                           and cnt >= max_range):
            return coord_list
        calc_x, calc_y = libtcod.line_step()

    return [coords1]
Esempio n. 3
0
	def _move (self):
		# self.x = clamp(self.x + random.randint(-1, 1), 0, self.state.map.w - 1)
		# self.y = clamp(self.y + random.randint(-1, 1), 0, self.state.map.h - 1)
		
		step_x, step_y = self.state.heart.x, self.state.heart.y
		baits = [e for e in self.state.entities if isinstance(e, towers.Bait)]
		if baits:
			curr_bait = baits[0]
			for bait in baits:
				if util.dist(self.x, self.y, curr_bait.x, curr_bait.y) > util.dist(self.x, self.y, bait.x, bait.y):
					curr_bait = bait
			step_x, step_y = curr_bait.x, curr_bait.y
		
		tcod.line_init(self.x, self.y, step_x, step_y)
		x, y = tcod.line_step()
		
		if x is None:
			pass
		else:
			did_hit = False
			for e in self.state.entities:
				if e.x == x and e.y == y and isinstance(e, towers.Building):
					self.hit(e)
					did_hit = True
			
			if not did_hit:
				self.x = x
				self.y = y
Esempio n. 4
0
def fractal_rectangle(start_position,
                      max_width,
                      max_height,
                      min_width=1,
                      min_height=1):
    visited = set()
    frame = geo.Rect(start_position, max_width, max_height).border_points()

    length = max_width / 4 if frame[0][0] == 0 or frame[0][
        0] == max_width else max_height / 4
    for point in frame:
        libtcod.line_init(start_position[0], start_position[1], point[0],
                          point[1])
        x, y = libtcod.line_step()
        max_length = max_width / 2 if point[0] == 0 or point[
            0] == max_width else max_height / 2
        min_length = min_width / 2 if point[1] == 0 or point[
            1] == min_width else min_height / 2
        delta = random.sample([0, 0, 0, 0, 1, 1, -1, -1, -1], 1)[0]
        length = min(max((delta + length), min_length), max_length)
        i = length
        while not x is None and i > 0:
            visited.add((x, y))
            x, y = libtcod.line_step()
            i -= 1

    return visited
def target_tile(actor, max_range=None):
    """
    Return the position of a tile left-clicked in player's FOV
    (optionally in a range), or (None,None) if right-clicked.
    """
    (key, mouse) = poll()
    (ox, oy) = (mouse.cx, mouse.cy)
    using_mouse = False
    using_keyboard = False
    (kx, ky) = renderer.ScreenCoords.fromWorldCoords(actor.camera_position,
                                                     actor.pos)
    pos = None

    while True:
        # Render the screen. This erases the inventory and shows
        # the names of objects under the mouse.
        libtcod.console_flush()
        (key, mouse) = poll()
        renderer.render_all(actor, (kx, ky))
        actor.current_map.fov_needs_recompute = False
        if (mouse.cx != ox or mouse.cy != oy):
            using_mouse = True
            using_keyboard = False
        (key_pressed, direction, shift) = parse_move(key)
        if key_pressed:
            using_keyboard = True
            if using_mouse:
                (ox, oy) = (mouse.cx, mouse.cy)
            using_mouse = False
            if direction:
                kx += direction.x
                ky += direction.y

        if using_mouse:
            (kx, ky) = (mouse.cx, mouse.cy)
        pos = renderer.ScreenCoords.toWorldCoords(actor.camera_position, (kx, ky))
        libtcod.console_set_default_background(renderer._overlay, libtcod.black)
        libtcod.console_clear(renderer._overlay)
        (ux, uy) = renderer.ScreenCoords.fromWorldCoords(actor.camera_position,
                                                         actor.pos)
        libtcod.line_init(ux, uy, kx, ky)

        nx, ny = libtcod.line_step()
        while ((not (nx is None)) and nx >= 0 and ny >= 0 and
               nx < config.MAP_PANEL_WIDTH and
               ny < config.MAP_PANEL_HEIGHT):
            libtcod.console_set_char_background(renderer._overlay, nx, ny, libtcod.sepia, libtcod.BKGND_SET)
            nx, ny = libtcod.line_step()

        if mouse.rbutton_pressed or key.vk == libtcod.KEY_ESCAPE:
            libtcod.console_clear(renderer._overlay)
            return None

        # Accept the target if the player clicked in FOV
        # and within the range specified.
        if ((mouse.lbutton_pressed or key.vk == libtcod.KEY_ENTER) and
                libtcod.map_is_in_fov(actor.current_map.fov_map, pos.x, pos.y) and
                (max_range is None or actor.distance(pos) <= max_range)):
            libtcod.console_clear(renderer._overlay)
            return pos
Esempio n. 6
0
def test_line_step():
    """
    libtcodpy.line_init and libtcodpy.line_step
    """
    libtcodpy.line_init(*LINE_ARGS)
    for expected_xy in EXCLUSIVE_RESULTS:
        assert libtcodpy.line_step() == expected_xy
    assert libtcodpy.line_step() == (None, None)
Esempio n. 7
0
 def set_line_path(self, destination):
     sx, sy = self.parent.position.value
     dx, dy = destination
     libtcod.line_init(sx, sy, dx, dy)
     self.clear()
     x, y = libtcod.line_step()
     while not x is None:
         self.position_list.insert(0, (x, y))
         x, y = libtcod.line_step()
Esempio n. 8
0
 def set_line_path(self, destination):
     sx, sy = self.parent.position.value
     dx, dy = destination
     libtcod.line_init(sx, sy, dx, dy)
     self.clear()
     x, y = libtcod.line_step()
     while not x is None:
         self.position_list.insert(0, (x, y))
         x, y = libtcod.line_step()
Esempio n. 9
0
def get_path(start, destination):
    result = [start]
    sx, sy = start
    dx, dy = destination
    libtcod.line_init(sx, sy, dx, dy)
    x, y = libtcod.line_step()
    while not x is None:
        result.append((x, y))
        x, y = libtcod.line_step()
    return result
Esempio n. 10
0
def get_path(start, destination):
    result = [start]
    sx, sy = start
    dx, dy = destination
    libtcod.line_init(sx, sy, dx, dy)
    x, y = libtcod.line_step()
    while not x is None:
        result.append((x, y))
        x, y = libtcod.line_step()
    return result
Esempio n. 11
0
    def draw(self, buffer):

        # Draw Connecting Lines
        for index1, index2 in self.one_way_links:
            if index1 == self.current_sector and \
               index2 == self.sectors[self.current_sector].neighbors[self.targeted_sector_index] or \
               index2 == self.current_sector and \
               index1 == self.sectors[self.current_sector].neighbors[self.targeted_sector_index]:
                # if this is a line to the target sector
                color = libtcod.Color(0, 255, 0)
            elif self.sectors[index1].discovered() and self.sectors[index2].discovered():
                # if this is a line between two discovered sectors
                color = libtcod.Color(87, 186, 255)
            else:
                # else standard connecting line
                color = libtcod.Color(150, 150, 150)

            libtcod.line_init(
                self.sectors[index1].galaxy_position_x,
                self.sectors[index1].galaxy_position_y,
                self.sectors[index2].galaxy_position_x,
                self.sectors[index2].galaxy_position_y,
            )
            x,y=libtcod.line_step()
            while x is not None:
                # if self.sectors[index1].discovered() or self.sectors[index2].discovered():
                buffer.set_fore(x, y, color[0], color[1], color[2], 4)
                x,y=libtcod.line_step()

        # Draw Sectors Nodes
        for index, sector in enumerate(self.sectors):
            x, y = sector.galaxy_position_x, sector.galaxy_position_y
            buffer.set_fore(x, y, sector.star_color[0], sector.star_color[1], sector.star_color[2], sector.star_icon)
            for x, y, icon in [(x-1, y-1, ord(' ')), (x, y-1, ord(' ')), (x+1, y-1, ord(' ')),
                               (x-1, y,   ord(' ')),                     (x+1, y,   ord(' ')),
                               (x-1, y+1, ord(' ')), (x, y+1, ord(' ')), (x+1, y+1, ord(' ')) ]:
                buffer.set_fore(x, y, 0, 0, 0, icon )

            if index == self.sectors[self.current_sector].neighbors[self.targeted_sector_index]:
                x, y  = sector.galaxy_position_x, sector.galaxy_position_y
                for x, y, icon in [(x-1, y-1, ord(' ')), (x, y-1, ord('-')), (x+1, y-1, ord(' ')),
                                   (x-1, y,   ord('|')),                     (x+1, y,   ord('|')),
                                   (x-1, y+1, ord(' ')), (x, y+1, ord('-')), (x+1, y+1, ord(' ')) ]:
                    buffer.set_fore(x, y, 255, 128, 128, icon)

            if index == self.current_sector:
                t = time.clock()
                if t > self.selected_blink + 0.5:
                    if t > self.selected_blink + 1.0:
                        self.selected_blink = t
                    x, y  = sector.galaxy_position_x, sector.galaxy_position_y
                    for x, y, icon in [(x-1, y-1, 213), (x, y-1, 205), (x+1, y-1, 184),
                                       (x-1, y,   179),                (x+1, y,   179),
                                       (x-1, y+1, 212), (x, y+1, 205), (x+1, y+1, 190) ]:
                        buffer.set_fore(x, y, 128, 255, 128, icon)
 def _get_current_path(self):
     result = []
     sx, sy = self.start_position
     dx, dy = self.cursor_position
     libtcod.line_init(sx, sy, dx, dy)
     x, y = libtcod.line_step()
     while not x is None:
         result.append((x, y))
         x, y = libtcod.line_step()
     result.append(self.cursor_position)
     return result
Esempio n. 13
0
def get_tiles_between(x1, y1, x2, y2):
    tiles = []
    #returns all tiles on the line between tile1 and tile2, including those tiles.
    libtcod.line_init(x1, y1, x2, y2)
    done = False
    while not done:
        (x, y) = libtcod.line_step()
        if x and y:
            tiles.append(defn.dungeon[x][y])
        else:
            done = True
    return tiles
Esempio n. 14
0
    def get_line_inclusive(self, origin, destination):
        """Return list of all tiles between the two coordinates. Includes origin and destination.
        origin: (x, y)
        destination: (x, y)
        """
        libtcod.line_init(origin[0], origin[1], destination[0], destination[1])

        coords = []
        x,y = origin

        while (not x is None):
            if x < 0 or x > self.width or y < 0 or y > self.height:
                break
            coords.append((x, y))
            x, y = libtcod.line_step()
        return coords
Esempio n. 15
0
 def _draw_distant_lights(self, pc, view_x,view_y,view_w,view_h):
     pcPos=rog.world().component_for_entity(pc, cmp.Position)
     for light in rog.list_lights():
         lx=light.x
         ly=light.y
         if (lx == pcPos.x and ly == pcPos.y): continue
         if not (lx >= view_x and ly >= view_y
             and lx <= view_x + view_w and ly <= view_y + view_h
             ):
             continue
         libtcod.line_init(pcPos.x,pcPos.y, lx,ly)
         canSee=True
         while True:
             x,y=libtcod.line_step()
             if x == None: break;
             if self.get_blocks_sight(x,y): canSee=False;break;
         if canSee:
             libtcod.console_put_char(self.con_map_state, lx,ly, "?")
Esempio n. 16
0
    def get_line(self, origin, destination, bypassWalls = False, ignoreFov = False, limit = None):
        """Return list of all tiles between the two coordinates
        origin: (x, y)
        destination: (x, y)
        bypassWalls: Flag to allow line to pass through walls
        ignoreFov: Flag to allow line to extend out of FOV
        limit: Maximum number of cells to return
        """
        if (origin == destination):
            return [origin]

        libtcod.line_init(origin[0], origin[1], destination[0], destination[1])
        x, y = libtcod.line_step()
        coords = []

        while (not x is None):
            passable = self.is_passable(x,y)
            infov = self.is_visible(x,y)
            validCell = True

            if (x, y) == destination:
                break

            if x < 0 or x > self.width or y < 0 or y > self.height:
                break

            if not ignoreFov:
                if not infov:
                    validCell = False

            if not bypassWalls:
                if not passable:
                    validCell = False

            if validCell:
                coords.append((x, y))

            x, y = libtcod.line_step()

        if limit:
            coords = coords[:limit]
        return coords
Esempio n. 17
0
def map_find_line(coords1, coords2):
    #converts two x,y coords into a list of tiles
    #coords1 = (x1, y1)     coords2 = (x2,y2)

    x1, y1 = coords1
    x2, y2 = coords2

    libtcod.line_init(x1, y1, x2, y2)

    calc_x, calc_y = libtcod.line_step()
    coord_list = []

    if x1 == x2 and y1 == y2:
        return [(x1, y1)]

    while (not calc_x is None):
        coord_list.append((calc_x, calc_y))

        calc_x, calc_y = libtcod.line_step()

    return coord_list
Esempio n. 18
0
	elif key.vk == libtcod.KEY_LEFT and dest_x > 0:
		dest_x -= diff
		if alt:
			dest_y -= diff
	elif key.vk == libtcod.KEY_ESCAPE and any([key.lctrl,key.rctrl]): break
	elif key.c == ord('>') and level < mp.depth: level += 1
	elif key.c == ord('<') and level > 1: level -= 1

	dest_x = min(dest_x,MAP_X-1)
	dest_y = min(dest_y,MAP_Y-1)

	dest_x = max(dest_x,0)
	dest_y = max(dest_y,0)

	if olevel == level:
		libtcod.line_init(player_x,player_y, dest_x,dest_y)
		nx,ny = libtcod.line_step()
		while None not in {nx,ny}:
			if not lm.get_walkable(level,nx,ny):
				libtcod.console_print(message_con, 0,0,'You cannot walk through a %s' % lm.get_tile_type(level, nx,ny)[0])
				break
			print nx,ny
			player_x,player_y = nx,ny
			nx,ny = libtcod.line_step()

	else:
		player_prop = player_x/MAP_X, player_y/MAP_Y
		offset_prop = offset_x/MAP_X, offset_y/MAP_Y
		levelmap = mp.get_level(level)
		MAP_Y,MAP_X = len(levelmap), len(levelmap[0])
		libtcod.console_clear(0)
Esempio n. 19
0
def target_tile(actor, max_range=None):
    """
    Return the position of a tile left-clicked in player's FOV
    (optionally in a range), or (None,None) if right-clicked.
    """
    (key, mouse) = poll()
    (ox, oy) = (mouse.cx, mouse.cy)
    using_mouse = False
    using_keyboard = False
    (kx, ky) = renderer.ScreenCoords.fromWorldCoords(actor.camera_position,
                                                     actor.pos)
    pos = None

    while True:
        # Render the screen. This erases the inventory and shows
        # the names of objects under the mouse.
        libtcod.console_flush()
        (key, mouse) = poll()
        renderer.render_all(actor, (kx, ky))
        actor.current_map.fov_needs_recompute = False
        if (mouse.cx != ox or mouse.cy != oy):
            using_mouse = True
            using_keyboard = False
        (key_pressed, direction, shift) = parse_move(key)
        if key_pressed:
            using_keyboard = True
            if using_mouse:
                (ox, oy) = (mouse.cx, mouse.cy)
            using_mouse = False
            if direction:
                kx += direction.x
                ky += direction.y

        if using_mouse:
            (kx, ky) = (mouse.cx, mouse.cy)
        pos = renderer.ScreenCoords.toWorldCoords(actor.camera_position,
                                                  (kx, ky))
        libtcod.console_set_default_background(renderer._overlay,
                                               libtcod.black)
        libtcod.console_clear(renderer._overlay)
        (ux,
         uy) = renderer.ScreenCoords.fromWorldCoords(actor.camera_position,
                                                     actor.pos)
        libtcod.line_init(ux, uy, kx, ky)

        nx, ny = libtcod.line_step()
        while ((not (nx is None)) and nx >= 0 and ny >= 0
               and nx < config.MAP_PANEL_WIDTH
               and ny < config.MAP_PANEL_HEIGHT):
            libtcod.console_set_char_background(renderer._overlay, nx, ny,
                                                libtcod.sepia,
                                                libtcod.BKGND_SET)
            nx, ny = libtcod.line_step()

        if mouse.rbutton_pressed or key.vk == libtcod.KEY_ESCAPE:
            libtcod.console_clear(renderer._overlay)
            return None

        # Accept the target if the player clicked in FOV
        # and within the range specified.
        if ((mouse.lbutton_pressed or key.vk == libtcod.KEY_ENTER) and
                libtcod.map_is_in_fov(actor.current_map.fov_map, pos.x, pos.y)
                and (max_range is None or actor.distance(pos) <= max_range)):
            libtcod.console_clear(renderer._overlay)
            return pos
Esempio n. 20
0
    def PlotTo(self, xTo, yTo):
        # Plot the start point as directly pointing to the new location.
        # At the moment this will use the Line Algorithm provided in that one thingy.

        # If this is the very start of the plot, put a 'star' indicating that its the end
        # of a track.
        if (self.firstPlot == True):
            self.map.Tile(self.x, self.y).trackChar = self.firstPlotChar
            self.map.Tile(self.x, self.y).IsTrack = True
            if (not self.CurrentLocation is None):
                self.CurrentLocation.AssignTile(self.map.Tile(self.x, self.y))
            self.firstPlot = False

        libtcod.line_init(self.x, self.y, xTo, yTo)
        x, y = libtcod.line_step()
        while (not x is None):
            # ---- Determine the direction between this track and the last.
            xd = x - self.x
            yd = y - self.y

            newTile = self.map.Tile(x, y)
            oldTile = self.map.Tile(self.x, self.y)
            if (xd == 0 and yd == -1):  # going north
                newTile.trackChar = '|'
                newTile.S = True
                newTile.IsTrack = True
                oldTile.N = True
            if (xd == 1 and yd == -1):  # going northeast
                newTile.trackChar = '/'
                newTile.SW = True
                newTile.IsTrack = True
                oldTile.NE = True
            if (xd == 1 and yd == 0):  # going east
                newTile.trackChar = '-'
                newTile.W = True
                newTile.IsTrack = True
                oldTile.E = True
            if (xd == 1 and yd == 1):  # going southeast
                newTile.trackChar = '\\'
                newTile.NW = True
                newTile.IsTrack = True
                oldTile.SE = True
            if (xd == 0 and yd == 1):  # going south
                newTile.trackChar = '|'
                newTile.N = True
                newTile.IsTrack = True
                oldTile.S = True
            if (xd == -1 and yd == 1):  # going southwest
                newTile.trackChar = '/'
                newTile.NE = True
                newTile.IsTrack = True
                oldTile.SW = True
            if (xd == -1 and yd == 0):  # going west
                newTile.trackChar = '-'
                newTile.E = True
                newTile.IsTrack = True
                oldTile.W = True
            if (xd == -1 and yd == -1):  # going northwest
                newTile.trackChar = '\\'
                newTile.SE = True
                newTile.IsTrack = True
                oldTile.NW = True

            # If either the old or new location has more than 2 connections, then it is a switch. Mark it as such.
            if newTile.CountConnections() == 3 and newTile.Switch is None:
                self.MakeSwitchAt(x, y)

            if oldTile.CountConnections() == 3 and oldTile.Switch is None:
                self.MakeSwitchAt(self.x, self.y)

            # If this is on a current location, then assign it to that location
            if (not self.CurrentLocation is None):
                self.CurrentLocation.AssignTile(newTile)

            # Move along, using the member variables to store the previous location.
            self.x = x
            self.y = y
            x, y = libtcod.line_step()

        self.x = xTo
        self.y = yTo
Esempio n. 21
0
 def PlotTo(self, xTo, yTo):
     # Plot the start point as directly pointing to the new location.
     # At the moment this will use the Line Algorithm provided in that one thingy.
     
     # If this is the very start of the plot, put a 'star' indicating that its the end
     # of a track.        
     if (self.firstPlot == True):
         self.map.Tile(self.x,self.y).trackChar = self.firstPlotChar
         self.map.Tile(self.x,self.y).IsTrack = True            
         if (not self.CurrentLocation is None):
             self.CurrentLocation.AssignTile(self.map.Tile(self.x,self.y))                
         self.firstPlot = False
     
     libtcod.line_init(self.x, self.y, xTo, yTo)
     x,y = libtcod.line_step()
     while (not x is None):
         # ---- Determine the direction between this track and the last.
         xd = x - self.x
         yd = y - self.y
         
         newTile = self.map.Tile(x,y)
         oldTile = self.map.Tile(self.x, self.y)            
         if (xd == 0 and yd == -1): # going north
             newTile.trackChar = '|'
             newTile.S = True
             newTile.IsTrack = True
             oldTile.N = True
         if (xd == 1 and yd == -1): # going northeast
             newTile.trackChar = '/'
             newTile.SW = True
             newTile.IsTrack = True
             oldTile.NE = True
         if (xd == 1 and yd == 0): # going east
             newTile.trackChar = '-'
             newTile.W = True
             newTile.IsTrack = True
             oldTile.E = True
         if (xd == 1 and yd == 1): # going southeast
             newTile.trackChar = '\\'
             newTile.NW = True
             newTile.IsTrack = True
             oldTile.SE = True
         if (xd == 0 and yd == 1): # going south
             newTile.trackChar = '|'
             newTile.N = True
             newTile.IsTrack = True
             oldTile.S = True
         if (xd == -1 and yd == 1): # going southwest
             newTile.trackChar = '/'
             newTile.NE = True
             newTile.IsTrack = True
             oldTile.SW = True
         if (xd == -1 and yd == 0): # going west
             newTile.trackChar = '-'
             newTile.E = True
             newTile.IsTrack = True
             oldTile.W = True
         if (xd == -1 and yd == -1): # going northwest
             newTile.trackChar = '\\'
             newTile.SE = True
             newTile.IsTrack = True
             oldTile.NW = True
             
         # If either the old or new location has more than 2 connections, then it is a switch. Mark it as such.
         if newTile.CountConnections() == 3 and newTile.Switch is None:
             self.MakeSwitchAt(x, y)
             
         if oldTile.CountConnections() == 3 and oldTile.Switch is None:            
             self.MakeSwitchAt(self.x, self.y)
             
         # If this is on a current location, then assign it to that location            
         if (not self.CurrentLocation is None):
             self.CurrentLocation.AssignTile(newTile)            
             
         # Move along, using the member variables to store the previous location.
         self.x = x
         self.y = y
         x,y = libtcod.line_step()
         
     self.x = xTo
     self.y = yTo
Esempio n. 22
0
 def draw_vert(self, con, x, y, h):
   libtcod.line_init(x,y,x,h)
   (xc,yc) = (x,y)
   while((xc,yc) != (None,None)):
     libtcod.console_put_char(con,xc,yc,Gui._vert)
     (xc,yc) = libtcod.line_step()
Esempio n. 23
0
 def draw_hori(self, con, x, y, w):
   libtcod.line_init(x,y,w,y)
   (xc,yc) = (x,y)
   while((xc,yc) != (None,None)):
     libtcod.console_put_char(con,xc,yc,Gui._hori)
     (xc,yc) = libtcod.line_step()
Esempio n. 24
0
	# RENDER STUFF

	libtcod.console_clear(None)
	
	# libtcod.console_set_default_background(None, libtcod.red)
	# libtcod.console_set_default_foreground(None, libtcod.black)
	# render(board.parts)		# draw the devices
	# libtcod.console_set_default_background(None, libtcod.black)
	# libtcod.console_set_default_foreground(None, libtcod.white)
	# render(board.wires)		# draw the wires
	
	# render wires
	for w in board.wires:
		for (x0, y0), (x1, y1) in zip(w.nodes, w.nodes[1:]):
			libtcod.line_init(x0, y0, x1, y1)

			x, y = x0, y0
			while (not x is None):
				libtcod.console_set_char_background(None, x, y, libtcod.blue, flag=libtcod.BKGND_SET)
				x, y = libtcod.line_step()

	# render chips
	libtcod.console_set_default_background(None, libtcod.black)
	libtcod.console_set_default_foreground(None, libtcod.white)
	render(board.parts)

	# draw the mouse cursor
	libtcod.console_set_char_background(None, mouse.x/FONT_WIDTH, mouse.y/FONT_HEIGHT, libtcod.green, flag=libtcod.BKGND_SET)
	
	stats()
Esempio n. 25
0
def step_towards(from_xy, to_xy):
    libtcod.line_init(from_xy.x, from_xy.y, to_xy.x, to_xy.y)
    return Pos( *libtcod.line_step() )