Пример #1
0
def load_focus_mask_data():    
    coordinates_dict = {}

    coordinates_file = renpy.file(COORDINATES_FILE_PATH)
    coordinates_buffer = coordinates_file.read()
    coordinates_file.close()

    # Положение в буфере, начиная с которого читаем данные. Придётся двигать вручную.
    offset = 0

    while offset < len(coordinates_buffer):
        # Читаем длину строки в которой хранится путь к файлу.
        button_image_path_len = struct.unpack_from(STRUCT_IMAGE_PATH_LEN, coordinates_buffer, offset)[0]
        offset += STRUCT_IMAGE_PATH_LEN_SIZE

        # Читаем путь к файлу.
        button_image_path = struct.unpack_from(STRUCT_IMAGE_PATH % button_image_path_len, coordinates_buffer, offset)[0].decode('utf-8')
        offset += button_image_path_len

        coordinates_set = set()
        coordinates_dict[button_image_path] = coordinates_set

        # Читаем количество координат.
        coordinates_count = struct.unpack_from(STRUCT_COORDINATES_COUNT, coordinates_buffer, offset)[0]
        offset += STRUCT_COORDINATES_COUNT_SIZE

        # Читаем все координаты.
        for coordinate_index in range(0, coordinates_count):
            coordinates = struct.unpack_from(STRUCT_COORDINATE, coordinates_buffer, offset)
            offset += STRUCT_COORDINATE_SIZE

            coordinates_set.add(coordinates)

    FocusMaskCallable.coordinates_dict = coordinates_dict        
Пример #2
0
def get_shrinked_surface(button_image_path):
    button_image_file = renpy.file(button_image_path)
    button_surface = pygame.image.load(button_image_file, button_image_path)
    button_size = button_surface.get_size()
    return pygame.transform.scale(button_surface,
                                  (button_size[0] / RESOLUTION_DIVIDER,
                                   button_size[1] / RESOLUTION_DIVIDER))
Пример #3
0
    def __init__(self, pos, image_folder, char_id):
        self.id = char_id

        self.char_images = {
            'default':
            pygame.image.load(renpy.file(image_folder + '/default.png')),
            'with_weapon':
            pygame.image.load(renpy.file(image_folder + '/with_weapon.png')),
        }

        self.base_image = self.char_images['default']

        self.health = 100
        self.max_health = 100
        self.default_spawn_point = (15 * game_data.tile_size,
                                    15 * game_data.tile_size)
        self.invuln_time = 0.75

        Entity.__init__(self, pos)
        all_voices.add(self)
Пример #4
0
def init():
    global tilemap, all_tiles, all_walls

    if all_tiles is not None:
        all_tiles.empty()

    if all_walls is not None:
        all_walls.empty()

    all_tiles = pygame.sprite.Group()
    all_walls = pygame.sprite.Group()

    tilemap = load_map_image(renpy.file('map.png'))
    read_tilemap()
Пример #5
0
    def __init__(self, wielder, image, mount_point=(35, 10),
                 anchor_pt=(5, 40)):
        self.mount_point = mount_point
        self.anchor_pt = anchor_pt
        self.wielder = wielder

        self.base_image = pygame.image.load(renpy.file(image))

        self.active = True
        self.can_damage = False
        self.is_melee = False
        self.rot_offset = 0

        self.rotate_to_wielder()

        Entity.__init__(self, self.pos)

        all_weapons.add(self)
Пример #6
0
def load_focus_mask_data():
    coordinates_dict = {}

    coordinates_file = renpy.file(COORDINATES_FILE_PATH)
    coordinates_buffer = coordinates_file.read()
    coordinates_file.close()

    # Положение в буфере, начиная с которого читаем данные. Придётся двигать вручную.
    offset = 0

    while offset < len(coordinates_buffer):
        # Читаем длину строки в которой хранится путь к файлу.
        button_image_path_len = struct.unpack_from(STRUCT_IMAGE_PATH_LEN,
                                                   coordinates_buffer,
                                                   offset)[0]
        offset += STRUCT_IMAGE_PATH_LEN_SIZE

        # Читаем путь к файлу.
        button_image_path = struct.unpack_from(
            STRUCT_IMAGE_PATH % button_image_path_len, coordinates_buffer,
            offset)[0].decode('utf-8')
        offset += button_image_path_len

        coordinates_set = set()
        coordinates_dict[button_image_path] = coordinates_set

        # Читаем количество координат.
        coordinates_count = struct.unpack_from(STRUCT_COORDINATES_COUNT,
                                               coordinates_buffer, offset)[0]
        offset += STRUCT_COORDINATES_COUNT_SIZE

        # Читаем все координаты.
        for coordinate_index in range(0, coordinates_count):
            coordinates = struct.unpack_from(STRUCT_COORDINATE,
                                             coordinates_buffer, offset)
            offset += STRUCT_COORDINATE_SIZE

            coordinates_set.add(coordinates)

    FocusMaskCallable.coordinates_dict = coordinates_dict
Пример #7
0
def get_shrinked_surface(button_image_path):
    button_image_file = renpy.file(button_image_path)
    button_surface = pygame.image.load(button_image_file, button_image_path)
    button_size = button_surface.get_size()
    return pygame.transform.scale(button_surface, (button_size[0]/RESOLUTION_DIVIDER, button_size[1]/RESOLUTION_DIVIDER))    
Пример #8
0
import pygame
import math
import game_data

all_tiles = None
all_walls = None

tilemap = []
tile_sprites = []

tilemap_ctrlpanel = 2
tilemap_wall = 1
tilemap_empty = 0
tilemap_skip = -1

control_panel_sprite = pygame.image.load(renpy.file('tiles/control_panel.png'))

floor_tile_sprites = {
    'normal': pygame.image.load(renpy.file('tiles/floor_tiles/basic.png')),
    'vent': [
        pygame.image.load(renpy.file('tiles/floor_tiles/vent_1.png')),
        pygame.image.load(renpy.file('tiles/floor_tiles/vent_2.png')),
    ],
    'panel': [
        pygame.image.load(renpy.file('tiles/floor_tiles/panel_1.png')),
        pygame.image.load(renpy.file('tiles/floor_tiles/panel_2.png')),
        pygame.image.load(renpy.file('tiles/floor_tiles/panel_3.png')),
        pygame.image.load(renpy.file('tiles/floor_tiles/panel_4.png')),
        pygame.image.load(renpy.file('tiles/floor_tiles/panel_5.png')),
        pygame.image.load(renpy.file('tiles/floor_tiles/panel_6.png')),
    ],