Exemple #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))
Exemple #2
0
def create():
    global NOISE

    display.create_surface("background")

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

    paint_map(initial=True)
Exemple #3
0
def create():
    global NOISE

    display.create_surface('background')

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

    paint_map(initial=True)
Exemple #4
0
def activate(zone_id):
    global ACTIVE_ZONE

    ACTIVE_ZONE = zone_id

    _zone = ZONES[zone_id]
    _noise = tcod.noise_new(2)

    logging.info('Bringing zone \'%s\' online...' % _zone['name'])

    _zone['astar_map'] = pathfinding.setup(_zone['width'], _zone['height'],
                                           _zone['solids'])
    _zone['los_map'] = mapgen.generate_los_map(_zone['width'], _zone['height'],
                                               _zone['solids'])

    display.create_surface('tiles',
                           width=_zone['width'],
                           height=_zone['height'])

    maps.render_map(_zone['tile_map'], _zone['width'], _zone['height'])

    post_processing.start()

    events.register_event('logic', post_processing.tick_sun)

    _static_lighting = display.create_shader(_zone['width'],
                                             _zone['height'],
                                             start_offset=1)
    _zone['shaders'].append(
        post_processing.generate_shadow_map(_zone['width'], _zone['height'],
                                            _zone['solids'], _zone['trees'],
                                            _zone['inside']))
    _zone['shaders'].append(
        post_processing.generate_light_map(_zone['width'], _zone['height'],
                                           _zone['solids'], _zone['trees']))
    _zone['light_maps']['static_lighting'] = _static_lighting
    _zone['shaders'].append(_static_lighting)

    _noise = tcod.noise_new(3)
    _zoom = 2.0
    _zone['fader'] = display.create_shader(_zone['width'], _zone['height'])
    _shader = display.create_shader(_zone['width'], _zone['height'])

    for y in range(0, _zone['height']):
        for x in range(0, _zone['width']):
            if (x, y) in _zone['inside']:
                _height = .75
            else:
                _noise_values = [(_zoom * x / _zone['width']),
                                 (_zoom * y / _zone['height'])]
                _height = .35 + numbers.clip(
                    tcod.noise_get_turbulence(_noise, _noise_values,
                                              tcod.NOISE_SIMPLEX), .35, 1)

            _shader[0][y, x] = 1.3 * _height
            _shader[1][y, x] = 1.3 * _height
            _shader[2][y, x] = 1.1 * _height

    _zone['shaders'].append(_shader)

    for light in _zone['lights']:
        effects.light(light[0],
                      light[1],
                      light[2],
                      r=light[3],
                      g=light[4],
                      b=light[5],
                      light_map='static_lighting')

    #if not '--no-fx' in sys.argv:
    #	post_processing.run(time=8,
    #		                repeat=-1,
    #		                repeat_callback=lambda _: post_processing.post_process_clouds(constants.MAP_VIEW_WIDTH,
    #		                                                                              constants.MAP_VIEW_HEIGHT,
    #		                                                                              8,
    #		                                                                              _noise,
    #		                                                                              _zone['inside']))
    post_processing.run(
        time=0,
        repeat=-1,
        repeat_callback=lambda _: post_processing.post_process_lights())
    #post_processing.run(time=0,
    #                    repeat=-1,
    #                    repeat_callback=lambda _: post_processing.sunlight())

    camera.set_limits(0, 0, _zone['width'] - constants.MAP_VIEW_WIDTH,
                      _zone['height'] - constants.MAP_VIEW_HEIGHT)

    logging.info('Zone \'%s\' is online' % _zone['name'])
Exemple #5
0
def create():
    display.create_surface('text')
Exemple #6
0
def create():
    display.create_surface("text")
