From ef73925b0a10276d3879d0183a40af619f5ac669 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 21 Jul 2023 20:09:24 +0800 Subject: [PATCH] enable render --- config/main.toml | 4 ++-- mods/dr_game/Difficult_Rocket_rs/__init__.py | 2 ++ mods/dr_game/sr1_ship.py | 9 ++++++--- mods/dr_game/types.py | 6 +++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config/main.toml b/config/main.toml index f4a4cba..fc01c1a 100644 --- a/config/main.toml +++ b/config/main.toml @@ -7,8 +7,8 @@ fonts_folder = "assets/fonts" [window] style = "None" -width = 1301 -height = 970 +width = 1112 +height = 793 visible = true gui_scale = 1 caption = "Difficult Rocket v{DR_version}" diff --git a/mods/dr_game/Difficult_Rocket_rs/__init__.py b/mods/dr_game/Difficult_Rocket_rs/__init__.py index 5c431a3..09260d0 100644 --- a/mods/dr_game/Difficult_Rocket_rs/__init__.py +++ b/mods/dr_game/Difficult_Rocket_rs/__init__.py @@ -100,6 +100,8 @@ if TYPE_CHECKING: @property def angle(self) -> float: ... @property + def angle_r(self) -> float: ... + @property def angle_v(self) -> float: ... @property def explode(self) -> bool: ... diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index f7943b5..42eeab1 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -129,7 +129,7 @@ class SR1ShipRender(BaseScreen): # List/Dict data self.part_data: Dict[int, SR1PartData] = {} - self.parts_sprite: Dict[int, Sprite] = {} + self.parts_sprite: Dict[int, List[Sprite]] = {} self.part_box_dict: Dict[int, Rectangle] = {} self.part_line_box: Dict[int, List[Line]] = {} self.part_line_list: List[Line] = [] @@ -181,15 +181,18 @@ class SR1ShipRender(BaseScreen): for p_id, parts in self.rust_ship.as_dict().items(): p_id: int parts: List[Tuple[SR1PartType_rs, SR1PartData_rs]] - part_group = Group(20, parent=self.part_group) + part_group = Group(2, parent=self.part_group) batch = [] for p_type, p_data in parts: part_sprite = Sprite(img=self.textures.get_texture(map_ptype_textures(p_data.part_type_id)), x=p_data.x * 60, y=p_data.y * 60, z=random.random(), batch=self.main_batch, group=part_group) + part_sprite.rotation = p_data.angle_r + part_sprite.scale_x = -1 if p_data.flip_x else 1 + part_sprite.scale_y = -1 if p_data.flip_y else 1 batch.append(part_sprite) - + self.parts_sprite[p_id] = batch count += 1 if count >= each_count: count = 0 diff --git a/mods/dr_game/types.py b/mods/dr_game/types.py index 966b62c..45fed65 100644 --- a/mods/dr_game/types.py +++ b/mods/dr_game/types.py @@ -50,7 +50,11 @@ class SR1Textures(Options): if name in self.cached_options: return self.cached_options.get(name) else: - return None + img = load(f'assets/textures/parts/{name}.png') + img.anchor_x = img.width // 2 + img.anchor_y = img.height // 2 + setattr(self, name, img) + return img Battery: AbstractImage = None Beam: AbstractImage = None