Example #1
0
	def draw(self, x, y, color_filter):
		feature = self.feature_at(x, y)
		item = self.item_at(x, y)
		actor = self.actor_at(x, y)
		
		if self.console is None:
			self.init_console()
		
		if feature:
			libtcod.console_put_char_ex(self.console, feature.x, feature.y, feature.symbol, color_filter(feature.color_fore), color_filter(feature.color_back))
		
		if item:
			libtcod.console_set_fore(self.console, item.x, item.y, color_filter(item.color))
			libtcod.console_set_char(self.console, item.x, item.y, item.symbol)
		
		if actor:
			libtcod.console_set_fore(self.console, actor.x, actor.y, color_filter(actor.color))
			libtcod.console_set_char(self.console, actor.x, actor.y, actor.symbol)
Example #2
0
def draw_map(player):
	libtcod.console_set_background_color(0, libtcod.black)
	libtcod.console_rect(0, 0, 0, 80, 40, True, libtcod.BKGND_SET)
	
	for x, y in player.fov.get_visible():
		player.memory.update(x, y)
	
	libtcod.console_blit(player.memory.console, 0, 0, 80, 40, 0, 0, 0)
	
	for feature in player.fov.get_visible_features():
		libtcod.console_put_char_ex(0, feature.x, feature.y, feature.symbol, feature.color_fore, feature.color_back)
	
	for item in player.fov.get_visible_items():
		libtcod.console_set_fore(0, item.x, item.y, item.color)
		libtcod.console_set_char(0, item.x, item.y, item.symbol)
	
	for actor in player.fov.get_visible_actors():
		libtcod.console_set_fore(0, actor.x, actor.y, actor.color)
		libtcod.console_set_char(0, actor.x, actor.y, actor.symbol)
Example #3
0
	def on_apply(self):
		actor = self.actor
		
		messages.Basic('Your mind expands to fill the world around you.', actor, self.symbol)
		
		#for (x, y) in self.actor.map.floodfill(self.actor.x, self.actor.y, 1000, True):
		#	self.actor.memory.update(x, y, scry_color_filter)
		
		for i, points in enumerate(actor.map.iter_floodfill(actor.x, actor.y, 20, True)):
			for (x, y) in points:
				actor.memory.update(x, y, scry_color_filter)
			
			draw_map(actor)
			
			for (x, y) in points:
				libtcod.console_set_back(0, x, y, libtcod.violet)
				libtcod.console_set_fore(0, x, y, libtcod.light_violet)
			
			libtcod.console_flush()
			libtcod.sys_sleep_milli(50)
		
		return True
Example #4
0
 def render(self, console=False, export=False):
     
     if not self._displayWidth or not self._displayHeight:
         print ('ERROR: Display dimensions not set, can not render Map.')
         sys.exit()
     if (self.width < self._displayWidth or self.height < self._displayHeight):
         print ('ERROR: Map size smaller than display size.')
         sys.exit()
     
     
     if console == False:
         console = self._displayCon
     
     if export:
         _offsetX = 0
         _offsetY = 0
         zoom = 0
     else:
         _offsetX = self._offsetX
         _offsetY = self._offsetY
         zoom = self._zoomLevel
     
     
     for cy in range(0, tcod.console_get_height(console) ):
         for cx in range(0, tcod.console_get_width(console) ):
             
             mx = cx + _offsetX
             my = cy + _offsetY
             
             c = self.coords[mx][my]
             
             tcod.console_put_char_ex(
                 console, cx, cy, 
                 c.char, 
                 c.fg(), c.bg())
             
             
             if (self._displayOverlay != None):
                 #TODO: generate overlays once, and move this stuff to the display layer.
                 if (self._displayOverlay == self.OVERLAY_TEMP):
                     
                     bgOverlay = c.tempColor
                 
                 elif (self._displayOverlay == self.OVERLAY_SALT):
                     
                     bgOverlay = c.saltColor
                 
                 elif (self._displayOverlay == self.OVERLAY_RAIN):
                     
                     bgOverlay = c.rainColor
                 
                 elif (self._displayOverlay == self.OVERLAY_BIOME):
                     
                     bgOverlay = c.biome.overlayColor
                 
                 
                 tcod.console_set_back(console, cx, cy, bgOverlay, tcod.BKGND_ALPHA(0.8))
             
             
     if not export:
         
         if ( self._zoomLevel == 0):
             height = self.height
             width = self.width
         elif (self._zoomLevel == 1):
             height = self.height/self.zoomFactor # / self.zoomLevel, right??
             width = self.width/self.zoomFactor
         
         if (self._selectedY <= self._displayHeight/2):
             self._hudY = self._selectedY
         elif (self._selectedY >= height - self._displayHeight/2):
             self._hudY = \
                 self._displayHeight/2 + (self._selectedY - (height - self._displayHeight/2))
         
         if ( self.showCrosshair ):
             if (self._selectedX <= self._displayWidth/2):
                 self._hudX = self._selectedX
             elif (self._selectedX >= width - self._displayWidth/2):
                 self._hudX = self._displayWidth - (width - self._selectedX)
             
             tcod.console_put_char(console, self._hudX, self._hudY, 'X', tcod.BKGND_NONE)
             tcod.console_set_fore(console, self._hudX, self._hudY, tcod.Color(255, 0, 127))
         
         
         if (self._displayStats):
             self._printStats(console)
     
     return console
