예제 #1
0
파일: nodes.py 프로젝트: witheld9/r3-tdw
def draw_path(entity, x_mod=0, y_mod=0):
	_last_x, _last_y = (0, 0)
	_node_ids = entity['node_grid']['path'][:]
	_action_time_max = 0
	_surface_width = display.get_surface('nodes')['width']
	_surface_height = display.get_surface('nodes')['height']
	
	for node_id in _node_ids:
		_node = entity['node_grid']['nodes'][node_id]
		
		if not _last_x:
			_last_x, _last_y = movement.get_position(entity)
		
		if (_last_x, _last_y) == (_node['node']['x'], _node['node']['y']):
			continue
		
		_node['node']['busy_pos'] = []
		
		if _node['node']['draw_path'] and not _node['node']['path']:
			_path = pathfinding.astar((_last_x, _last_y), (_node['node']['x'], _node['node']['y']), zones.get_active_astar_map(), zones.get_active_weight_map())
			
			if (_node['node']['x'], _node['node']['y']) in _path:
				_path.remove((_node['node']['x'], _node['node']['y']))
			
			_node['node']['path'] = _path
		
		_move_cost = 0
		for pos in _node['node']['path']:
			for node_id in _node_ids:
				_check_node = entity['node_grid']['nodes'][node_id]['node']
				
				if not _check_node['action_time']:
					continue
				
				if (_check_node['x'], _check_node['y']) == pos:
					_action_time_max = _check_node['action_time']
			
			if _action_time_max and _move_cost <= _action_time_max:
				_color_mod = int(round(200*numbers.clip(_move_cost/float(_action_time_max), .75, 1)))
				_color = (_color_mod, 0, 0)
				
				_node['node']['busy_pos'].append(pos)
			
			else:
				_color = (200, 200, 200)
			
			if _action_time_max:
				_move_cost += movement.get_move_cost(entity)
				
				if _move_cost >= _action_time_max:
					_action_time_max = 0
					_move_cost = 0
			
			if pos[0]-x_mod < 0 or pos[1]-y_mod < 0 or pos[0]-x_mod >= _surface_width or pos[1]-y_mod >= _surface_height:
				continue
			
			display.write_char('nodes', pos[0]-x_mod, pos[1]-y_mod, chr(177), fore_color=_color)
		
		if _node['node']['draw_path']:
			_last_x, _last_y = (_node['node']['x'], _node['node']['y'])
예제 #2
0
파일: ui_draw.py 프로젝트: penny64/r3-tdw
def draw_walk_path():
    _walk_path = ui_squad_control.WALK_PATH

    if not _walk_path:
        return

    _width = display.get_surface('life')['width']
    _height = display.get_surface('life')['height']
    _entity = ui_squad_control.get_selected_squad_member()
    _action_points = _entity['stats']['action_points']

    for x, y in _walk_path:
        _x = x - camera.X
        _y = y - camera.Y

        if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
            continue

        if _action_points < 0:
            _fore_color = (200, 0, 0)
            _char = chr(176)

        else:
            _fore_color = (200, 200, 200)
            _char = chr(177)

        display.write_char('nodes', _x, _y, _char, fore_color=_fore_color)
        _action_points -= constants.IDLE_COST
        _action_points -= movement.get_move_cost(_entity)
예제 #3
0
파일: ui_draw.py 프로젝트: witheld9/r3-tdw
def draw_walk_path():
	_walk_path = ui_squad_control.WALK_PATH
	
	if not _walk_path:
		return
	
	_width = display.get_surface('life')['width']
	_height = display.get_surface('life')['height']
	_entity = ui_squad_control.get_selected_squad_member()
	_action_points = _entity['stats']['action_points']
	
	for x, y in _walk_path:
		_x = x - camera.X
		_y = y - camera.Y
		
		if _x < 0 or _y < 0 or _x >= _width or _y >= _height:
			continue
		
		if _action_points < 0:
			_fore_color = (200, 0, 0)
			_char = chr(176)
		
		else:
			_fore_color = (200, 200, 200)
			_char = chr(177)
		
		display.write_char('nodes', _x, _y, _char, fore_color=_fore_color)
		_action_points -= constants.IDLE_COST
		_action_points -= movement.get_move_cost(_entity)
예제 #4
0
def draw_raid_path(path):
    _start_pos = path[0]

    for pos in path[1:]:
        _r_pos_1 = _start_pos[0] * constants.MAP_CELL_SPACE, _start_pos[1] * constants.MAP_CELL_SPACE
        _r_pos_2 = pos[0] * constants.MAP_CELL_SPACE, pos[1] * constants.MAP_CELL_SPACE
        _line = shapes.line(_r_pos_1, _r_pos_2)

        for x, y in _line[: len(_line) - 1]:
            display.write_char("map_path", x + constants.MAP_CELL_SPACE / 2, y + constants.MAP_CELL_SPACE / 2, chr(176))

        _start_pos = pos[:]
