mirror of
https://github.com/kristoferssolo/2048.git
synced 2025-10-21 15:20:35 +00:00
feat(game): add inital block value option
This commit is contained in:
parent
c738084ce1
commit
b533946471
@ -7,13 +7,13 @@ from .config import Config
|
||||
|
||||
|
||||
class Block(pygame.sprite.Sprite):
|
||||
def __init__(self, x: int, y: int):
|
||||
def __init__(self, x: int, y: int, value: int | None = 2):
|
||||
"""Initialize a block"""
|
||||
super().__init__()
|
||||
self.image = pygame.Surface((Config.BLOCK_SIZE, Config.BLOCK_SIZE))
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect.topleft = (x, y)
|
||||
self.value: int = 2 if random.random() <= Config.BLOCK_VALUE_PROBABILITY else 4
|
||||
self.value: int = value if value is not None else 2 if random.random() <= Config.BLOCK_VALUE_PROBABILITY else 4
|
||||
self.font = pygame.font.SysFont(Config.FONT_FAMILY, Config.FONT_SIZE)
|
||||
self.update()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user