Nauč se Python > Materiály > Snake Workshop for PyLadies > The Snake > Drawing the snake

Drawing the snake – Řešení [0]

import pyglet

TILE_SIZE = 64

class GameState:
    def initialize(self):
        self.snake = [(1, 2), (2, 2), (3, 2), (3, 3), (3, 4), (3, 5), (4, 5)]

state = GameState()
state.initialize()

green_image = pyglet.image.load('green.png')

window = pyglet.window.Window()

@window.event
def on_draw():
    window.clear()
    green_image.blit(4 * TILE_SIZE, 5 * TILE_SIZE,
                     width=TILE_SIZE, height=TILE_SIZE)

pyglet.app.run()

Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.