d
This commit is contained in:
96
v5/Window.py
96
v5/Window.py
@@ -4,35 +4,47 @@ CELL = 25
|
|||||||
HEIGHT = 600
|
HEIGHT = 600
|
||||||
WIDTH = 900
|
WIDTH = 900
|
||||||
|
|
||||||
|
images = [
|
||||||
|
["res/tiles_0.png", 0, 0, 75, 100],
|
||||||
|
["res/tiles_0.png", 75, 0, 75, 100],
|
||||||
|
["res/tiles_1.png", 0, 0, 75, 100],
|
||||||
|
]
|
||||||
|
positions = [
|
||||||
|
[9, 1],
|
||||||
|
[14, 1],
|
||||||
|
[19, 1],
|
||||||
|
[24, 1],
|
||||||
|
|
||||||
|
[9, 7],
|
||||||
|
[14, 7],
|
||||||
|
[19, 7],
|
||||||
|
[24, 7],
|
||||||
|
|
||||||
|
[9, 13],
|
||||||
|
[14, 13],
|
||||||
|
[19, 13],
|
||||||
|
[24, 13],
|
||||||
|
|
||||||
|
[9, 19],
|
||||||
|
[14, 19],
|
||||||
|
[19, 19],
|
||||||
|
[24, 19],
|
||||||
|
]
|
||||||
|
textures = None
|
||||||
|
deselected_tiles = []
|
||||||
|
selected_tiles = []
|
||||||
|
|
||||||
class Window(arcade.Window):
|
class Window(arcade.Window):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(WIDTH, HEIGHT, "OGS Memory")
|
super().__init__(WIDTH, HEIGHT, "OGS Memory")
|
||||||
arcade.set_background_color(arcade.color.WHITE)
|
arcade.set_background_color(arcade.color.WHITE)
|
||||||
self.all_sprites = arcade.SpriteList()
|
self.all_sprites = arcade.SpriteList()
|
||||||
|
|
||||||
positions = [
|
textures = load_textures(images)
|
||||||
[9, 1],
|
deselected_tiles = create_deselected_tiles(positions, textures)
|
||||||
[14, 1],
|
for t in deselected_tiles:
|
||||||
[19, 1],
|
self.all_sprites.append(t)
|
||||||
[24, 1],
|
#selected_tiles = create_selected_tiles(positions, textures)
|
||||||
|
|
||||||
[9, 7],
|
|
||||||
[14, 7],
|
|
||||||
[19, 7],
|
|
||||||
[24, 7],
|
|
||||||
|
|
||||||
[9, 13],
|
|
||||||
[14, 13],
|
|
||||||
[19, 13],
|
|
||||||
[24, 13],
|
|
||||||
|
|
||||||
[9, 19],
|
|
||||||
[14, 19],
|
|
||||||
[19, 19],
|
|
||||||
[24, 19],
|
|
||||||
]
|
|
||||||
|
|
||||||
add_tiles(self.all_sprites, positions)
|
|
||||||
|
|
||||||
def on_draw(self):
|
def on_draw(self):
|
||||||
arcade.start_render()
|
arcade.start_render()
|
||||||
@@ -47,17 +59,27 @@ class Window(arcade.Window):
|
|||||||
def on_update(self, delta):
|
def on_update(self, delta):
|
||||||
self.all_sprites.update_animation()
|
self.all_sprites.update_animation()
|
||||||
|
|
||||||
def add_tiles(sprites, positions):
|
|
||||||
id = 0
|
def load_textures(images):
|
||||||
for p in positions:
|
ts = []
|
||||||
tile = arcade.AnimatedTimeBasedSprite()
|
for (id, img) in enumerate(images):
|
||||||
tile.guid = id
|
tex = arcade.load_texture(img[0], x = img[1], y = img[2], width = img[3], height = img[4])
|
||||||
id += 1
|
ts.append(tex)
|
||||||
for i in range(2):
|
return ts
|
||||||
tex = arcade.load_texture("res/tiles_0.png", x = i*75, y = 0, width = 75, height = 100)
|
|
||||||
tile.append_texture(tex)
|
def create_deselected_tiles(positions, textures):
|
||||||
a = arcade.sprite.AnimationKeyframe(i, 700, tex)
|
tiles = []
|
||||||
tile.frames.append(a)
|
for (id, p) in enumerate(positions):
|
||||||
tile.center_x = CELL * 2 + p[0] * CELL
|
tile = arcade.AnimatedTimeBasedSprite()
|
||||||
tile.center_y = HEIGHT - CELL * 2 - p[1] * CELL
|
tiles.append(tile)
|
||||||
sprites.append(tile)
|
tile.guid = id
|
||||||
|
tile.texture = textures[0]
|
||||||
|
# Animation between two textures.
|
||||||
|
a1 = arcade.sprite.AnimationKeyframe(0, 700, textures[0])
|
||||||
|
a2 = arcade.sprite.AnimationKeyframe(1, 700, textures[1])
|
||||||
|
tile.frames.append(a1)
|
||||||
|
tile.frames.append(a2)
|
||||||
|
# Position.
|
||||||
|
tile.center_x = CELL * 2 + p[0] * CELL
|
||||||
|
tile.center_y = HEIGHT - CELL * 2 - p[1] * CELL
|
||||||
|
return tiles
|
||||||
|
|||||||
Reference in New Issue
Block a user