Last active
May 18, 2017 05:45
-
-
Save nattybear/2f8628c9733d78e94d91675711ad318d to your computer and use it in GitHub Desktop.
거북이 대포 게임 만들기
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle as t | |
import random | |
def turn_up(): | |
t.left(2) | |
def turn_down(): | |
t.right(2) | |
def fire(): | |
ang = t.heading() | |
while t.ycor() > 0: | |
t.forward(15) | |
t.right(5) | |
d = t.distance(target, 0) | |
t.sety(random.randint(10, 100)) | |
if d < 25: | |
t.color("blue") | |
t.write("Good!", False, "center", ("", 15)) | |
else: | |
t.color("red") | |
t.write("Bad!", False, "center", ("", 15)) | |
t.color("black") | |
t.goto(-200, 10) | |
t.setheading(ang) | |
t.goto(-300, 0) | |
t.down() | |
t.goto(300, 0) | |
target = random.randint(50, 150) | |
t.pensize(3) | |
t.color("green") | |
t.up() | |
t.goto(target - 25, 2) | |
t.down() | |
t.goto(target +25, 2) | |
t.color("black") | |
t.up() | |
t.goto(-200, 10) | |
t.setheading(20) | |
t.onkeypress(turn_up, "Up") | |
t.onkeypress(turn_down, "Down") | |
t.onkeypress(fire, "space") | |
t.listen() | |
t.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
좌표
각도
글자 쓰기
t.write("문자열", False, "center", ("", 15))
프로젝트 구조
SpaceBar
누르면 작동