Beispiel #1
0
 def test_cell_spacing(self):
     b = Board(1, 1)
     _value = 7
     b.cell_spacing = _value
     self.assertEqual(b.cell_spacing, _value)
     b._setupUI()
     self.assertEqual(b.cell_spacing, _value)
     b.on_timer = lambda: b.close()
     b.start_timer(TIME_TO_CLOSE)
     b.show()
     self.assertEqual(b.cell_spacing, _value)
Beispiel #2
0
def cell_spacing_test():
    b = Board(1, 1)
    _value = 7
    b.cell_spacing = _value
    assert b.cell_spacing == _value
    b._setupUI()
    assert b.cell_spacing == _value
    b.on_timer = lambda: b.close()
    b.start_timer(TIME_TO_CLOSE)
    b.show()
    assert b.cell_spacing == _value
Beispiel #3
0
        previous_row = r  # Save last position
        previous_col = c


def newgame():
    global previous_row, previous_col, reversed_cards, match_count, attempts_count
    previous_row = previous_col = reversed_cards = match_count = attempts_count = 0
    game[0][0] = game[0][1] = 1
    game[0][2] = game[0][3] = 2
    game[1][0] = game[1][1] = 3
    game[1][2] = game[1][3] = 4
    game[2][0] = game[2][1] = 5
    game[2][2] = game[2][3] = 6
    game[3][0] = game[3][1] = 7
    game[3][2] = game[3][3] = 8
    game.shuffle()
    game.print(MSG)


game = Board(4, 4)
game.cell_size = 130
game.margin_color = game.grid_color = "wheat1"
game.cell_color = "wheat3"
game.cell_spacing = 2
game.title = "Memory Game"
game.create_output(background_color="wheat4", color="white")
game.on_mouse_click = fnmouse
game.on_key_press = fnkbd
game.on_start = newgame
game.show()
Beispiel #4
0
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()