Kreslení hada – Řešení [2]
import pyglet
TILE_SIZE = 64
snake = [(1, 2), (2, 2), (3, 2), (3, 3), (3, 4), (3, 5), (4, 5)]
food = [(2, 0), (5, 1), (1, 4)]
red_image = pyglet.image.load('apple.png')
green_image = pyglet.image.load('green.png')
window = pyglet.window.Window()
@window.event
def on_draw():
window.clear()
for x, y in snake:
green_image.blit(x * TILE_SIZE, y * TILE_SIZE,
width=TILE_SIZE, height=TILE_SIZE)
for x, y in food:
red_image.blit(x * TILE_SIZE, y * TILE_SIZE,
width=TILE_SIZE, height=TILE_SIZE)
pyglet.app.run()