コード例 #1
0
ファイル: 48.py プロジェクト: banksee/2048
g2048 = Field(size=4)

while True:

    # Print current state of field
    g2048.print_field()

    # Choosing the direction
    print 'Choose direction \'WASD\' (or \'q\' for exit) >>>',
    direction = raw_input()
    direction.lower()

    if direction == 'q':
        break
    elif direction in ['w', 'a', 's', 'd']:
        g2048.make_move(direction)

    # Checking whether user win or lose
    win_check = g2048.check()
    if win_check == 'win':
        print 'YOU WON!'
        g2048.print_field()
        break
    elif win_check == 'lose':
        print 'You\'ve lost, try again!'
        g2048.print_field()
        break
    else:
        # os.system('cls' if os.name == 'nt' else 'clear')
        continue