def test_margin(self): b = Board(7, 1) _value = 19 b.margin = _value self.assertEqual(b.margin, _value) b._setupUI() self.assertEqual(b.margin, _value) b.on_timer = lambda: b.close() b.start_timer(TIME_TO_CLOSE) b.show() self.assertEqual(b.margin, _value)
def margin_test(): b = Board(7, 1) _value = 19 b.margin = _value assert b.margin == _value b._setupUI() assert b.margin == _value b.on_timer = lambda: b.close() b.start_timer(TIME_TO_CLOSE) b.show() assert b.margin == _value
if field[r][c] is None: # It must be an empty place field[r][c] = "fruit" break def setup(): global snake, lastkey w2 = FIELD_WIDTH // 2 # field center h2 = FIELD_HEIGHT // 2 field.fill(None) snake = [(h2, w2), (h2, w2 + 1)] # Initial snake position for pos in snake: field[pos[0]][pos[1]] = 'body' # Draw the snake fruit_random_position() lastkey = "Left" # starts moving to the left field.start_timer(300) # 300 ms field = Board(FIELD_HEIGHT, FIELD_WIDTH) field.cell_size = BLOCK_SIZE field.title = "Snake game" field.cursor = None # Hide the cursor field.margin = 10 field.grid_color = "dark sea green" field.margin_color = "dark sea green" field.cell_color = "PaleGreen4" field.on_key_press = kbd_fn field.on_timer = timer_fn setup() field.show()
from game2dboard import Board b = Board(8, 8) b.title = "Playground!" b.margin = 21 b.cell_size = 74 b.cell_spacing = 1 b.background_image = "chess" b.create_output(color='gray20', background_color='AntiqueWhite3', font_size=10) b.on_mouse_click = lambda btn, r, c : b.print("Clicked on [{}][{}]".format(r, c)) b.print("Click me") b.show()
def fntimer(): b.shuffle() b.start_timer(500) b = Board(3, 12) b[1][0] = 'H' b[1][1] = 'e' b[1][2] = 'l' b[1][3] = 'l' b[1][4] = 'o' b[1][5] = 'comma' b[1][6] = 'W' b[1][7] = 'o' b[1][8] = 'r' b[1][9] = 'l' b[1][10] = 'd' b[1][11] = 'excl' b.cell_size = (80, 100) b.title = "WTF????" b.margin = 10 b.cell_spacing = 3 b.grid_color = b.margin_color = "AntiqueWhite3" b.cell_color = "gray20" b.start_timer(2000) b.on_timer = fntimer b.show()
from game2dboard import Board b = Board(8, 8) b.title = "Playground!" b.margin = 0 b.cell_spacing = 1 b.cell_size = 80 b.margin_color = None b.grid_color = "red" b.cell_color = "green" # b.background_image = "chess" b.create_output(color='gray20', background_color='AntiqueWhite3', font_size=10) b.show()