#6-6: Robot°ú YouÀÇ °¡À§/¹ÙÀ§/º¸ °ÔÀÓ ¿ÏÀü ÇÁ·Î±×·¥
'''
´Ü°è 1ÀÇ ¼Ò½ºÄÚµå 6-4.py
01ÁÙºÎÅÍ 27ÁÙ±îÁö Äڵ带 º¹»ç
'''
import turtle, random
imgGawi = "gawi.gif"
imgBawi = "bawi.gif"
imgBo = "bo.gif"
sc = turtle.Screen()
sc.addshape(imgGawi)
sc.addshape(imgBawi)
sc.addshape(imgBo)
def create_player(no, name) :
t = turtle.Turtle()
t.up()
t.goto(-300*(1-no),200)
t.write("***"+ name +"***", font="±¼¸² 20 bold")
return t
def robot_start() :
select = random.randint(0, 2)
if select == 0 :
robot.shape(imgGawi)
elif select == 1:
robot.shape(imgBawi)
else :
robot.shape(imgBo)
return select
def game_run() :
y_gbb = int(input("°¡À§(0), ¹ÙÀ§(1), º¸(2):"))
r_gbb = robot_start()
t1.clear()
if y_gbb == 0 :
you.shape(imgGawi)
if r_gbb == 0:
t1.write("ºñ°åÀ½!", font="±¼¸² 14 bold")
elif r_gbb == 1:
t1.write("Robot ½Â!", font="±¼¸² 14 bold")
else:
t1.write("You ½Â!", font="±¼¸² 14 bold")
elif y_gbb == 1:
if r_gbb == 0:
t1.write("You ½Â!", font="±¼¸² 14 bold")
elif r_gbb == 1:
t1.write("ºñ°åÀ½!", font="±¼¸² 14 bold")
else:
t1.write("Robot ½Â!", font="±¼¸² 14 bold")
you.shape(imgBawi)
else :
you.shape(imgBo)
if r_gbb == 0:
t1.write("Robot ½Â!", font="±¼¸² 14 bold")
elif r_gbb == 1:
t1.write("You ½Â!", font="±¼¸² 14 bold")
else:
t1.write("ºñ°åÀ½!", font="±¼¸² 14 bold")
robot = create_player(0, "Robot")
robot.goto(-150*(1-0),0)
you = create_player(2, "You")
you.goto(-150*(1-2),0)
t1 = create_player(1, "°¡À§!¹ÙÀ§!º¸!")
sc.onkeypress(game_run, "space")
sc.listen()