Example #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))
Example #2
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')
Example #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 > 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")
Example #4
0
def create():
	global MAP, FADER
	
	worlds.create('strategy')
	words.reset()
	
	display.create_surface('background')
	display.create_surface('map', width=constants.STRAT_MAP_WIDTH, height=constants.STRAT_MAP_HEIGHT)
	display.create_surface('map_markers', width=constants.STRAT_MAP_WIDTH, height=constants.STRAT_MAP_HEIGHT)
	display.create_surface('map_squads', width=constants.STRAT_MAP_WIDTH, height=constants.STRAT_MAP_HEIGHT)
	display.create_surface('map_path', width=constants.STRAT_MAP_WIDTH, height=constants.STRAT_MAP_HEIGHT)
	display.create_surface('ui_bar', width=constants.WINDOW_WIDTH, height=constants.WINDOW_HEIGHT-constants.STRAT_MAP_HEIGHT)
	display.fill_surface('ui_bar', (30, 30, 30))
	display.blit_background('background')
	
	register_input()
	
	entities.create_entity_group('life', static=True)
	entities.create_entity_group('items', static=True)
	entities.create_entity_group('factions', static=True)
	entities.create_entity_group('squads', static=True)
	entities.create_entity_group('systems')
	
	FADER = entities.create_entity()
	timers.register(FADER)
	fade_in()
	
	_grid = {}
	_color_map = {}
	
	MAP = {'grid': _grid,
	       'color_map': _color_map,
	       'astar_map': None,
	       'astar_weight_map': numpy.ones((constants.STRAT_MAP_HEIGHT/constants.MAP_CELL_SPACE,
	                                       constants.STRAT_MAP_WIDTH/constants.MAP_CELL_SPACE))}
	
	for x in range(constants.STRAT_MAP_WIDTH/constants.MAP_CELL_SPACE):
		for y in range(constants.STRAT_MAP_HEIGHT/constants.MAP_CELL_SPACE):
			_grid[x, y] = {'owned_by': None,
			               'is_ownable': False,
			               'squads': [],
			               'income': .025}
	
	worldgen.generate()
	
	unregister_input()
	world_action._start_battle(attacking_squads=[entities.get_entity_group('squads')[0]], defending_squads=[entities.get_entity_group('squads')[1]])
Example #5
0
def _start_battle(attacking_squads=[], defending_squads=[]):
	global FADER
	
	create()
	
	_width, _height, _node_grid, _node_sets, _weight_map, _tile_map, _solids, _fsl, _trees, _inside, _lights, _spawns = mapgen_arena.generate(200, 200)
	_zone = zones.create('swamps', _width, _height, _node_grid, _node_sets, _weight_map, _tile_map, _solids, _fsl, _trees, _inside, _lights, _spawns)
	_attacking_spawn_x, _attacking_spawn_y = random.choice(list(_spawns['attacking']))
	_attacking_spawn_positions = [(x, y) for x, y in shapes.circle(_attacking_spawn_x, _attacking_spawn_y, 5) if not (x, y) in _solids]
	
	for squad_id in attacking_squads:
		_squad = entities.get_entity(squad_id)
		
		for member_id in _squad['members']:
			_member = entities.get_entity(member_id)
			_spawn_x, _spawn_y = _attacking_spawn_positions.pop(random.randint(0, len(_attacking_spawn_positions) - 1))
			
			entities.trigger_event(_member, 'set_position', x=_spawn_x, y=_spawn_y)
	
	_defending_spawn_x, _defending_spawn_y = random.choice(list(_spawns['defending']))
	_attacking_spawn_positions = [(x, y) for x, y in shapes.circle(_defending_spawn_x, _defending_spawn_y, 5) if not (x, y) in _solids]
	
	for squad_id in defending_squads:
		_squad = entities.get_entity(squad_id)
		
		for member_id in _squad['members']:
			_member = entities.get_entity(member_id)
			_spawn_x, _spawn_y = _attacking_spawn_positions.pop(random.randint(0, len(_attacking_spawn_positions) - 1))
			
			entities.trigger_event(_member, 'set_position', x=_spawn_x, y=_spawn_y)

	zones.activate(_zone)
	
	FADER = entities.create_entity()
	timers.register(FADER)
	fade_in()
	
	display.blit_background('tiles')
	
	while loop():
		events.trigger_event('cleanup')
