Beispiel #1
0
def create():
	display.create_surface('background')
	display.create_surface('text')
	display.blit_background('background')
	
	roll()
	
	NOISE = tcod.noise_new(2, h=tcod.NOISE_DEFAULT_HURST, random=tcod.random_new())
	
	for y in range(0, constants.WINDOW_HEIGHT):
		for x in range(0, constants.WINDOW_WIDTH):
			_noise_values = [(ZOOM * x / (constants.WINDOW_WIDTH)),
			                 (ZOOM * y / (constants.WINDOW_HEIGHT))]
			_height = 1 - tcod.noise_get_turbulence(NOISE, _noise_values, tcod.NOISE_SIMPLEX)
			_dist_to_crosshair = 30
			_crosshair_mod = abs((_dist_to_crosshair - 1))
			
			if _height > .4:
				_height = (_height - .4) / .4
				_r, _g, _b = numbers.clip(30 * _height, 20, 255), 50 * _height, numbers.clip(30 * _height, 30, 255)
			
			else:
				_r, _g, _b = 20, 0, 30
			
			_r += 30# * _crosshair_mod
			
			if x < SIDEBAR_WIDTH:
				if y < 7:
					_r = numbers.interp(_r, .0, .4)
					_g = numbers.interp(_g, .0, .4)
					_b = numbers.interp(_b, .0, .4)
					
				elif y < 43:
					_r = numbers.interp(_r, .0, .6)
					_g = numbers.interp(_g, .0, .6)
					_b = numbers.interp(_b, .0, .6)
					
				elif y < constants.WINDOW_HEIGHT:
					_r = numbers.interp(_r, 1, .7)
					_g = numbers.interp(_g, 1, .7)
					_b = numbers.interp(_b, 1, .7)

				else:
					_r = (int(round(_r * 1.0)))
					_g = (int(round(_g * .2)))
					_b = (int(round(_b * .2)))
			
			if x > SIDEBAR_WIDTH + 3 and x < constants.WINDOW_WIDTH - 6:
				if y > 18 and y < 36:
					_r = numbers.interp(_r, 255, .1)
					_g = numbers.interp(_g, 255, .1)
					_b = numbers.interp(_b, 255, .1)
			
			if x > SIDEBAR_WIDTH + 3 and x < constants.WINDOW_WIDTH - 6:
				if y > 10 and y < 16:
					_r = numbers.interp(_r, .0, .4)
					_g = numbers.interp(_g, .0, .4)
					_b = numbers.interp(_b, .0, .4)
			
			display._set_char('background', x, y, ' ', (0, 0, 0), (_r, _g, _b))
Beispiel #2
0
def render_map(tile_map, width, height):
	_surface = display.get_surface('tiles')
	
	for y in range(height):
		for x in range(width):
			_tile = tile_map[y][x]
			
			display._set_char('tiles', _tile['x'], _tile['y'], _tile['c'], _tile['c_f'], _tile['c_b'])
Beispiel #3
0
def paint_map(initial=False):
    global SPARK_SIZE, REDRAW_RATE

    if REDRAW_RATE:
        REDRAW_RATE -= 1

        return

    REDRAW_RATE = 0.0

    if initial:
        _x_range = 0, constants.WINDOW_WIDTH
        _y_range = 0, constants.WINDOW_HEIGHT

    else:
        _x_range = 30, 50
        _y_range = 5, 20

    SPARK_SIZE = numbers.clip(SPARK_SIZE + random.uniform(-3, 3), 6.0, 12.0)

    for y in range(_y_range[0], _y_range[1]):
        for x in range(_x_range[0], _x_range[1]):
            _noise_values = [(ZOOM * x / (constants.WINDOW_WIDTH)),
                             (ZOOM * y / (constants.WINDOW_HEIGHT))]
            _height = 1 - tcod.noise_get_turbulence(NOISE, _noise_values,
                                                    tcod.NOISE_SIMPLEX)
            _dist_to_crosshair = numbers.clip(
                (abs(y - 12) *
                 (abs(x - 38))) / (SPARK_SIZE + random.uniform(-3.5, 1)), 0, 1)
            #_height *= _dist_to_crosshair

            _crosshair_mod = abs((_dist_to_crosshair - 1))

            #if not initial and not _crosshair_mod:
            #	continue

            if _height > .4:
                _height = (_height - .4) / .4
                _r, _g, _b = numbers.clip(30 * _height, 20,
                                          255), 50 * _height, numbers.clip(
                                              30 * _height, 30, 255)

            else:
                _r, _g, _b = 20, 0, 30
                #_height = 1 - (_height / .5)
                #_r, _g, _b = 60 * _height, 60 * _height, 100 * _height

            _r += 80 * _crosshair_mod

            display._set_char('background', x, y, ' ', (0, 0, 0), (_r, _g, _b))

    display.blit_background('background')