예제 #5
0
def draw():
	_entity = entities.get_entity(HAS_FOCUS)
	_x, _y = movement.get_position(_entity)
	_char = tile.get_char(_entity)
	
	for y in range(12):
		display.write_char('ui', 4, 4 + y + 1, ' ', back_color=(20, 20, 20))
		display.write_char('ui', 4 + 12, 4 + y, ' ', back_color=(40, 40, 40))
		display.write_char('ui', 4 + y, 4, ' ', back_color=(20, 20, 20))
		display.write_char('ui', 4 + y + 1, 4 + 12, ' ', back_color=(40, 40, 40))
	
	display.blit_surface_viewport('tiles', _x-5, _y-5, 11, 11, dx=5, dy=5)
	display.write_char('ui', 10, 10, _char, fore_color=_entity['tile']['fore_color'])
예제 #6
0
def loop():
    global UNSCRAMBLE_TO, WHITE_VALUE, SUBTITLE_COLOR

    for i in range(len(COMPANY_STRING)):
        if i > UNSCRAMBLE_TO:
            _char = random.choice(COMPANY_STRING)
            _gray_color = int(round(255 * (UNSCRAMBLE_TO / i))) + random.randint(-15, 15)
            _fore_color = (_gray_color, _gray_color, _gray_color)

        else:
            _char = COMPANY_STRING[i]
            _r = numbers.clip(WHITE_VALUE - random.randint(0, 90), 0, 255)
            _g = _r
            _b = _r

            _fore_color = _r, _g, _b

        display.write_char(
            "text",
            (constants.WINDOW_WIDTH / 2) + i - (len(COMPANY_STRING) / 2),
            (constants.WINDOW_HEIGHT / 2) - 1,
            _char,
            fore_color=_fore_color,
        )

    display.write_string(
        "text",
        (constants.WINDOW_WIDTH / 2) - (len(SUBTITLE_TEXT) / 2),
        (constants.WINDOW_HEIGHT / 2) + 1,
        SUBTITLE_TEXT,
        fore_color=(SUBTITLE_COLOR, SUBTITLE_COLOR, SUBTITLE_COLOR),
    )

    if UNSCRAMBLE_TO > 6:
        SUBTITLE_COLOR = numbers.clip(SUBTITLE_COLOR + 2, 0, 255)

    if UNSCRAMBLE_TO > 25:
        WHITE_VALUE -= 2

        SUBTITLE_COLOR = numbers.clip(SUBTITLE_COLOR - 6, 0, 255)

    if UNSCRAMBLE_TO > 38:
        return False

    display.blit_surface("text")

    events.trigger_event("draw")

    UNSCRAMBLE_TO += 0.1

    return True
예제 #7
0
def draw_raid_path(path):
    _start_pos = path[0]

    for pos in path[1:]:
        _r_pos_1 = _start_pos[0] * constants.MAP_CELL_SPACE, _start_pos[
            1] * constants.MAP_CELL_SPACE
        _r_pos_2 = pos[0] * constants.MAP_CELL_SPACE, pos[
            1] * constants.MAP_CELL_SPACE
        _line = shapes.line(_r_pos_1, _r_pos_2)

        for x, y in _line[:len(_line) - 1]:
            display.write_char('map_path', x + constants.MAP_CELL_SPACE / 2,
                               y + constants.MAP_CELL_SPACE / 2, chr(176))

        _start_pos = pos[:]
예제 #8
0
def loop():
    global UNSCRAMBLE_TO, WHITE_VALUE, SUBTITLE_COLOR

    for i in range(len(COMPANY_STRING)):
        if i > UNSCRAMBLE_TO:
            _char = random.choice(COMPANY_STRING)
            _gray_color = int(round(
                255 * (UNSCRAMBLE_TO / i))) + random.randint(-15, 15)
            _fore_color = (_gray_color, _gray_color, _gray_color)

        else:
            _char = COMPANY_STRING[i]
            _r = numbers.clip(WHITE_VALUE - random.randint(0, 90), 0, 255)
            _g = _r
            _b = _r

            _fore_color = _r, _g, _b

        display.write_char('text', (constants.WINDOW_WIDTH / 2) + i -
                           (len(COMPANY_STRING) / 2),
                           (constants.WINDOW_HEIGHT / 2) - 1,
                           _char,
                           fore_color=_fore_color)

    display.write_string(
        'text', (constants.WINDOW_WIDTH / 2) - (len(SUBTITLE_TEXT) / 2),
        (constants.WINDOW_HEIGHT / 2) + 1,
        SUBTITLE_TEXT,
        fore_color=(SUBTITLE_COLOR, SUBTITLE_COLOR, SUBTITLE_COLOR))

    if UNSCRAMBLE_TO > 6:
        SUBTITLE_COLOR = numbers.clip(SUBTITLE_COLOR + 2, 0, 255)

    if UNSCRAMBLE_TO > 25:
        WHITE_VALUE -= 2

        SUBTITLE_COLOR = numbers.clip(SUBTITLE_COLOR - 6, 0, 255)

    if UNSCRAMBLE_TO > 38:
        return False

    display.blit_surface('text')

    events.trigger_event('draw')

    UNSCRAMBLE_TO += .1

    return True
