1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #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() | cs |