Beispiel #4
0
def paint_map(initial=False):
    global SPARK_SIZE, REDRAW_RATE

    if REDRAW_RATE:
        REDRAW_RATE -= 1

        return

    REDRAW_RATE = 0.0

    if initial:
        _x_range = 0, constants.WINDOW_WIDTH
        _y_range = 0, constants.WINDOW_HEIGHT

    else:
        _x_range = 30, 50
        _y_range = 5, 20

    SPARK_SIZE = numbers.clip(SPARK_SIZE + random.uniform(-3, 3), 6.0, 12.0)

    for y in range(_y_range[0], _y_range[1]):
        for x in range(_x_range[0], _x_range[1]):
            _noise_values = [(ZOOM * x / (constants.WINDOW_WIDTH)), (ZOOM * y / (constants.WINDOW_HEIGHT))]
            _height = 1 - tcod.noise_get_turbulence(NOISE, _noise_values, tcod.NOISE_SIMPLEX)
            _dist_to_crosshair = numbers.clip(
                (abs(y - 12) * (abs(x - 38))) / (SPARK_SIZE + random.uniform(-3.5, 1)), 0, 1
            )
            # _height *= _dist_to_crosshair

            _crosshair_mod = abs((_dist_to_crosshair - 1))

            # if not initial and not _crosshair_mod:
            # 	continue

            if _height > 0.4:
                _height = (_height - 0.4) / 0.4
                _r, _g, _b = numbers.clip(30 * _height, 20, 255), 50 * _height, numbers.clip(30 * _height, 30, 255)

            else:
                _r, _g, _b = 20, 0, 30
                # _height = 1 - (_height / .5)
                # _r, _g, _b = 60 * _height, 60 * _height, 100 * _height

            _r += 80 * _crosshair_mod

            display._set_char("background", x, y, " ", (0, 0, 0), (_r, _g, _b))

    display.blit_background("background")
Beispiel #5
0
def _tick_smoke(entity):
	_x, _y = movement.get_position(entity)
	_alpha = flags.get_flag(entity, 'alpha')
	_alpha_mode = flags.get_flag(entity, 'alpha_mode')
	_alpha_max = flags.get_flag(entity, 'alpha_max')
	_fore_color = flags.get_flag(entity, 'fore_color')
	_back_color = flags.get_flag(entity, 'back_color')
	_decay_mod = flags.get_flag(entity, 'decay')
	
	if _alpha_mode:
		_alpha -= random.uniform(.001 * _decay_mod, .005 * _decay_mod)
		
		if _alpha <= 0:
			display._set_char('tiles', _x, _y, ' ', (0, 0, 0), None)
			entities.delete_entity(entity)
			
			return
	
	else:
		_alpha += random.uniform(.01, .05)
		
		if _alpha > _alpha_max:
			_alpha_mode = 1
	
	_alpha = numbers.clip(_alpha, 0, 1)
	
	#entities.trigger_event(entity, 'set_char', char=random.choice(['*', '&', '%']))

	_color = list(display.get_color_at('tiles', _x, _y))
	_color[0] = numbers.interp_velocity(_color[0], _fore_color, _alpha)
	_color[1] = numbers.interp_velocity(_color[1], _back_color, _alpha)
	
	for c in range(len(_color)):
		for i in range(len(_color)):
			_color[c][i] = int((round(_color[c][i])))
	
	entities.trigger_event(entity, 'set_fore_color', color=_color[0])
	entities.trigger_event(entity, 'set_back_color', color=_color[1])
	
	entities.trigger_event(entity, 'set_flag', flag='alpha', value=_alpha)
	entities.trigger_event(entity, 'set_flag', flag='alpha_mode', value=_alpha_mode)
Beispiel #6
0
def create():
    display.create_surface('background')
    display.create_surface('text')
    display.blit_background('background')

    roll()

    NOISE = tcod.noise_new(2,
                           h=tcod.NOISE_DEFAULT_HURST,
                           random=tcod.random_new())

    for y in range(0, constants.WINDOW_HEIGHT):
        for x in range(0, constants.WINDOW_WIDTH):
            _noise_values = [(ZOOM * x / (constants.WINDOW_WIDTH)),
                             (ZOOM * y / (constants.WINDOW_HEIGHT))]
            _height = 1 - tcod.noise_get_turbulence(NOISE, _noise_values,
                                                    tcod.NOISE_SIMPLEX)
            _dist_to_crosshair = 30
            _crosshair_mod = abs((_dist_to_crosshair - 1))

            if _height > .4:
                _height = (_height - .4) / .4
                _r, _g, _b = numbers.clip(30 * _height, 20,
                                          255), 50 * _height, numbers.clip(
                                              30 * _height, 30, 255)

            else:
                _r, _g, _b = 20, 0, 30

            _r += 30  # * _crosshair_mod

            if x < SIDEBAR_WIDTH:
                if y < 7:
                    _r = numbers.interp(_r, .0, .4)
                    _g = numbers.interp(_g, .0, .4)
                    _b = numbers.interp(_b, .0, .4)

                elif y < 43:
                    _r = numbers.interp(_r, .0, .6)
                    _g = numbers.interp(_g, .0, .6)
                    _b = numbers.interp(_b, .0, .6)

                elif y < constants.WINDOW_HEIGHT:
                    _r = numbers.interp(_r, 1, .7)
                    _g = numbers.interp(_g, 1, .7)
                    _b = numbers.interp(_b, 1, .7)

                else:
                    _r = (int(round(_r * 1.0)))
                    _g = (int(round(_g * .2)))
                    _b = (int(round(_b * .2)))

            if x > SIDEBAR_WIDTH + 3 and x < constants.WINDOW_WIDTH - 6:
                if y > 18 and y < 36:
                    _r = numbers.interp(_r, 255, .1)
                    _g = numbers.interp(_g, 255, .1)
                    _b = numbers.interp(_b, 255, .1)

            if x > SIDEBAR_WIDTH + 3 and x < constants.WINDOW_WIDTH - 6:
                if y > 10 and y < 16:
                    _r = numbers.interp(_r, .0, .4)
                    _g = numbers.interp(_g, .0, .4)
                    _b = numbers.interp(_b, .0, .4)

            display._set_char('background', x, y, ' ', (0, 0, 0), (_r, _g, _b))