예제 #9
0
def draw_squads(selected_squad=None):
    for entity_id in entities.get_entity_group("squads"):
        _squad = entities.get_entity(entity_id)

        if _squad["faction"] == "Terrorists":
            continue

        _x, _y = movement.get_position(_squad)
        _r_x = (_x * constants.MAP_CELL_SPACE) + constants.MAP_CELL_SPACE / 2
        _r_y = (_y * constants.MAP_CELL_SPACE) + constants.MAP_CELL_SPACE / 2
        _fore_color = (200, 200, 200)

        if selected_squad == entity_id:
            if time.time() % 1 >= 0.5:
                _fore_color = (100, 150, 100)

        display.write_char("map_squads", _r_x, _r_y, "S", fore_color=_fore_color)
예제 #10
0
def draw_squads(selected_squad=None):
    for entity_id in entities.get_entity_group('squads'):
        _squad = entities.get_entity(entity_id)

        if _squad['faction'] == 'Terrorists':
            continue

        _x, _y = movement.get_position(_squad)
        _r_x = (_x * constants.MAP_CELL_SPACE) + constants.MAP_CELL_SPACE / 2
        _r_y = (_y * constants.MAP_CELL_SPACE) + constants.MAP_CELL_SPACE / 2
        _fore_color = (200, 200, 200)

        if selected_squad == entity_id:
            if time.time() % 1 >= .5:
                _fore_color = (100, 150, 100)

        display.write_char('map_squads',
                           _r_x,
                           _r_y,
                           'S',
                           fore_color=_fore_color)
예제 #11
0
def draw():
    _entity = entities.get_entity(HAS_FOCUS)
    _x, _y = movement.get_position(_entity)
    _char = tile.get_char(_entity)

    for y in range(12):
        display.write_char('ui', 4, 4 + y + 1, ' ', back_color=(20, 20, 20))
        display.write_char('ui', 4 + 12, 4 + y, ' ', back_color=(40, 40, 40))
        display.write_char('ui', 4 + y, 4, ' ', back_color=(20, 20, 20))
        display.write_char('ui',
                           4 + y + 1,
                           4 + 12,
                           ' ',
                           back_color=(40, 40, 40))

    display.blit_surface_viewport('tiles', _x - 5, _y - 5, 11, 11, dx=5, dy=5)
    display.write_char('ui',
                       10,
                       10,
                       _char,
                       fore_color=_entity['tile']['fore_color'])
예제 #12
0
파일: nodes.py 프로젝트: penny64/r3-tdw
def draw_path(entity, x_mod=0, y_mod=0):
    _last_x, _last_y = (0, 0)
    _node_ids = entity['node_grid']['path'][:]
    _action_time_max = 0
    _surface_width = display.get_surface('nodes')['width']
    _surface_height = display.get_surface('nodes')['height']

    for node_id in _node_ids:
        _node = entity['node_grid']['nodes'][node_id]

        if not _last_x:
            _last_x, _last_y = movement.get_position(entity)

        if (_last_x, _last_y) == (_node['node']['x'], _node['node']['y']):
            continue

        _node['node']['busy_pos'] = []

        if _node['node']['draw_path'] and not _node['node']['path']:
            _path = pathfinding.astar((_last_x, _last_y),
                                      (_node['node']['x'], _node['node']['y']),
                                      zones.get_active_astar_map(),
                                      zones.get_active_weight_map())

            if (_node['node']['x'], _node['node']['y']) in _path:
                _path.remove((_node['node']['x'], _node['node']['y']))

            _node['node']['path'] = _path

        _move_cost = 0
        for pos in _node['node']['path']:
            for node_id in _node_ids:
                _check_node = entity['node_grid']['nodes'][node_id]['node']

                if not _check_node['action_time']:
                    continue

                if (_check_node['x'], _check_node['y']) == pos:
                    _action_time_max = _check_node['action_time']

            if _action_time_max and _move_cost <= _action_time_max:
                _color_mod = int(
                    round(200 * numbers.clip(
                        _move_cost / float(_action_time_max), .75, 1)))
                _color = (_color_mod, 0, 0)

                _node['node']['busy_pos'].append(pos)

            else:
                _color = (200, 200, 200)

            if _action_time_max:
                _move_cost += movement.get_move_cost(entity)

                if _move_cost >= _action_time_max:
                    _action_time_max = 0
                    _move_cost = 0

            if pos[0] - x_mod < 0 or pos[1] - y_mod < 0 or pos[
                    0] - x_mod >= _surface_width or pos[
                        1] - y_mod >= _surface_height:
                continue

            display.write_char('nodes',
                               pos[0] - x_mod,
                               pos[1] - y_mod,
                               chr(177),
                               fore_color=_color)

        if _node['node']['draw_path']:
            _last_x, _last_y = (_node['node']['x'], _node['node']['y'])
