python3小游戏源代码_python 点球小游戏代码

#点球小游戏

from random import choice

import time

score=[0,0]

direction = ['left','center','right']

def kick():

print('====You Kick !====' )

time.sleep(1)

print ( 'Choose one side to shoot: ')

time.sleep(1)

print ( 'left,center,right')

time.sleep(1)

you = input()

print ('you kicked ' + you)

time.sleep(1)

com=choice(direction)

print('Computer saved '+com)

time.sleep(1)

if you != com:

print('Goal!')

time.sleep(1)

score[0] +=1

else:

print('Oops..')

time.sleep(1)

print('Score:%d(you) - %d(com) \n'%(score[0],score[1]))

time.sleep(1)

print('==== You Save !====' )

time.sleep(1)

print ( 'Choose one side to save: ')

time.sleep(1)

print ( 'left,center,right')

time.sleep(1)

you = input()

print ('you saved ' +you)

time.sleep(1)

com=choice(direction)

print('Computer Kicked '+com)

time.sleep(1)

if you == com:

print('Saved!')

time.sleep(1)

else:

print('Oops..')

time.sleep(1)

score[1] +=1

print('Score:%d(you) - %d(com) \n'%(score[0],score[1]))

time.sleep(1)

for i in range(5):

print('====Round %d ===='%(i+1))

time.sleep(1)

kick()

while(score[0]==score[1]):

i+=1

print('===Round %d ===='%(i+1))

time.sleep(1)

kick()

if score[0] > score[1]:

print('YoU Win !')

else:

print('You Lose !')

你可能感兴趣的:(python3小游戏源代码)