From 9c6bf448fac3977d3f458d3745989acb7886fba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Fri, 28 Jun 2024 22:42:53 +0300 Subject: [PATCH] d --- v5/desktop.py | 19 +++++++++++++++++++ v5/desktop_Platform.py | 1 + v5/desktop_Window.py | 5 ++++- v5/gui.py | 11 +++++------ v5/main-gui.py | 1 + 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/v5/desktop.py b/v5/desktop.py index 7172dff..817bae9 100644 --- a/v5/desktop.py +++ b/v5/desktop.py @@ -15,3 +15,22 @@ def desktop_loadTextures(p): #} p.textures = texs #} + +def desktop_createDeselectedTiles(p): + for (id, pos) in enumerate(p.c.tilePositions): + tile = arcade.AnimatedTimeBasedSprite() + p.deselectedTiles.append(tile) + p.sprites.append(tile) + + tile.guid = id + tile.texture = p.textures[0] + # Animation between two textures. + a1 = arcade.sprite.AnimationKeyframe(0, 700, p.textures[0]) + a2 = arcade.sprite.AnimationKeyframe(1, 700, p.textures[1]) + tile.frames.append(a1) + tile.frames.append(a2) + # Position. + tile.left = pos[0] + tile.top = pos[1] + #} +#} diff --git a/v5/desktop_Platform.py b/v5/desktop_Platform.py index 327f55a..4d7b035 100644 --- a/v5/desktop_Platform.py +++ b/v5/desktop_Platform.py @@ -3,5 +3,6 @@ import arcade class desktop_Platform: def __init__(self): self.c = None + self.deselectedTiles = [] self.sprites = arcade.SpriteList() self.textures = [] diff --git a/v5/desktop_Window.py b/v5/desktop_Window.py index 238f08e..4bf4c77 100644 --- a/v5/desktop_Window.py +++ b/v5/desktop_Window.py @@ -17,6 +17,9 @@ class desktop_Window(arcade.Window): def on_mouse_press(self, x, y, button, key_modifiers): print("click", x, y) + sprites = arcade.get_sprites_at_point([x, y], self.p.sprites) + id = sprites[0].guid + print("selected id: ", id) def on_update(self, delta): - pass + self.p.sprites.update_animation() diff --git a/v5/gui.py b/v5/gui.py index dc7e8d5..1d939f5 100644 --- a/v5/gui.py +++ b/v5/gui.py @@ -68,16 +68,15 @@ def gui_generateTilePositions( heightInCells = c.windowHeight / c.cellSize positions = gui_aux_cellPositions(c.playfieldSize) - poss = [] + ps = [] for i in range(0, len(positions)): p = positions[i] - pos = [p[0] * c.cellSize, p[1] * c.cellSize] - poss.append(pos) + x = p[0] * c.cellSize + y = c.windowHeight - p[1] * c.cellSize + ps.append([x, y]) #} - #tile.center_x = CELL * 2 + p[0] * CELL - #tile.center_y = HEIGHT - CELL * 2 - p[1] * CELL - c.tilePositions = poss + c.tilePositions = ps c.recentField = "tilePositions" return c #} diff --git a/v5/main-gui.py b/v5/main-gui.py index 194cc47..f2edeff 100644 --- a/v5/main-gui.py +++ b/v5/main-gui.py @@ -101,6 +101,7 @@ ctrl.set("windowBackgroundColor", "#ffffff") ctrl.set("windowTitle", "OGS Memory") desktop_loadTextures(p) +desktop_createDeselectedTiles(p) wnd = desktop_Window(p) arcade.run()