예제 #13
0
def draw_map_grid(selected_grid=None, fade=1.0):
    _shader = []
    _shader.append(
        numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH),
                    dtype=numpy.float))
    _shader.append(
        numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH),
                    dtype=numpy.float))
    _shader.append(
        numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH),
                    dtype=numpy.float))

    _shader[0] += 1.35 * fade
    _shader[1] += 1.35 * fade
    _shader[2] += 1.25 * fade

    display.apply_surface_shader('map', _shader, constants.STRAT_MAP_WIDTH,
                                 constants.STRAT_MAP_HEIGHT)

    display.blit_surface_viewport('map', 0, 0, constants.STRAT_MAP_WIDTH,
                                  constants.STRAT_MAP_HEIGHT)

    for x in range(constants.STRAT_MAP_WIDTH / constants.MAP_CELL_SPACE):
        for y in range(constants.STRAT_MAP_HEIGHT / constants.MAP_CELL_SPACE):
            _tile = world_strategy.MAP['grid'][x, y]

            if x == controls.get_mouse_pos(
            )[0] / constants.MAP_CELL_SPACE and y == controls.get_mouse_pos(
            )[1] / constants.MAP_CELL_SPACE:
                _hover = True

            else:
                _hover = False

            for _x in range(constants.MAP_CELL_SPACE):
                for _y in range(constants.MAP_CELL_SPACE):
                    _d_x = (x * constants.MAP_CELL_SPACE) + _x
                    _d_y = (y * constants.MAP_CELL_SPACE) + _y
                    _back_color = None

                    if _tile['is_ownable']:
                        if _tile['owned_by'] == 'Terrorists':
                            _fore_color = (200, 0, 0)
                            _back_color = (125, 0, 0)

                        elif _tile['owned_by'] == 'Rogues':
                            _fore_color = (0, 200, 0)
                            _back_color = (0, 125, 0)

                        else:
                            _fore_color = (180, 180, 180)
                            _back_color = (100, 100, 100)

                        if (x, y) == selected_grid:
                            _fore_color = int(round(
                                _fore_color[0] * 1.2)), int(
                                    round(_fore_color[1] * 1.2)), int(
                                        round(_fore_color[2] * 1.2))
                            _back_color = int(round(
                                _back_color[0] * 1.2)), int(
                                    round(_back_color[1] * 1.2)), int(
                                        round(_back_color[2] * 1.2))

                        if not _x + _y:
                            if _hover or (x, y) == selected_grid:
                                _char = chr(201)
                                _fore_color = (255, 255, 255)

                            else:
                                _char = chr(218)

                        elif _x == constants.MAP_CELL_SPACE - 1 and not _y:
                            if _hover or (x, y) == selected_grid:
                                _char = chr(187)
                                _fore_color = (255, 255, 255)

                            else:
                                _char = chr(191)

                        elif not _x and _y == constants.MAP_CELL_SPACE - 1:
                            if _hover or (x, y) == selected_grid:
                                _char = chr(200)
                                _fore_color = (255, 255, 255)

                            else:
                                _char = chr(192)

                        elif _x + _y == (constants.MAP_CELL_SPACE - 1) * 2:
                            if _hover or (x, y) == selected_grid:
                                _char = chr(188)
                                _fore_color = (255, 255, 255)

                            else:
                                _char = chr(217)

                        elif _y > 0 and _y < constants.MAP_CELL_SPACE - 1 and (
                                not _x or _x == constants.MAP_CELL_SPACE - 1):
                            _char = chr(179)

                        elif _x > 0 and _x < constants.MAP_CELL_SPACE - 1 and (
                                not _y or _y == constants.MAP_CELL_SPACE - 1):
                            _char = chr(196)

                        else:
                            _char = '.'

                        display.write_char('map_markers',
                                           _d_x,
                                           _d_y,
                                           _char,
                                           fore_color=_fore_color,
                                           back_color=_back_color)

                    else:
                        if _hover or (x, y) == selected_grid:
                            if not _x + _y:
                                _char = chr(201)

                            elif _x == constants.MAP_CELL_SPACE - 1 and not _y:
                                _char = chr(187)

                            elif not _x and _y == constants.MAP_CELL_SPACE - 1:
                                _char = chr(200)

                            elif _x + _y == (constants.MAP_CELL_SPACE - 1) * 2:
                                _char = chr(188)

                            else:
                                _char = ' '

                            _color = display.get_color_at('map', _d_x, _d_y)[1]

                            display.write_char(
                                'map_markers',
                                _d_x,
                                _d_y,
                                _char,
                                back_color=(int(round(_color[0] * 1.4)),
                                            int(round(_color[1] * 1.4)),
                                            int(round(_color[2] * 1.4))))
예제 #14
0
def draw_map_grid(selected_grid=None, fade=1.0):
    _shader = []
    _shader.append(numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float))
    _shader.append(numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float))
    _shader.append(numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float))

    _shader[0] += 1.35 * fade
    _shader[1] += 1.35 * fade
    _shader[2] += 1.25 * fade

    display.apply_surface_shader("map", _shader, constants.STRAT_MAP_WIDTH, constants.STRAT_MAP_HEIGHT)

    display.blit_surface_viewport("map", 0, 0, constants.STRAT_MAP_WIDTH, constants.STRAT_MAP_HEIGHT)

    for x in range(constants.STRAT_MAP_WIDTH / constants.MAP_CELL_SPACE):
        for y in range(constants.STRAT_MAP_HEIGHT / constants.MAP_CELL_SPACE):
            _tile = world_strategy.MAP["grid"][x, y]

            if (
                x == controls.get_mouse_pos()[0] / constants.MAP_CELL_SPACE
                and y == controls.get_mouse_pos()[1] / constants.MAP_CELL_SPACE
            ):
                _hover = True

            else:
                _hover = False

            for _x in range(constants.MAP_CELL_SPACE):
                for _y in range(constants.MAP_CELL_SPACE):
                    _d_x = (x * constants.MAP_CELL_SPACE) + _x
                    _d_y = (y * constants.MAP_CELL_SPACE) + _y
                    _back_color = None

                    if _tile["is_ownable"]:
                        if _tile["owned_by"] == "Terrorists":
                            _fore_color = (200, 0, 0)
                            _back_color = (125, 0, 0)

                        elif _tile["owned_by"] == "Rogues":
                            _fore_color = (0, 200, 0)
                            _back_color = (0, 125, 0)

                        else:
                            _fore_color = (180, 180, 180)
                            _back_color = (100, 100, 100)

                        if (x, y) == selected_grid:
                            _fore_color = (
                                int(round(_fore_color[0] * 1.2)),
                                int(round(_fore_color[1] * 1.2)),
                                int(round(_fore_color[2] * 1.2)),
                            )
                            _back_color = (
                                int(round(_back_color[0] * 1.2)),
                                int(round(_back_color[1] * 1.2)),
                                int(round(_back_color[2] * 1.2)),
                            )

                        if not _x + _y:
                            if _hover or (x, y) == selected_grid:
                                _char = chr(201)
                                _fore_color = (255, 255, 255)

                            else:
                                _char = chr(218)

                        elif _x == constants.MAP_CELL_SPACE - 1 and not _y:
                            if _hover or (x, y) == selected_grid:
                                _char = chr(187)
                                _fore_color = (255, 255, 255)

                            else:
                                _char = chr(191)

                        elif not _x and _y == constants.MAP_CELL_SPACE - 1:
                            if _hover or (x, y) == selected_grid:
                                _char = chr(200)
                                _fore_color = (255, 255, 255)

                            else:
                                _char = chr(192)

                        elif _x + _y == (constants.MAP_CELL_SPACE - 1) * 2:
                            if _hover or (x, y) == selected_grid:
                                _char = chr(188)
                                _fore_color = (255, 255, 255)

                            else:
                                _char = chr(217)

                        elif (
                            _y > 0
                            and _y < constants.MAP_CELL_SPACE - 1
                            and (not _x or _x == constants.MAP_CELL_SPACE - 1)
                        ):
                            _char = chr(179)

                        elif (
                            _x > 0
                            and _x < constants.MAP_CELL_SPACE - 1
                            and (not _y or _y == constants.MAP_CELL_SPACE - 1)
                        ):
                            _char = chr(196)

                        else:
                            _char = "."

                        display.write_char(
                            "map_markers", _d_x, _d_y, _char, fore_color=_fore_color, back_color=_back_color
                        )

                    else:
                        if _hover or (x, y) == selected_grid:
                            if not _x + _y:
                                _char = chr(201)

                            elif _x == constants.MAP_CELL_SPACE - 1 and not _y:
                                _char = chr(187)

                            elif not _x and _y == constants.MAP_CELL_SPACE - 1:
                                _char = chr(200)

                            elif _x + _y == (constants.MAP_CELL_SPACE - 1) * 2:
                                _char = chr(188)

                            else:
                                _char = " "

                            _color = display.get_color_at("map", _d_x, _d_y)[1]

                            display.write_char(
                                "map_markers",
                                _d_x,
                                _d_y,
                                _char,
                                back_color=(
                                    int(round(_color[0] * 1.4)),
                                    int(round(_color[1] * 1.4)),
                                    int(round(_color[2] * 1.4)),
                                ),
                            )
