@@ -15,3 +15,22 @@ def desktop_loadTextures(p): | |||||
#} | #} | ||||
p.textures = texs | 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] | |||||
#} | |||||
#} |
@@ -3,5 +3,6 @@ import arcade | |||||
class desktop_Platform: | class desktop_Platform: | ||||
def __init__(self): | def __init__(self): | ||||
self.c = None | self.c = None | ||||
self.deselectedTiles = [] | |||||
self.sprites = arcade.SpriteList() | self.sprites = arcade.SpriteList() | ||||
self.textures = [] | self.textures = [] |
@@ -17,6 +17,9 @@ class desktop_Window(arcade.Window): | |||||
def on_mouse_press(self, x, y, button, key_modifiers): | def on_mouse_press(self, x, y, button, key_modifiers): | ||||
print("click", x, y) | 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): | def on_update(self, delta): | ||||
pass | |||||
self.p.sprites.update_animation() |
@@ -68,16 +68,15 @@ def gui_generateTilePositions( | |||||
heightInCells = c.windowHeight / c.cellSize | heightInCells = c.windowHeight / c.cellSize | ||||
positions = gui_aux_cellPositions(c.playfieldSize) | positions = gui_aux_cellPositions(c.playfieldSize) | ||||
poss = [] | |||||
ps = [] | |||||
for i in range(0, len(positions)): | for i in range(0, len(positions)): | ||||
p = positions[i] | 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" | c.recentField = "tilePositions" | ||||
return c | return c | ||||
#} | #} | ||||
@@ -101,6 +101,7 @@ ctrl.set("windowBackgroundColor", "#ffffff") | |||||
ctrl.set("windowTitle", "OGS Memory") | ctrl.set("windowTitle", "OGS Memory") | ||||
desktop_loadTextures(p) | desktop_loadTextures(p) | ||||
desktop_createDeselectedTiles(p) | |||||
wnd = desktop_Window(p) | wnd = desktop_Window(p) | ||||
arcade.run() | arcade.run() |