use store view and update some dr game
This commit is contained in:
parent
9107621fb8
commit
9b72f437a5
@ -37,9 +37,7 @@ class Camera:
|
|||||||
self.zoom = zoom
|
self.zoom = zoom
|
||||||
self.min_zoom = min_zoom
|
self.min_zoom = min_zoom
|
||||||
self.max_zoom = max_zoom
|
self.max_zoom = max_zoom
|
||||||
|
self._stored_view = window.view
|
||||||
def get_view(self):
|
|
||||||
return self.window.view
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def position(self) -> Tuple[float, float]:
|
def position(self) -> Tuple[float, float]:
|
||||||
@ -59,6 +57,7 @@ class Camera:
|
|||||||
|
|
||||||
def begin(self) -> None:
|
def begin(self) -> None:
|
||||||
view = self.window.view
|
view = self.window.view
|
||||||
|
self._stored_view = view
|
||||||
x = self.window.width / self.zoom + (self.dx / self.zoom)
|
x = self.window.width / self.zoom + (self.dx / self.zoom)
|
||||||
y = self.window.height / self.zoom + (self.dy / self.zoom)
|
y = self.window.height / self.zoom + (self.dy / self.zoom)
|
||||||
|
|
||||||
@ -68,14 +67,7 @@ class Camera:
|
|||||||
self.window.view = view_matrix
|
self.window.view = view_matrix
|
||||||
|
|
||||||
def end(self) -> None:
|
def end(self) -> None:
|
||||||
view = self.window.view
|
self.window.view = self._stored_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
|
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.begin()
|
self.begin()
|
||||||
@ -87,7 +79,7 @@ class Camera:
|
|||||||
|
|
||||||
class CenterCamera(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
|
>>> from pyglet.window import Window
|
||||||
>>> window = Window()
|
>>> window = Window()
|
||||||
@ -103,6 +95,7 @@ class CenterCamera(Camera):
|
|||||||
"""
|
"""
|
||||||
def begin(self) -> None:
|
def begin(self) -> None:
|
||||||
view = self.window.view
|
view = self.window.view
|
||||||
|
self._stored_view = view
|
||||||
x = self.window.width / 2.0 / self.zoom + (self.dx / self.zoom)
|
x = self.window.width / 2.0 / self.zoom + (self.dx / self.zoom)
|
||||||
y = self.window.height / 2.0 / self.zoom + (self.dy / 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
|
self.window.view = view_matrix
|
||||||
|
|
||||||
def end(self) -> None:
|
def end(self) -> None:
|
||||||
view = self.window.view
|
self.window.view = self._stored_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
|
|
||||||
|
|
@ -7,8 +7,8 @@ fonts_folder = "libs/fonts"
|
|||||||
|
|
||||||
[window]
|
[window]
|
||||||
style = "None"
|
style = "None"
|
||||||
width = 1268
|
width = 1047
|
||||||
height = 1031
|
height = 684
|
||||||
visible = true
|
visible = true
|
||||||
gui_scale = 1
|
gui_scale = 1
|
||||||
caption = "Difficult Rocket v{DR_version}"
|
caption = "Difficult Rocket v{DR_version}"
|
||||||
|
@ -54,7 +54,7 @@ DR_mod_runtime = _DR_mod_runtime()
|
|||||||
class DR_mod(ModInfo):
|
class DR_mod(ModInfo):
|
||||||
mod_id = "difficult_rocket_mod"
|
mod_id = "difficult_rocket_mod"
|
||||||
name = "Difficult Rocket mod"
|
name = "Difficult Rocket mod"
|
||||||
version = Version("0.3.1.1")
|
version = Version("0.3.1.2")
|
||||||
|
|
||||||
writer = "shenjackyuanjie"
|
writer = "shenjackyuanjie"
|
||||||
link = "shenjack.top"
|
link = "shenjack.top"
|
||||||
|
@ -199,9 +199,9 @@ class SR1ShipRender(BaseScreen):
|
|||||||
count += 1
|
count += 1
|
||||||
if count >= each_count:
|
if count >= each_count:
|
||||||
count = 0
|
count = 0
|
||||||
yield each_count
|
yield count
|
||||||
if DR_mod_runtime.use_DR_rust:
|
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:
|
for connect in self.rust_ship.connection:
|
||||||
# 连接线
|
# 连接线
|
||||||
parent_part_data = self.part_data[connect[2]]
|
parent_part_data = self.part_data[connect[2]]
|
||||||
@ -212,9 +212,9 @@ class SR1ShipRender(BaseScreen):
|
|||||||
batch=self.main_batch, group=connect_line_group,
|
batch=self.main_batch, group=connect_line_group,
|
||||||
width=1, color=color))
|
width=1, color=color))
|
||||||
count += 1
|
count += 1
|
||||||
if count >= each_count:
|
if count >= each_count * 3:
|
||||||
count = 0
|
count = 0
|
||||||
yield each_count
|
yield count
|
||||||
self.drawing = False
|
self.drawing = False
|
||||||
raise GeneratorExit
|
raise GeneratorExit
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user