Михаил Капелько 1周前
父节点
当前提交
9c6bf448fa
共有 5 个文件被更改,包括 30 次插入7 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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 查看文件

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

正在加载...
取消
保存