디시인사이드 갤러리

갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

엄준식

ㅇㅇ(183.99) 2023.05.16 11:10:57
조회 52 추천 0 댓글 0

import turtle as t


import random


  

score=0

playing =False


te1 = t.Turtle()

te1.shape("turtle")

te1.color("red")

te1.speed(0)

te1.up()

te1.goto(0,200)


te2 = t.Turtle()

te2.shape("turtle")

te2.color("yellow")

te2.speed(0)

te2.up()

te2.goto(0,150)


ts1 = t.Turtle()

ts1.shape("circle")

ts1.color("green")

ts1.up()

ts1.goto(0,-200)



ts2 = t.Turtle()

ts2.shape("circle")

ts2.color("blue")

ts2.up()

ts2.goto(0,-100)


def turn_right():

    t.setheading(0)


def turn_up():

    t.setheading(90)


def turn_left():

    t.setheading(180)


def turn_down():

    t.setheading(270)


def start():

    global playing

    if playing == False:

        playing = True

        t.clear()

        play()


def play():

    global score

    global playing

    t.forward(10)

    if random.randint(1,7) == 4:

       ang = te1.towards(t.pos())

       te1.setheading(ang)

    speed = score +5

    if speed > 15:

        speed = 15

    te1.forward(speed)

    if random.randint(1, 7) == 4:

        ang = te2. towards(t.pos())

        te2.setheading(ang)

    speed = score + 5

    if speed >15:

        speed = 15

    te2.forward(speed)

    if t.distance(te1) < 12:

        text = "Score:" + str(score)

        message("Game Over", text)

        playing = False

        score = 0

    if t.distance(te2) < 12:

        score= score +1

        t.write(score)

        star_x1= random.randint( -230,230)

        star_y1 = random.randint(-230,230)

        ts1.goto(star_x1 ,  star_y1)

    if t.distance(ts2)<12:

        score=score +1

        r.write(score)

        star_x2 = random.randint(-230,230)

        star_y2 = random.randint(-230, 230)

        ts2.goto(star_x2,star_y2)

    if playing:

        t.ontimer(play, 100)


def message(m1,m2):

    t.clear()

    t.goto(0,100)

    t.write(m1,False, "center",("",20))

    t.goto(0,-100)

    t.write(m2, False, "center", ("",15))

    t.home()


t.title("Turtle Run")

t.setup(500, 500)

t.bgcolor("orange")

t.shape("turtle")

t.speed(0)

t.up()

t.color("white")

t.onkeypress(turn_right,"Right")

t.onkeypress(turn_up,"Up")

t.onkeypress(turn_left,"Left")

t.onkeypress(turn_down,"Down")

t.onkeypress(start,"space")

t.listen()

message("Turtle Run", "[Space]")



추천 비추천

0

고정닉 0

2

댓글 영역

전체 댓글 0
등록순정렬 기준선택
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 연예인 안됐으면 어쩔 뻔, 누가 봐도 천상 연예인은? 운영자 24/06/17 - -
15 내 섹파는 양ㅅㅂ SEX(49.169) 06.12 21 0
14 내 섹파는 노래방 기계임 성관계(49.169) 06.09 20 0
12 이 갤을 뭐하는 갤이노? ㅇㅇ(59.10) 23.07.11 74 0
11 엄준식 ㅇㅇ(211.217) 23.05.23 68 0
10 내 여친 얼평좀 ㅇㅇ(106.101) 23.05.17 181 0
엄준식 ㅇㅇ(183.99) 23.05.16 52 0
8 . [3] 오옹 나이스(211.243) 23.05.07 117 0
7 예전 미술 쌤 어디 학교로 갔나? 이** 미술 티처 ㅇㅇ(211.107) 23.04.27 126 1
5 HARCASS [2] 고예준 순결도둑(1.232) 22.05.10 203 15
3 노무현은 살아있다! hkhhkh1217a(211.114) 22.04.05 126 0
2 본인이 3학년이면 개추 [2] ㅇㅇ(58.140) 22.03.30 193 4
1
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2