|
10 | 10 | from dumbdisplay.layer_turtle import LayerTurtle |
11 | 11 | from dumbdisplay.layer_lcd import LayerLcd |
12 | 12 | from dumbdisplay_examples.tetris.tetris_common import Grid, _colors, _grid_n_rows, _grid_n_cols, _block_unit_width, \ |
13 | | - _width, _height, _left, _top, _draw_grid, _check_can_place_block_grid, _commit_block_grid |
| 13 | + _width, _height, _left, _top, _draw_grid, _check_can_place_block_grid, _commit_block_grid, Block |
14 | 14 |
|
15 | 15 | from dumbdisplay_examples.utils import DDAppBase, create_example_wifi_dd |
16 | 16 |
|
@@ -139,42 +139,42 @@ def _randomize_grid() -> Grid: |
139 | 139 | # |
140 | 140 | # |
141 | 141 |
|
142 | | -class Block: |
143 | | - def __init__(self, x: int, y: int, block_grid: Grid, block_pen: LayerTurtle): |
144 | | - self.x = x |
145 | | - self.y = y |
146 | | - self.block_grid = block_grid |
147 | | - self.block_pen = block_pen |
148 | | - block_pen.clear() |
149 | | - self.sync_image() |
150 | | - _draw_grid(block_grid, block_pen) |
151 | | - |
152 | | - def move_down(self, grid: Grid) -> bool: |
153 | | - if _check_can_place_block_grid(self.block_grid, self.x, self.y + 1, grid=grid): |
154 | | - return False |
155 | | - self.y += 1 |
156 | | - self.sync_image() |
157 | | - return True |
158 | | - |
159 | | - def move_right(self, grid: Grid) -> bool: |
160 | | - if _check_can_place_block_grid(self.block_grid, self.x + 1, self.y, grid=grid): |
161 | | - return False |
162 | | - self.x += 1 |
163 | | - self.sync_image() |
164 | | - return True |
165 | | - |
166 | | - def move_left(self, grid: Grid) -> bool: |
167 | | - if _check_can_place_block_grid(self.block_grid, self.x - 1, self.y, grid=grid): |
168 | | - return False |
169 | | - self.x -= 1 |
170 | | - self.sync_image() |
171 | | - return True |
172 | | - |
173 | | - def sync_image(self): |
174 | | - #anchor_x = (self.x - _INIT_BLOCK_X) * _block_unit_width |
175 | | - anchor_x = self.x * _block_unit_width |
176 | | - anchor_y = self.y * _block_unit_width |
177 | | - self.block_pen.setLevelAnchor(anchor_x, anchor_y) |
| 142 | +# class Block: |
| 143 | +# def __init__(self, x: int, y: int, block_grid: Grid, block_pen: LayerTurtle): |
| 144 | +# self.x = x |
| 145 | +# self.y = y |
| 146 | +# self.block_grid = block_grid |
| 147 | +# self.block_pen = block_pen |
| 148 | +# block_pen.clear() |
| 149 | +# self.sync_image() |
| 150 | +# _draw_grid(block_grid, block_pen) |
| 151 | +# |
| 152 | +# def move_down(self, grid: Grid) -> bool: |
| 153 | +# if _check_can_place_block_grid(self.block_grid, self.x, self.y + 1, grid=grid): |
| 154 | +# return False |
| 155 | +# self.y += 1 |
| 156 | +# self.sync_image() |
| 157 | +# return True |
| 158 | +# |
| 159 | +# def move_right(self, grid: Grid) -> bool: |
| 160 | +# if _check_can_place_block_grid(self.block_grid, self.x + 1, self.y, grid=grid): |
| 161 | +# return False |
| 162 | +# self.x += 1 |
| 163 | +# self.sync_image() |
| 164 | +# return True |
| 165 | +# |
| 166 | +# def move_left(self, grid: Grid) -> bool: |
| 167 | +# if _check_can_place_block_grid(self.block_grid, self.x - 1, self.y, grid=grid): |
| 168 | +# return False |
| 169 | +# self.x -= 1 |
| 170 | +# self.sync_image() |
| 171 | +# return True |
| 172 | +# |
| 173 | +# def sync_image(self): |
| 174 | +# #anchor_x = (self.x - _INIT_BLOCK_X) * _block_unit_width |
| 175 | +# anchor_x = self.x * _block_unit_width |
| 176 | +# anchor_y = self.y * _block_unit_width |
| 177 | +# self.block_pen.setLevelAnchor(anchor_x, anchor_y) |
178 | 178 |
|
179 | 179 |
|
180 | 180 |
|
|
0 commit comments