From 9b72f437a52d6858a4657db14896a4406d07126b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 2 Jul 2023 20:16:21 +0800 Subject: [PATCH] use store view and update some dr game --- Difficult_Rocket/utils/camera.py | 26 ++++++-------------------- configs/main.toml | 4 ++-- mods/dr_game/__init__.py | 2 +- mods/dr_game/sr1_ship.py | 8 ++++---- 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Difficult_Rocket/utils/camera.py b/Difficult_Rocket/utils/camera.py index 7a48b50..0348437 100644 --- a/Difficult_Rocket/utils/camera.py +++ b/Difficult_Rocket/utils/camera.py @@ -37,9 +37,7 @@ class Camera: self.zoom = zoom self.min_zoom = min_zoom self.max_zoom = max_zoom - - def get_view(self): - return self.window.view + self._stored_view = window.view @property def position(self) -> Tuple[float, float]: @@ -59,6 +57,7 @@ class Camera: def begin(self) -> None: view = self.window.view + self._stored_view = view x = self.window.width / self.zoom + (self.dx / self.zoom) y = self.window.height / self.zoom + (self.dy / self.zoom) @@ -68,14 +67,7 @@ class Camera: self.window.view = view_matrix def end(self) -> None: - view = self.window.view - x = self.window.width / self.zoom + (self.dx / self.zoom) - y = self.window.height / self.zoom + (self.dy / self.zoom) - - view_matrix = view.scale((1.0 / self.zoom, 1.0 / self.zoom, 1)) - view_matrix = view_matrix.translate((-x * self.zoom, -y * self.zoom, 0)) - - self.window.view = view_matrix + self.window.view = self._stored_view def __enter__(self): self.begin() @@ -87,7 +79,7 @@ class Camera: class CenterCamera(Camera): """ - A camera that centers the view on the center of the window + A camera that centers the view in the center of the window >>> from pyglet.window import Window >>> window = Window() @@ -103,6 +95,7 @@ class CenterCamera(Camera): """ def begin(self) -> None: view = self.window.view + self._stored_view = view x = self.window.width / 2.0 / self.zoom + (self.dx / self.zoom) y = self.window.height / 2.0 / self.zoom + (self.dy / self.zoom) @@ -112,12 +105,5 @@ class CenterCamera(Camera): self.window.view = view_matrix def end(self) -> None: - view = self.window.view - x = self.window.width / 2.0 / self.zoom + (self.dx / self.zoom) - y = self.window.height / 2.0 / self.zoom + (self.dy / self.zoom) - - view_matrix = view.scale((1.0 / self.zoom, 1.0 / self.zoom, 1)) - view_matrix = view_matrix.translate((-x * self.zoom, -y * self.zoom, 0)) - - self.window.view = view_matrix + self.window.view = self._stored_view \ No newline at end of file diff --git a/configs/main.toml b/configs/main.toml index 63dd2c7..481df95 100644 --- a/configs/main.toml +++ b/configs/main.toml @@ -7,8 +7,8 @@ fonts_folder = "libs/fonts" [window] style = "None" -width = 1268 -height = 1031 +width = 1047 +height = 684 visible = true gui_scale = 1 caption = "Difficult Rocket v{DR_version}" diff --git a/mods/dr_game/__init__.py b/mods/dr_game/__init__.py index a59f99f..9f9aa7f 100644 --- a/mods/dr_game/__init__.py +++ b/mods/dr_game/__init__.py @@ -54,7 +54,7 @@ DR_mod_runtime = _DR_mod_runtime() class DR_mod(ModInfo): mod_id = "difficult_rocket_mod" name = "Difficult Rocket mod" - version = Version("0.3.1.1") + version = Version("0.3.1.2") writer = "shenjackyuanjie" link = "shenjack.top" diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index c3ed153..c56321d 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -199,9 +199,9 @@ class SR1ShipRender(BaseScreen): count += 1 if count >= each_count: count = 0 - yield each_count + yield count if DR_mod_runtime.use_DR_rust: - connect_line_group = Group(5, parent=self.part_group) + connect_line_group = Group(7, parent=self.part_group) for connect in self.rust_ship.connection: # 连接线 parent_part_data = self.part_data[connect[2]] @@ -212,9 +212,9 @@ class SR1ShipRender(BaseScreen): batch=self.main_batch, group=connect_line_group, width=1, color=color)) count += 1 - if count >= each_count: + if count >= each_count * 3: count = 0 - yield each_count + yield count self.drawing = False raise GeneratorExit