tubeCoding
Python
Java demo
한국어(ko)
English(en)
한국어(ko)
로그인
회원가입
새 파일
CSV 파일 추가
파일 이름
취소
파일 생성
코드 실행
해당 파일은 텍스트 편집기에서 표시할 수 없습니다.
콘솔 출력
[{"type": "TextFile", "filename": "main.py", "content": "import turtle\r\n# \uc124\uc815\uac12\r\nHEIGHT = 10\r\nWIDTH = 20\r\nCELL_SIZE = 30 # \ud55c \uce78\uc758 \ud53d\uc140 \ud06c\uae30\r\nPLAYER_COLOR = 'blue'\r\nBG_COLOR = 'white'\r\n# turtle \uc138\ud305\r\nscreen = turtle.Screen()\r\nscreen.setup(width=WIDTH * CELL_SIZE + 40, height=HEIGHT * CELL_SIZE + 40)\r\nscreen.bgcolor(BG_COLOR)\r\nscreen.title(\"Turtle Car Lane Game\")\r\nscreen.tracer(0)\r\n# \ucc28\ub7c9 \uc0dd\uc131 (\ud55c \ubc88\ub9cc)\r\ncar = turtle.Turtle()\r\ncar.shape(\"square\")\r\ncar.shapesize(stretch_wid=3, stretch_len=2)\r\ncar.color(PLAYER_COLOR)\r\ncar.penup()\r\ncar.goto(0 + 125 + CELL_SIZE, -HEIGHT // 2 * CELL_SIZE + CELL_SIZE // 2)\r\ncar.showturtle()\r\n# \ucc28\ub7c9 \uc774\ub3d9 \uac70\ub9ac\r\nMOVE_STEP = 20\r\ndef move_left():\r\n # \uc790\uc720\ub86d\uac8c \uc88c\uce21\uc73c\ub85c \uc774\ub3d9\r\n car.setx(car.xcor() - MOVE_STEP)\r\n update()\r\ndef move_right():\r\n # \uc790\uc720\ub86d\uac8c \uc6b0\uce21\uc73c\ub85c \uc774\ub3d9\r\n car.setx(car.xcor() + MOVE_STEP)\r\n update()\r\ndef update():\r\n screen.update()\r\n# \ud0a4 \ubc14\uc778\ub529\r\nscreen.listen()\r\nscreen.onkeypress(move_left, \"Left\")\r\nscreen.onkeypress(move_right, \"Right\")\r\nupdate()\r\nscreen.mainloop()", "locked": true}]