def shine(self): # shine light on environment; add light to lightmap assert (self.shone == False) # cannot shine if we already did self.shone = True rang = self.getLumens(self.lum) libtcod.map_compute_fov( # Get the tiles we can see rog.getfovmap(self.fovID), self.x, self.y, rang, light_walls=True, algo=libtcod.FOV_RESTRICTIVE) for x in range(max(0, self.x - rang), min(ROOMW, self.x + rang + 1)): for y in range(max(0, self.y - rang), min(ROOMH, self.y + rang + 1)): if (rog.in_range(self.x, self.y, x, y, rang) and libtcod.map_is_in_fov(rog.getfovmap(self.fovID), x, y)): dist = maths.dist(self.x, self.y, x, y) # F = L / 4 * pi * d^2 (formula for light dispersion) lux = self.lum // (12.5663706144 * (dist**2)) if lux: self.add_tile(x, y, lux) rog.tile_lighten(x, y, lux) # end for return True #success
def _draw_what_player_sees(self, pc): world=rog.world() seer=world.component_for_entity(pc, cmp.SenseSight) rang=seer.sight pos=world.component_for_entity(pc, cmp.Position) rend=world.component_for_entity(ent, cmp.Draw) for x in range( max(0, pc.x-rang), min(self.w, pc.x+rang+1) ): for y in range( max(0, pc.y-rang), min(self.h, pc.y+rang+1) ): canSee=False if not rog.in_range(pos.x,pos.y, x,y, rang): continue if not libtcod.map_is_in_fov(seer.fov_map, x,y): continue ent=self.thingat(x, y) if (self.get_light_value(x,y) == 0 and not rog.on(pc,NVISION) ): self._draw_silhouettes(pc, x,y, ent) continue if ent: libtcod.console_put_char( self.con_map_state, x,y, rend.char) libtcod.console_set_char_foreground( self.con_map_state, x,y, rend.color) self._apply_rendered_bgcol(x,y, ent) else: libtcod.console_put_char_ex(self.con_map_state, x,y, self.get_char(x, y), self.get_color(x, y), self.get_bgcolor(x, y))
def func(self): diameter = 7 radius = int(diameter/2) for i in range(diameter): for j in range(diameter): xx = self.x + i - radius yy = self.y + j - radius if not rog.in_range(self.x,self.y, xx,yy, radius): continue rog.create_fluid(FL_NAPALM, xx,yy, dice.roll(3)) rog.set_fire(xx,yy)
def deathFunc(ent): pos=rog.world().component_for_entity(ent, cmp.Position) diameter = 7 radius = int(diameter/2) for i in range(diameter): for j in range(diameter): xx = pos.x + i - radius yy = pos.y + j - radius if not rog.in_range(pos.x,pos.y, xx,yy, radius): continue rog.create_fluid(FL_NAPALM, xx,yy, dice.roll(3)) rog.set_fire(xx,yy)
def shine(self): # add light to the lightmap if (self.shone): # must unshine before shining again. print("ERROR: shine failed: shone==True") return False self.shone=True #get the tiles we can see and lighten them up libtcod.map_compute_fov( self.fov_map, self.x,self.y, self.brightness, light_walls = True, algo=libtcod.FOV_RESTRICTIVE) rang = self.brightness for x in range( max(0, self.x-rang), min(ROOMW, self.x+rang+1) ): for y in range( max(0, self.y-rang), min(ROOMH, self.y+rang+1) ): if ( rog.in_range(self.x,self.y, x,y, rang) and libtcod.map_is_in_fov(self.fov_map, x,y) ): dist=maths.dist(self.x,self.y, x,y) value=round(self.brightness - dist) if value > 0: self.add_tile(x,y, value ) rog.tile_lighten(x,y,value) return True #success