示例#1
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()
示例#2
0
        b[row][col] = IMGID if not b[row][col] else None
    elif btn == 3:
        b[row][col] = "fruit.png"


def timerfn():
    b.print(datetime.datetime.now().strftime("[H]: Help      %H:%M:%S"))


def startfn():
    b[0][0] = 12
    b[0][1] = "Hello"
    b[0][2] = b[4][1] = IMGID
    b[3][6] = "fruit.png"


b = Board(5, 15)
b.title = "Hello, World!"
b.margin = 10
b.cell_spacing = 6
b.cell_size = (50, 40)
b.margin_color = b.grid_color = "AntiqueWhite4"
b.cell_color = "AntiqueWhite1"
b.on_start = startfn
b.on_key_press = kbdfn
b.on_mouse_click = mousefn
b.on_timer = timerfn
b.start_timer(1000)
b.create_output(color='gray20', background_color='AntiqueWhite3', font_size=10)
b.show()