Created
December 17, 2022 17:38
-
-
Save rabuf/479e0a926b7ac45dc01ae7d2b253eb37 to your computer and use it in GitHub Desktop.
Using a generator for tetris pieces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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