예제 #15
0
def draw():
    #Title
    _i = 0
    _dst_x = 9999

    for c in TEXT[0]:
        _alpha = numbers.clip(
            FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1)
        _dx = ((constants.WINDOW_WIDTH / 2) - (len(''.join(TEXT)) / 2)) + _i

        if _dx < _dst_x:
            _dst_x = _dx

    _batch = display.create_batch(len(TEXT[0]), 1, _dst_x, 12)

    _i = 0
    for c in TEXT[0]:
        _alpha = numbers.clip(
            FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1)

        display.write_char_batch(
            _batch,
            ((constants.WINDOW_WIDTH / 2) - (len(''.join(TEXT)) / 2)) + _i,
            12,
            c,
            fore_color=(200 * _alpha, 200 * _alpha, 200 * _alpha))

        _i += 1

    display.draw_batch(_batch, 'text')

    _i = 0
    for c in TEXT[1]:
        _alpha = numbers.clip(
            FADE_ALPHA * numbers.clip(18 - _i, 0, 18) / SPARK_SIZE, 0, 1)
        display.write_char('text', ((constants.WINDOW_WIDTH / 2) -
                                    (len(TEXT[1]) / 2)) + _i,
                           13,
                           c.upper(),
                           fore_color=(200 * _alpha, 60 * _alpha, 80 * _alpha))

        _i += 1

    #Menu
    _i = 0
    for item in [('Continue', False), ('New', True), ('Quit', True)]:
        if item[1]:
            _fore_color = (200 * FADE_ALPHA, 200 * FADE_ALPHA,
                           200 * FADE_ALPHA)

        else:
            _fore_color = (100 * FADE_ALPHA, 100 * FADE_ALPHA,
                           100 * FADE_ALPHA)

        if MENU_ITEM_SELECTED == _i:
            _text = '> %s <' % item[0]

        else:
            _text = item[0]

        display.write_string('text',
                             (constants.WINDOW_WIDTH / 2) - (len(_text) / 2),
                             18 + _i,
                             _text,
                             fore_color=_fore_color)

        _i += 1

    paint_map()

    display.blit_surface_viewport('background', 0, 0, constants.MAP_VIEW_WIDTH,
                                  constants.MAP_VIEW_HEIGHT)
    display.blit_surface('text')