Example #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))
Example #7
0
def create():
    global MAP, FADER

    worlds.create('strategy')
    words.reset()

    display.create_surface('background')
    display.create_surface('map',
                           width=constants.STRAT_MAP_WIDTH,
                           height=constants.STRAT_MAP_HEIGHT)
    display.create_surface('map_markers',
                           width=constants.STRAT_MAP_WIDTH,
                           height=constants.STRAT_MAP_HEIGHT)
    display.create_surface('map_squads',
                           width=constants.STRAT_MAP_WIDTH,
                           height=constants.STRAT_MAP_HEIGHT)
    display.create_surface('map_path',
                           width=constants.STRAT_MAP_WIDTH,
                           height=constants.STRAT_MAP_HEIGHT)
    display.create_surface('ui_bar',
                           width=constants.WINDOW_WIDTH,
                           height=constants.WINDOW_HEIGHT -
                           constants.STRAT_MAP_HEIGHT)
    display.fill_surface('ui_bar', (30, 30, 30))
    display.blit_background('background')

    register_input()

    entities.create_entity_group('life', static=True)
    entities.create_entity_group('items', static=True)
    entities.create_entity_group('factions', static=True)
    entities.create_entity_group('squads', static=True)
    entities.create_entity_group('systems')

    FADER = entities.create_entity()
    timers.register(FADER)
    fade_in()

    _grid = {}
    _color_map = {}

    MAP = {
        'grid':
        _grid,
        'color_map':
        _color_map,
        'astar_map':
        None,
        'astar_weight_map':
        numpy.ones((constants.STRAT_MAP_HEIGHT / constants.MAP_CELL_SPACE,
                    constants.STRAT_MAP_WIDTH / constants.MAP_CELL_SPACE))
    }

    for x in range(constants.STRAT_MAP_WIDTH / constants.MAP_CELL_SPACE):
        for y in range(constants.STRAT_MAP_HEIGHT / constants.MAP_CELL_SPACE):
            _grid[x, y] = {
                'owned_by': None,
                'is_ownable': False,
                'squads': [],
                'income': .025
            }

    worldgen.generate()

    unregister_input()
    world_action._start_battle(
        attacking_squads=[entities.get_entity_group('squads')[0]],
        defending_squads=[entities.get_entity_group('squads')[1]])
Example #8
0
def _start_battle(attacking_squads=[], defending_squads=[]):
    global FADER

    create()

    _width, _height, _node_grid, _node_sets, _weight_map, _tile_map, _solids, _fsl, _trees, _inside, _lights, _spawns = mapgen_arena.generate(
        200, 200)
    _zone = zones.create('swamps', _width, _height, _node_grid, _node_sets,
                         _weight_map, _tile_map, _solids, _fsl, _trees,
                         _inside, _lights, _spawns)
    _attacking_spawn_x, _attacking_spawn_y = random.choice(
        list(_spawns['attacking']))
    _attacking_spawn_positions = [
        (x, y)
        for x, y in shapes.circle(_attacking_spawn_x, _attacking_spawn_y, 5)
        if not (x, y) in _solids
    ]

    for squad_id in attacking_squads:
        _squad = entities.get_entity(squad_id)

        for member_id in _squad['members']:
            _member = entities.get_entity(member_id)
            _spawn_x, _spawn_y = _attacking_spawn_positions.pop(
                random.randint(0,
                               len(_attacking_spawn_positions) - 1))

            entities.trigger_event(_member,
                                   'set_position',
                                   x=_spawn_x,
                                   y=_spawn_y)

    _defending_spawn_x, _defending_spawn_y = random.choice(
        list(_spawns['defending']))
    _attacking_spawn_positions = [
        (x, y)
        for x, y in shapes.circle(_defending_spawn_x, _defending_spawn_y, 5)
        if not (x, y) in _solids
    ]

    for squad_id in defending_squads:
        _squad = entities.get_entity(squad_id)

        for member_id in _squad['members']:
            _member = entities.get_entity(member_id)
            _spawn_x, _spawn_y = _attacking_spawn_positions.pop(
                random.randint(0,
                               len(_attacking_spawn_positions) - 1))

            entities.trigger_event(_member,
                                   'set_position',
                                   x=_spawn_x,
                                   y=_spawn_y)

    zones.activate(_zone)

    FADER = entities.create_entity()
    timers.register(FADER)
    fade_in()

    display.blit_background('tiles')

    while loop():
        events.trigger_event('cleanup')