Example #5
0
def highlight_tile(x, y):
	# consider changing the hue to yellow instead of the color
	libtcod.console_set_back(0, x, y, libtcod.yellow)
	libtcod.console_set_fore(0, x, y, libtcod.dark_yellow)
Example #6
0
    def render(self, console=False, export=False):

        if not self._displayWidth or not self._displayHeight:
            print('ERROR: Display dimensions not set, can not render Map.')
            sys.exit()
        if (self.width < self._displayWidth
                or self.height < self._displayHeight):
            print('ERROR: Map size smaller than display size.')
            sys.exit()

        if console == False:
            console = self._displayCon

        if export:
            _offsetX = 0
            _offsetY = 0
            zoom = 0
        else:
            _offsetX = self._offsetX
            _offsetY = self._offsetY
            zoom = self._zoomLevel

        for cy in range(0, tcod.console_get_height(console)):
            for cx in range(0, tcod.console_get_width(console)):

                mx = cx + _offsetX
                my = cy + _offsetY

                c = self.coords[mx][my]

                tcod.console_put_char_ex(console, cx, cy, c.char, c.fg(),
                                         c.bg())

                if (self._displayOverlay != None):
                    #TODO: generate overlays once, and move this stuff to the display layer.
                    if (self._displayOverlay == self.OVERLAY_TEMP):

                        bgOverlay = c.tempColor

                    elif (self._displayOverlay == self.OVERLAY_SALT):

                        bgOverlay = c.saltColor

                    elif (self._displayOverlay == self.OVERLAY_RAIN):

                        bgOverlay = c.rainColor

                    elif (self._displayOverlay == self.OVERLAY_BIOME):

                        bgOverlay = c.biome.overlayColor

                    tcod.console_set_back(console, cx, cy, bgOverlay,
                                          tcod.BKGND_ALPHA(0.8))

        if not export:

            if (self._zoomLevel == 0):
                height = self.height
                width = self.width
            elif (self._zoomLevel == 1):
                height = self.height / self.zoomFactor  # / self.zoomLevel, right??
                width = self.width / self.zoomFactor

            if (self._selectedY <= self._displayHeight / 2):
                self._hudY = self._selectedY
            elif (self._selectedY >= height - self._displayHeight / 2):
                self._hudY = \
                    self._displayHeight/2 + (self._selectedY - (height - self._displayHeight/2))

            if (self.showCrosshair):
                if (self._selectedX <= self._displayWidth / 2):
                    self._hudX = self._selectedX
                elif (self._selectedX >= width - self._displayWidth / 2):
                    self._hudX = self._displayWidth - (width - self._selectedX)

                tcod.console_put_char(console, self._hudX, self._hudY, 'X',
                                      tcod.BKGND_NONE)
                tcod.console_set_fore(console, self._hudX, self._hudY,
                                      tcod.Color(255, 0, 127))

            if (self._displayStats):
                self._printStats(console)

        return console