예제 #16
0
def draw():
	_x = 3
	_y_mod = 0
	_total_money = 0
	
	display.write_string('text', (SIDEBAR_WIDTH / 2) - (len(TITLE) / 2), 3, TITLE, fore_color=(255, 255, 255))
	
	for squad_member in HIRED_MEMBERS:
		_y = 10 + _y_mod
		_name = squad_member['name']
		
		display.write_string('text', _x, _y - 2, _name, fore_color=(255, 255, 255))
		display.write_string('text', _x, _y - 1, squad_member['skill_focus'].title() + ' ' * (len(_name) - len(squad_member['skill_focus'])), fore_color=(180, 180, 180), back_color=(40, 40, 40))
		
		for stat in SKILL_NAMES:
			_r = int(round(220 * (1 - (squad_member[stat] / 75.0))))
			_g = int(round(250 * (squad_member[stat] / 75.0)))
			
			display.write_string('text', _x, _y + 1, '%s' % stat.upper())
			display.write_string('text', _x + len(stat), _y + 1, '.' * (15 - len(stat)), fore_color=(80, 80, 80))
			display.write_string('text', _x + 15, _y + 1, '%s' % squad_member[stat], fore_color=(_r, _g, 0))
			
			_y += 1
	
		display.write_string('text', _x, _y + 2, 'Pay: ')
		display.write_string('text', _x + 6, _y + 2, '$%.2f' % squad_member['pay'], fore_color=(0, 200, 0), back_color=(0, 40, 0))
		display.write_string('text', _x + 6 + len('$%.2f' % squad_member['pay']) + 0, _y + 2, '/week', fore_color=(150, 150, 150), back_color=(0, 0, 0))
		
		_x += 20
		
		if _x > 40:
			_x = 3
			_y_mod += 12
		
		_total_money += squad_member['pay']
	
	#for y in range(12, 14):
		#for x in range(SIDEBAR_WIDTH + 10, constants.WINDOW_WIDTH - 14):
	display.write_string('text', SIDEBAR_WIDTH + 10, 12, 'Operation', fore_color=(255, 255, 255))
	display.write_string('text', SIDEBAR_WIDTH + 10, 13, 'Dark Wing', fore_color=(255, 255, 255))
	
	for y in range(20, 28):
		for x in range(SIDEBAR_WIDTH + 10, constants.WINDOW_WIDTH - 14):
			display.write_char('text', x, y, '#', fore_color=(255, 255, 255))
	
	display.write_string('text', SIDEBAR_WIDTH + 5, 29, 'No contact outside the town.', fore_color=(255, 255, 255))
	
	_i = 0
	
	for feat in FEATS:
		display.write_string('text', 3, _y + 5 + _i, feat[0][0], fore_color=feat[0][1])
		display.write_string('text', 3 + len(feat[0][0]), _y + 5 + _i, '- ' + feat[1], fore_color=(255, 255, 255))
		
		_i += 1
	
	display.write_string('text', 3, constants.WINDOW_HEIGHT - 4, '<Space>', fore_color=(255, 255, 255))
	display.write_string('text', 10, constants.WINDOW_HEIGHT - 4, ' - Reroll', fore_color=(200, 200, 200))
	
	display.write_string('text', 3, constants.WINDOW_HEIGHT - 5, '<Enter>', fore_color=(255, 255, 255))
	display.write_string('text', 10, constants.WINDOW_HEIGHT - 5, ' - Accept', fore_color=(200, 200, 200))
	
	display.write_string('text', 3, constants.WINDOW_HEIGHT - 2, 'Total Cost: ')
	display.write_string('text', 15, constants.WINDOW_HEIGHT - 2, '$%.2f' % _total_money, fore_color=(0, 200, 0), back_color=(0, 40, 0))
	
	display.blit_surface_viewport('background', 0, 0, constants.WINDOW_WIDTH, constants.WINDOW_HEIGHT)
	display.blit_surface('text')
예제 #17
0
def draw():
    # Title
    _i = 0
    _dst_x = 9999

    for c in TEXT[0]:
        _alpha = numbers.clip(FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1)
        _dx = ((constants.WINDOW_WIDTH / 2) - (len("".join(TEXT)) / 2)) + _i

        if _dx < _dst_x:
            _dst_x = _dx

    _batch = display.create_batch(len(TEXT[0]), 1, _dst_x, 12)

    _i = 0
    for c in TEXT[0]:
        _alpha = numbers.clip(FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1)

        display.write_char_batch(
            _batch,
            ((constants.WINDOW_WIDTH / 2) - (len("".join(TEXT)) / 2)) + _i,
            12,
            c,
            fore_color=(200 * _alpha, 200 * _alpha, 200 * _alpha),
        )

        _i += 1

    display.draw_batch(_batch, "text")

    _i = 0
    for c in TEXT[1]:
        _alpha = numbers.clip(FADE_ALPHA * numbers.clip(18 - _i, 0, 18) / SPARK_SIZE, 0, 1)
        display.write_char(
            "text",
            ((constants.WINDOW_WIDTH / 2) - (len(TEXT[1]) / 2)) + _i,
            13,
            c.upper(),
            fore_color=(200 * _alpha, 60 * _alpha, 80 * _alpha),
        )

        _i += 1

        # Menu
    _i = 0
    for item in [("Continue", False), ("New", True), ("Quit", True)]:
        if item[1]:
            _fore_color = (200 * FADE_ALPHA, 200 * FADE_ALPHA, 200 * FADE_ALPHA)

        else:
            _fore_color = (100 * FADE_ALPHA, 100 * FADE_ALPHA, 100 * FADE_ALPHA)

        if MENU_ITEM_SELECTED == _i:
            _text = "> %s <" % item[0]

        else:
            _text = item[0]

        display.write_string(
            "text", (constants.WINDOW_WIDTH / 2) - (len(_text) / 2), 18 + _i, _text, fore_color=_fore_color
        )

        _i += 1

    paint_map()

    display.blit_surface_viewport("background", 0, 0, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)
    display.blit_surface("text")
