Skip to content

Fix a couple of minor demo game bugs. #5762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/textual/demo/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def on_mount(self) -> None:
width, height = self.tile_size
self.styles.width = width
self.styles.height = height
column, row = self.position
column, row = self.start_position
self.set_scroll(column * width, row * height)
self.offset = self.position * self.tile_size

Expand Down Expand Up @@ -372,14 +372,16 @@ def compose(self) -> ComposeResult:
theme="material",
)
tile_width, tile_height = self.dimensions
blank_pos = self.dimensions - (1, 1)
self.state = "waiting"
yield Digits("")
with containers.HorizontalGroup(id="grid") as grid:
grid.styles.width = tile_width * self.tile_size[0]
grid.styles.height = tile_height * self.tile_size[1]
for row, column in product(range(tile_width), range(tile_height)):
position = Offset(row, column)
tile_no = self.locations[position]
tile_no = (row * tile_width) + column if position != blank_pos else None
self.locations[position] = tile_no
yield Tile(syntax, tile_no, self.tile_size, position)
if self.language:
self.call_after_refresh(self.shuffle)
Expand Down