Example #1
0
def update():
    global X
    global Y
    global LAST_X
    global LAST_Y

    X = numbers.clip(X, X_MIN, X_MAX)
    Y = numbers.clip(Y, Y_MIN, Y_MAX)

    _zone = zones.ZONES[zones.ACTIVE_ZONE]

    display.set_surface_camera("tiles", X, Y)
    display.reset_surface_shaders("tiles")

    if world_action.FADE_VALUE < 255:
        display.apply_surface_shader(
            "tiles", zones.get_active_fader(), constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT
        )

    for shader in _zone["shaders"]:
        display.apply_surface_shader("tiles", shader, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)

    display.blit_surface_viewport("tiles", X, Y, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)

    LAST_X = X
    LAST_Y = Y
Example #2
0
def update():
	global X
	global Y	
	global LAST_X
	global LAST_Y
	
	X = numbers.clip(X, X_MIN, X_MAX)
	Y = numbers.clip(Y, Y_MIN, Y_MAX)
	
	_zone = zones.ZONES[zones.ACTIVE_ZONE]
	
	display.set_surface_camera('tiles', X, Y)
	display.reset_surface_shaders('tiles')
	
	if world_action.FADE_VALUE < 255:
		display.apply_surface_shader('tiles', zones.get_active_fader(), constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)
	
	for shader in _zone['shaders']:
		display.apply_surface_shader('tiles', shader, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)
	
	display.blit_surface_viewport('tiles', X, Y, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT)
	
	LAST_X = X
	LAST_Y = Y
Example #3
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)),
                                ),
                            )
Example #4
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))))