예제 #18
0
def draw():
    _x = 3
    _y_mod = 0
    _total_money = 0

    display.write_string('text', (SIDEBAR_WIDTH / 2) - (len(TITLE) / 2),
                         3,
                         TITLE,
                         fore_color=(255, 255, 255))

    for squad_member in HIRED_MEMBERS:
        _y = 10 + _y_mod
        _name = squad_member['name']

        display.write_string('text',
                             _x,
                             _y - 2,
                             _name,
                             fore_color=(255, 255, 255))
        display.write_string('text',
                             _x,
                             _y - 1,
                             squad_member['skill_focus'].title() + ' ' *
                             (len(_name) - len(squad_member['skill_focus'])),
                             fore_color=(180, 180, 180),
                             back_color=(40, 40, 40))

        for stat in SKILL_NAMES:
            _r = int(round(220 * (1 - (squad_member[stat] / 75.0))))
            _g = int(round(250 * (squad_member[stat] / 75.0)))

            display.write_string('text', _x, _y + 1, '%s' % stat.upper())
            display.write_string('text',
                                 _x + len(stat),
                                 _y + 1,
                                 '.' * (15 - len(stat)),
                                 fore_color=(80, 80, 80))
            display.write_string('text',
                                 _x + 15,
                                 _y + 1,
                                 '%s' % squad_member[stat],
                                 fore_color=(_r, _g, 0))

            _y += 1

        display.write_string('text', _x, _y + 2, 'Pay: ')
        display.write_string('text',
                             _x + 6,
                             _y + 2,
                             '$%.2f' % squad_member['pay'],
                             fore_color=(0, 200, 0),
                             back_color=(0, 40, 0))
        display.write_string('text',
                             _x + 6 + len('$%.2f' % squad_member['pay']) + 0,
                             _y + 2,
                             '/week',
                             fore_color=(150, 150, 150),
                             back_color=(0, 0, 0))

        _x += 20

        if _x > 40:
            _x = 3
            _y_mod += 12

        _total_money += squad_member['pay']

    #for y in range(12, 14):
    #for x in range(SIDEBAR_WIDTH + 10, constants.WINDOW_WIDTH - 14):
    display.write_string('text',
                         SIDEBAR_WIDTH + 10,
                         12,
                         'Operation',
                         fore_color=(255, 255, 255))
    display.write_string('text',
                         SIDEBAR_WIDTH + 10,
                         13,
                         'Dark Wing',
                         fore_color=(255, 255, 255))

    for y in range(20, 28):
        for x in range(SIDEBAR_WIDTH + 10, constants.WINDOW_WIDTH - 14):
            display.write_char('text', x, y, '#', fore_color=(255, 255, 255))

    display.write_string('text',
                         SIDEBAR_WIDTH + 5,
                         29,
                         'No contact outside the town.',
                         fore_color=(255, 255, 255))

    _i = 0

    for feat in FEATS:
        display.write_string('text',
                             3,
                             _y + 5 + _i,
                             feat[0][0],
                             fore_color=feat[0][1])
        display.write_string('text',
                             3 + len(feat[0][0]),
                             _y + 5 + _i,
                             '- ' + feat[1],
                             fore_color=(255, 255, 255))

        _i += 1

    display.write_string('text',
                         3,
                         constants.WINDOW_HEIGHT - 4,
                         '<Space>',
                         fore_color=(255, 255, 255))
    display.write_string('text',
                         10,
                         constants.WINDOW_HEIGHT - 4,
                         ' - Reroll',
                         fore_color=(200, 200, 200))

    display.write_string('text',
                         3,
                         constants.WINDOW_HEIGHT - 5,
                         '<Enter>',
                         fore_color=(255, 255, 255))
    display.write_string('text',
                         10,
                         constants.WINDOW_HEIGHT - 5,
                         ' - Accept',
                         fore_color=(200, 200, 200))

    display.write_string('text', 3, constants.WINDOW_HEIGHT - 2,
                         'Total Cost: ')
    display.write_string('text',
                         15,
                         constants.WINDOW_HEIGHT - 2,
                         '$%.2f' % _total_money,
                         fore_color=(0, 200, 0),
                         back_color=(0, 40, 0))

    display.blit_surface_viewport('background', 0, 0, constants.WINDOW_WIDTH,
                                  constants.WINDOW_HEIGHT)
    display.blit_surface('text')