Skip to content

Instantly share code, notes, and snippets.

@rabuf
Created December 17, 2022 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabuf/479e0a926b7ac45dc01ae7d2b253eb37 to your computer and use it in GitHub Desktop.
Save rabuf/479e0a926b7ac45dc01ae7d2b253eb37 to your computer and use it in GitHub Desktop.
Using a generator for tetris pieces
pieces = [{3,4,5,6},
{4, 3+1j, 4+1j, 5+1j, 4+2j},
{3, 4, 5, 5+1j, 5+2j},
{3, 3+1j, 3+2j, 3+3j},
{3, 4, 3+1j, 4+1j}]
def make_piece():
level = 0
for piece in cycle(pieces):
level = yield {part + (level * 1j) for part in piece}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment