mirror of
https://github.com/csd4ni3l/simulator-games.git
synced 2026-01-01 12:23:44 +01:00
fix wrong check for windows to disable svg loading, and now bodies that go outside the border get destroyed instead of spawned back to avoid infinite looping
This commit is contained in:
@@ -134,7 +134,7 @@ class Game(arcade.gui.UIView):
|
|||||||
self.settings_box.add(arcade.gui.UILabel("Inventory", font_size=18))
|
self.settings_box.add(arcade.gui.UILabel("Inventory", font_size=18))
|
||||||
|
|
||||||
self.inventory_grid = self.settings_box.add(BodyInventory(self.window.width, self.window.height, "crate", {"crate": ":resources:images/tiles/boxCrate_double.png", "coin": ":resources:images/items/coinGold.png"}))
|
self.inventory_grid = self.settings_box.add(BodyInventory(self.window.width, self.window.height, "crate", {"crate": ":resources:images/tiles/boxCrate_double.png", "coin": ":resources:images/items/coinGold.png"}))
|
||||||
if os.name == "nt":
|
if os.name != "nt":
|
||||||
self.add_custom_body_button = self.settings_box.add(arcade.gui.UITextureButton(text="Add custom body from SVG", size_hint=(1, 0.1), width=self.window.width * 0.2, height=self.window.height * 0.1))
|
self.add_custom_body_button = self.settings_box.add(arcade.gui.UITextureButton(text="Add custom body from SVG", size_hint=(1, 0.1), width=self.window.width * 0.2, height=self.window.height * 0.1))
|
||||||
|
|
||||||
self.add_custom_body_button.on_click = lambda event: self.custom_body_ui()
|
self.add_custom_body_button.on_click = lambda event: self.custom_body_ui()
|
||||||
@@ -399,12 +399,17 @@ class Game(arcade.gui.UIView):
|
|||||||
self.create_custom_body(self.inventory_grid.selected_item, self.window.mouse.data['x'], self.window.mouse.data['y'], self.custom_mass)
|
self.create_custom_body(self.inventory_grid.selected_item, self.window.mouse.data['x'], self.window.mouse.data['y'], self.custom_mass)
|
||||||
|
|
||||||
for sprite in self.spritelist:
|
for sprite in self.spritelist:
|
||||||
body = sprite.pymunk_obj.body
|
x, y = sprite.pymunk_obj.body.position
|
||||||
x, y = body.position
|
|
||||||
|
|
||||||
if x < 0 or x > self.window.width * 0.775 or y < 0:
|
if x < 0 or x > self.window.width * 0.775 or y < 0:
|
||||||
body.position = (random.uniform(self.window.width * 0.1, self.window.width * 0.9), self.window.height * 0.9)
|
if not isinstance(sprite.pymunk_obj, FakeShape):
|
||||||
body.velocity = (0, 0)
|
sprite.remove_from_sprite_lists()
|
||||||
|
self.space.remove(sprite.pymunk_obj, sprite.pymunk_obj.body)
|
||||||
|
else:
|
||||||
|
sprite.remove_from_sprite_lists()
|
||||||
|
for shape in sprite.pymunk_obj.body.shapes:
|
||||||
|
self.space.remove(shape)
|
||||||
|
self.space.remove(sprite.pymunk_obj.body)
|
||||||
|
|
||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
self.space.step(self.window._draw_rate)
|
self.space.step(self.window._draw_rate)
|
||||||
@@ -443,6 +448,7 @@ class Game(arcade.gui.UIView):
|
|||||||
self.space.remove(shape)
|
self.space.remove(shape)
|
||||||
self.space.remove(sprite.pymunk_obj.body)
|
self.space.remove(sprite.pymunk_obj.body)
|
||||||
|
|
||||||
|
|
||||||
self.spritelist.clear()
|
self.spritelist.clear()
|
||||||
|
|
||||||
def on_show_view(self):
|
def on_show_view(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user