Exemple #7
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))
Exemple #8
0
def create():
	global QUIT
	
	QUIT = False
	
	entities.create_entity_group('tiles', static=True)
	entities.create_entity_group('bullets', static=True)
	entities.create_entity_group('node_grid', static=True)
	entities.create_entity_group('missions', static=True)
	entities.create_entity_group('ui')
	entities.create_entity_group('ui_menus')
	entities.create_entity_group('ui_dialogs')
	entities.create_entity_group('nodes')
	entities.create_entity_group('effects_freetick')
	entities.create_entity_group('ui_effects_freetick')
	entities.create_entity_group('contexts')
	entities.create_entity_group('effects', static=True)
	entities.create_entity_group('ui_effects', static=True)

	display.create_surface('life', width=constants.MAP_VIEW_WIDTH, height=constants.MAP_VIEW_HEIGHT)
	display.create_surface('items', width=constants.MAP_VIEW_WIDTH, height=constants.MAP_VIEW_HEIGHT)
	display.create_surface('nodes', width=constants.MAP_VIEW_WIDTH, height=constants.MAP_VIEW_HEIGHT)
	display.create_surface('node_grid', width=constants.MAP_VIEW_WIDTH, height=constants.MAP_VIEW_HEIGHT)
	display.create_surface('effects', width=constants.MAP_VIEW_WIDTH, height=constants.MAP_VIEW_HEIGHT)
	display.create_surface('ui_inventory', width=35, height=constants.MAP_VIEW_HEIGHT)
	display.create_surface('ui')
	display.create_surface('ui_menus')
	display.create_surface('ui_dialogs')
	
	display.set_clear_surface('effects', 'tiles')
	display.set_clear_surface('ui_menus', 'tiles')
	display.set_clear_surface('ui_dialogs', 'tiles')
	display.set_clear_surface('ui', 'tiles')
	display.set_clear_surface('life', 'tiles')
	display.set_clear_surface('nodes', 'tiles')
	display.set_clear_surface('effects', 'tiles')
	
	events.register_event('mouse_pressed', handle_mouse_pressed)
	events.register_event('mouse_moved', handle_mouse_movement)
	events.register_event('camera', camera.update)
	
	camera.set_pos(0, 0)
	
	ui_cursor.boot()
	ai.boot()
	ui_input.boot()
	ui_draw.boot()
	ui_menu.boot()
	ui_dialog.boot()
	ui_director.boot()
Exemple #9
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]])
Exemple #10
0
def activate(zone_id):
	global ACTIVE_ZONE
	
	ACTIVE_ZONE = zone_id
	
	_zone = ZONES[zone_id]
	_noise = tcod.noise_new(2)
	
	logging.info('Bringing zone \'%s\' online...' % _zone['name'])
	
	_zone['astar_map'] = pathfinding.setup(_zone['width'], _zone['height'], _zone['solids'])
	_zone['los_map'] = mapgen.generate_los_map(_zone['width'], _zone['height'], _zone['solids'])
	
	display.create_surface('tiles', width=_zone['width'], height=_zone['height'])
	
	maps.render_map(_zone['tile_map'], _zone['width'], _zone['height'])
	
	post_processing.start()
	
	events.register_event('logic', post_processing.tick_sun)
	
	_static_lighting = display.create_shader(_zone['width'], _zone['height'], start_offset=1)
	_zone['shaders'].append(post_processing.generate_shadow_map(_zone['width'], _zone['height'], _zone['solids'], _zone['trees'], _zone['inside']))
	_zone['shaders'].append(post_processing.generate_light_map(_zone['width'], _zone['height'], _zone['solids'], _zone['trees']))
	_zone['light_maps']['static_lighting'] = _static_lighting
	_zone['shaders'].append(_static_lighting)
	
	_noise = tcod.noise_new(3)
	_zoom = 2.0
	_zone['fader'] = display.create_shader(_zone['width'], _zone['height'])
	_shader = display.create_shader(_zone['width'], _zone['height'])
	
	for y in range(0, _zone['height']):
		for x in range(0, _zone['width']):
			if (x, y) in _zone['inside']:
				_height = .75
			else:
				_noise_values = [(_zoom * x / _zone['width']),
					             (_zoom * y / _zone['height'])]
				_height = .35 + numbers.clip(tcod.noise_get_turbulence(_noise, _noise_values, tcod.NOISE_SIMPLEX), .35, 1)
			
			_shader[0][y, x] = 1.3 * _height
			_shader[1][y, x] = 1.3 * _height
			_shader[2][y, x] = 1.1 * _height
	
	_zone['shaders'].append(_shader)
	
	for light in _zone['lights']:
		effects.light(light[0], light[1], light[2], r=light[3], g=light[4], b=light[5], light_map='static_lighting')
	
	#if not '--no-fx' in sys.argv:
	#	post_processing.run(time=8,
	#		                repeat=-1,
	#		                repeat_callback=lambda _: post_processing.post_process_clouds(constants.MAP_VIEW_WIDTH,
	#		                                                                              constants.MAP_VIEW_HEIGHT,
	#		                                                                              8,
	#		                                                                              _noise,
	#		                                                                              _zone['inside']))
	post_processing.run(time=0,
		                repeat=-1,
		                repeat_callback=lambda _: post_processing.post_process_lights())
	#post_processing.run(time=0,
	#                    repeat=-1,
	#                    repeat_callback=lambda _: post_processing.sunlight())
	
	camera.set_limits(0, 0, _zone['width']-constants.MAP_VIEW_WIDTH, _zone['height']-constants.MAP_VIEW_HEIGHT)
	
	logging.info('Zone \'%s\' is online' % _zone['name'])