Beispiel #7
0
def create_map():
	_grid = world_strategy.MAP['grid']
	_color_map = world_strategy.MAP['color_map']
	_ownable_plots = set()
	_banned_plots = set()
	
	#Mountains
	_noise = tcod.noise_new(3)
	_zoom = 1.25
	_c_pos = constants.STRAT_MAP_WIDTH/2, constants.STRAT_MAP_HEIGHT/2
	_solids = set()
	
	for y in range(0, constants.STRAT_MAP_HEIGHT):
		for x in range(0, constants.STRAT_MAP_WIDTH):
			_m_x = x / constants.MAP_CELL_SPACE
			_m_y = y / constants.MAP_CELL_SPACE
			
			_m_x = numbers.clip(_m_x, 1, (constants.STRAT_MAP_WIDTH/constants.MAP_CELL_SPACE) - 2)
			_m_y = numbers.clip(_m_y, 1, (constants.STRAT_MAP_HEIGHT/constants.MAP_CELL_SPACE) - 2)
			_c_mod = numbers.float_distance(_c_pos, (x, y))/max([constants.STRAT_MAP_WIDTH/2, constants.STRAT_MAP_HEIGHT/2])
			_noise_values = [(_zoom * x / (constants.STRAT_MAP_WIDTH)),
					         (_zoom * y / (constants.STRAT_MAP_HEIGHT))]
			_height = tcod.noise_get_turbulence(_noise, _noise_values, tcod.NOISE_SIMPLEX) * _c_mod
			_char = ' '
			
			#Mountain
			if _height > .55:
				_color_map[x, y] = random.choice([constants.DARKER_GRAY_1,
				                                  constants.DARKER_GRAY_2,
				                                  constants.DARKER_GRAY_3])
				
				_grid[_m_x, _m_y]['is_ownable'] = False
				_banned_plots.add((_m_x, _m_y))
				
				_c_1 = int(round(_color_map[x, y][0] * (1.8 * _height)))
				_c_2 = int(round(_color_map[x, y][1] * (1.8 * _height)))
				_c_3 = int(round(_color_map[x, y][2] * (1.8 * _height)))
			
			else:
				_color_map[x, y] = random.choice([constants.FOREST_GREEN_1,
				                                  constants.FOREST_GREEN_2,
				                                  constants.FOREST_GREEN_3])
				
				_ownable_plots.add((_m_x, _m_y))

				if _height <= .2:
					_char = random.choice([',', '.', '\'', ' ' * (1 + (20 * int(round(_height))))])
				
				_height -= .1

				_c_1 = int(round(_color_map[x, y][0] * (.7 + _height * 2.8)))
				_c_2 = int(round(_color_map[x, y][1] * (1.0 + _height * .9)))
				_c_3 = int(round(_color_map[x, y][2] * (.75 + _height * 1.2)))
			
			display._set_char('map', x, y, _char, (int(round(_c_1 * .8)), int(round(_c_2 * .8)), int(round(_c_3 * .8))), (_c_1, _c_2, _c_3))
	
	_solids = [(x, y) for x, y in list(_banned_plots)]
	
	world_strategy.MAP['astar_map'] = pathfinding.setup(constants.STRAT_MAP_WIDTH/constants.MAP_CELL_SPACE,
	                                                    constants.STRAT_MAP_HEIGHT/constants.MAP_CELL_SPACE,
	                                                    _solids)
	
	return list(_ownable_plots - _banned_plots)
Beispiel #8
0
def char(x, y, amount):
	_color = list(display.get_color_at('tiles', x, y))
	_color[0] = numbers.interp_velocity(_color[0], random.choice([constants.DARKER_BLACK_1, constants.DARKER_BLACK_2, constants.DARKER_BLACK_3]), amount)
	_color[1] = numbers.interp_velocity(_color[1], random.choice([constants.DARKER_BLACK_1, constants.DARKER_BLACK_2, constants.DARKER_BLACK_3]), amount)
	
	display._set_char('tiles', x, y, random.choice([',', '.', '^']), _color[0], _color[1])