Михаил Капелько vor 5 Monaten
Ursprung
Commit
9c6bf448fa
5 geänderte Dateien mit 30 neuen und 7 gelöschten Zeilen
  1. +19
    -0
      v5/desktop.py
  2. +1
    -0
      v5/desktop_Platform.py
  3. +4
    -1
      v5/desktop_Window.py
  4. +5
    -6
      v5/gui.py
  5. +1
    -0
      v5/main-gui.py

+ 19
- 0
v5/desktop.py Datei anzeigen

@@ -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]
#}
#}

+ 1
- 0
v5/desktop_Platform.py Datei anzeigen

@@ -3,5 +3,6 @@ import arcade
class desktop_Platform:
def __init__(self):
self.c = None
self.deselectedTiles = []
self.sprites = arcade.SpriteList()
self.textures = []

+ 4
- 1
v5/desktop_Window.py Datei anzeigen

@@ -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()

+ 5
- 6
v5/gui.py Datei anzeigen

@@ -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
#}


+ 1
- 0
v5/main-gui.py Datei anzeigen

@@ -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()

Laden…
Abbrechen
Speichern