Exemple #11
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]])
Exemple #12
0
def create():
    global QUIT

    QUIT = False

    entities.create_entity_group('tiles', static=True)
    entities.create_entity_group('bullets', static=True)
    entities.create_entity_group('node_grid', static=True)
    entities.create_entity_group('missions', static=True)
    entities.create_entity_group('ui')
    entities.create_entity_group('ui_menus')
    entities.create_entity_group('ui_dialogs')
    entities.create_entity_group('nodes')
    entities.create_entity_group('effects_freetick')
    entities.create_entity_group('ui_effects_freetick')
    entities.create_entity_group('contexts')
    entities.create_entity_group('effects', static=True)
    entities.create_entity_group('ui_effects', static=True)

    display.create_surface('life',
                           width=constants.MAP_VIEW_WIDTH,
                           height=constants.MAP_VIEW_HEIGHT)
    display.create_surface('items',
                           width=constants.MAP_VIEW_WIDTH,
                           height=constants.MAP_VIEW_HEIGHT)
    display.create_surface('nodes',
                           width=constants.MAP_VIEW_WIDTH,
                           height=constants.MAP_VIEW_HEIGHT)
    display.create_surface('node_grid',
                           width=constants.MAP_VIEW_WIDTH,
                           height=constants.MAP_VIEW_HEIGHT)
    display.create_surface('effects',
                           width=constants.MAP_VIEW_WIDTH,
                           height=constants.MAP_VIEW_HEIGHT)
    display.create_surface('ui_inventory',
                           width=35,
                           height=constants.MAP_VIEW_HEIGHT)
    display.create_surface('ui')
    display.create_surface('ui_menus')
    display.create_surface('ui_dialogs')

    display.set_clear_surface('effects', 'tiles')
    display.set_clear_surface('ui_menus', 'tiles')
    display.set_clear_surface('ui_dialogs', 'tiles')
    display.set_clear_surface('ui', 'tiles')
    display.set_clear_surface('life', 'tiles')
    display.set_clear_surface('nodes', 'tiles')
    display.set_clear_surface('effects', 'tiles')

    events.register_event('mouse_pressed', handle_mouse_pressed)
    events.register_event('mouse_moved', handle_mouse_movement)
    events.register_event('camera', camera.update)

    camera.set_pos(0, 0)

    ui_cursor.boot()
    ai.boot()
    ui_input.boot()
    ui_draw.boot()
    ui_menu.boot()
    ui_dialog.boot()
    ui_director.boot()