음성고등학교 로고이미지

RSS 페이스북 공유하기 트위터 공유하기 카카오톡 공유하기 카카오스토리 공유하기 네이버밴드 공유하기 프린트하기
10117 전의규 (수정)
좋아요:0
작성자 한재민 등록일 19.12.18 조회수 247
첨부파일
녹화_2019_12_26_16_26_29_421.mp4 (3.58MB) (다운횟수:134)

인터넷 유튜브등에서 자료를 조사해 미로찾기 게임을 만들어보았습니다.

한번에 여러칸을 이동할 수 있도록 코드를 수정했습니다

 

from turtle import *

import keyboard

up()

goto(-187,212)

down()

goto(12,212)

up()

goto(-162,187)

down()

goto(-137,187)

up()

goto(-112,187)

down()

goto(-12,187)

up()

goto(-162,162)

down()

goto(-37,162)

up()

goto(-212,137)

down()

goto(-137,137)

up()

goto(-112,137)

down()

goto(-62,137)

up()

goto(-12,137)

down()

goto(12,137)

up()

goto(-212,112)

down()

goto(-187,112)

up()

goto(-62,112)

down()

goto(-12,112)

up()

goto(-87,87)

down()

goto(-37,87)

up()

goto(-162,62)

down()

goto(-137,62)

up()

goto(-112,62)

down()

goto(-62,62)

up()

goto(-162,37)

down()

goto(-112,37)

up()

goto(-187,12)

down()

goto(-162,12)

up()

goto(-87,12)

down()

goto(-62,12)

up()

goto(-37,12)

down()

goto(12,12)

up()

goto(-212,-12)

down()

goto(12,-12)

up()

goto(-212,212)

down()

goto(-212,-12)

up()

goto(-187,212)

down()

goto(-187,162)

up()

goto(-187,112)

down()

goto(-187,37)

up()

goto(-162,187)

down()

goto(-162,62)

up()

goto(-162,37)

down()

goto(-162,12)

up()

goto(-137,137)

down()

goto(-137,112)

up()

goto(-137,87)

down()

goto(-137,62)

up()

goto(-137,12)

down()

goto(-137,-12)

up()

goto(-112,137)

down()

goto(-112,62)

up()

goto(-112,37)

down()

goto(-112,-12)

up()

goto(-87,112)

down()

goto(-87,87)

up()

goto(-87,37)

down()

goto(-87,12)

up()

goto(-62,137)

down()

goto(-62,112)

up()

goto(-62,62)

down()

goto(-62,12)

up()

goto(-37,162)

down()

goto(-37,112)

up()

goto(-37,87)

down()

goto(-37,12)

up()

goto(-12,187)

down()

goto(-12,137)

up()

goto(-12,112)

down()

goto(-12,37)

up()

goto(12,212)

down()

goto(12,-12)

up()

x=0

y=0

goto(x,y)

setheading(180)

head=0

while (-200<=x<=0)and(0<=y<=200):

    if keyboard.is_pressed('w'):

        head = 'w'

    elif keyboard.is_pressed('s'):

        head = 's'

    elif keyboard.is_pressed('a'):

        head = 'a'

    elif keyboard.is_pressed('d'):

        head = 'd'

    if ((x==-50 and y==0)or(x==-100 and y==0)or(x==-125 and y==0)or(x==-150 and y==0)or(x==-200 and y==0)

        or(x==0 and y==25)or(x==-25 and y==25)or(x==-50 and y==25)or(x==-75 and y==25)or(x==-100 and y==25)or(x==-175 and y==25)or(x==-200 and y==25)

        or(x==0 and y==50)or(x==-25 and y==50)or(x==-50 and y==50)or(x==-125 and y==50)or(x==-175 and y==50)or(x==-200 and y==50)

        or(x==0 and y==75)or(x==-25 and y==75)or(x==-100 and y==75)or(x==-125 and y==75)or(x==-150 and y==75)or(x==-175 and y==75)or(x==-200 and y==75)

        or(x==0 and y==100)or(x==-75 and y==100)or(x==-100 and y==100)or(x==-125 and y==100)or(x==-150 and y==100)or(x==-175 and y==100)

        or(x==-25 and y==125)or(x==-50 and y==125)or(x==-125 and y==125)

        or(x==0 and y==150)or(x==-25 and y==150)or(x==-175 and y==150)or(x==-200 and y==150)

        or(x==0 and y==175)or(x==-125 and y==175)or(x==-175 and y==175)or(x==-200 and y==175))and head=="w":

        y=y+25

        setheading(90)

        goto(x,y)

    elif ((x==-50 and y==25)or(x==-100 and y==25)or(x==-125 and y==25)or(x==-150 and y==25)or(x==-200 and y==25)

          or(x==0 and y==50)or(x==-25 and y==50)or(x==-50 and y==50)or(x==-75 and y==50)or(x==-100 and y==50)or(x==-175 and y==50)or(x==-200 and y==50)

          or(x==0 and y==75)or(x==-25 and y==75)or(x==-50 and y==75)or(x==-125 and y==75)or(x==-175 and y==75)or(x==-200 and y==75)

          or(x==0 and y==100)or(x==-25 and y==100)or(x==-100 and y==100)or(x==-125 and y==100)or(x==-150 and y==100)or(x==-175 and y==100)or(x==-200 and y==100)

          or(x==0 and y==125)or(x==-75 and y==125)or(x==-100 and y==125)or(x==-125 and y==125)or(x==-150 and y==125)or(x==-175 and y==125)

          or(x==-25 and y==150)or(x==-50 and y==150)or(x==-125 and y==150)

          or(x==0 and y==175)or(x==-25 and y==175)or(x==-175 and y==175)or(x==-200 and y==175)

          or(x==0 and y== 200)or(x==-125 and y== 200)or(x==-175 and y== 200))and head=="s":

          y=y-25

          setheading(270)

          goto(x,y)

    elif ((x==-25 and y==0)or(x==-50 and y==0)or(x==-75 and y==0)or(x==-100 and y==0)or(x==-175 and y==0)or(x==-200 and y==0)

          or(x==-25 and y==25)or(x==-150 and y==25)or(x==-200 and y==25)

          or(x==-100 and y==50)or(x==-125 and y==50)or(x==-150 and y==50)or(x==-175 and y==50)

          or(x==-75 and y==75)or(x==-100 and y==75)

          or(x==-50 and y==100)or(x==-75 and y==100)or(x==-150 and y==100)

          or(x==-25 and y==125)or(x==-100 and y==125)or(x==-200 and y==125)

          or(x==-75 and y==150)or(x==-100 and y==150)or(x==-125 and y==150)or(x==-150 and y==150)or(x==-200 and y==150)

          or(x==-50 and y==-175)or(x==-75 and y==-175)or(x==-100 and y==-175)or(x==-125 and y==-175)or(x==-150 and y==175)

          or(x==-25 and y==200)or(x==-50 and y==200)or(x==-75 and y==200)or(x==-100 and y==200)or(x==-125 and y==200)or(x==-150 and y==200)or(x==-175 and y==200))and head=="d":

        x=x+25

        setheading(0)

        goto(x,y)

    elif ((x==0 and y==0)or(x==-25 and y==0)or(x==-50 and y==0)or(x==-75 and y==0)or(x==-150 and y==0)or(x==-175 and y==0)

          or(x==0 and y==25)or(x==-125 and y==25)or(x==-175 and y==25)

          or(x==-75 and y==50)or(x==-100 and y==50)or(x==-125 and y==50)or(x==-150 and y==50)

          or(x==-50 and y==75)or(x==-75 and y==75)

          or(x==-25 and y==100)or(x==-50 and y==100)or(x==-125 and y==100)

          or(x==0 and y==125)or(x==-75 and y==125)or(x==-175 and y==125)

          or(x==-50 and y==150)or(x==-75 and y==150)or(x==-100 and y==150)or(x==-125 and y==150)or(x==-175 and y==150)

          or(x==-25 and y==175)or(x==-50 and y==175)or(x==-75 and y==175)or(x==-100 and y==175)or(x==-125 and y==175)

          or(x==0 and y==200)or(x==-25 and y==200)or(x==-50 and y==200)or(x==-75 and y==200)or(x==-100 and y==200)or(x==-125 and y==200)or(x==-150 and y==200))and head=="a":

        x=x-25

        setheading(180)

        goto(x,y)

    else:

        goto(x,y)

    if x==-200 and y==200:

        print("you win!!!")

        break

 

from turtle import *

import keyboard

up()

goto(-187,212)

down()

goto(12,212)

up()

goto(-162,187)

down()

goto(-137,187)

up()

goto(-112,187)

down()

goto(-12,187)

up()

goto(-162,162)

down()

goto(-37,162)

up()

goto(-212,137)

down()

goto(-137,137)

up()

goto(-112,137)

down()

goto(-62,137)

up()

goto(-12,137)

down()

goto(12,137)

up()

goto(-212,112)

down()

goto(-187,112)

up()

goto(-62,112)

down()

goto(-12,112)

up()

goto(-87,87)

down()

goto(-37,87)

up()

goto(-162,62)

down()

goto(-137,62)

up()

goto(-112,62)

down()

goto(-62,62)

up()

goto(-162,37)

down()

goto(-112,37)

up()

goto(-187,12)

down()

goto(-162,12)

up()

goto(-87,12)

down()

goto(-62,12)

up()

goto(-37,12)

down()

goto(12,12)

up()

goto(-212,-12)

down()

goto(12,-12)

up()

goto(-212,212)

down()

goto(-212,-12)

up()

goto(-187,212)

down()

goto(-187,162)

up()

goto(-187,112)

down()

goto(-187,37)

up()

goto(-162,187)

down()

goto(-162,62)

up()

goto(-162,37)

down()

goto(-162,12)

up()

goto(-137,137)

down()

goto(-137,112)

up()

goto(-137,87)

down()

goto(-137,62)

up()

goto(-137,12)

down()

goto(-137,-12)

up()

goto(-112,137)

down()

goto(-112,62)

up()

goto(-112,37)

down()

goto(-112,-12)

up()

goto(-87,112)

down()

goto(-87,87)

up()

goto(-87,37)

down()

goto(-87,12)

up()

goto(-62,137)

down()

goto(-62,112)

up()

goto(-62,62)

down()

goto(-62,12)

up()

goto(-37,162)

down()

goto(-37,112)

up()

goto(-37,87)

down()

goto(-37,12)

up()

goto(-12,187)

down()

goto(-12,137)

up()

goto(-12,112)

down()

goto(-12,37)

up()

goto(12,212)

down()

goto(12,-12)

up()

x=0

y=0

goto(x,y)

setheading(180)

head=0

while (-200<=x<=0)and(0<=y<=200):

    if keyboard.is_pressed('w'):

        head = 'w'

    elif keyboard.is_pressed('s'):

        head = 's'

    elif keyboard.is_pressed('a'):

        head = 'a'

    elif keyboard.is_pressed('d'):

        head = 'd'

    if ((x==-50 and y==0)or(x==-100 and y==0)or(x==-125 and y==0)or(x==-150 and y==0)or(x==-200 and y==0)

        or(x==0 and y==25)or(x==-25 and y==25)or(x==-50 and y==25)or(x==-75 and y==25)or(x==-100 and y==25)or(x==-175 and y==25)or(x==-200 and y==25)

        or(x==0 and y==50)or(x==-25 and y==50)or(x==-50 and y==50)or(x==-125 and y==50)or(x==-175 and y==50)or(x==-200 and y==50)

        or(x==0 and y==75)or(x==-25 and y==75)or(x==-100 and y==75)or(x==-125 and y==75)or(x==-150 and y==75)or(x==-175 and y==75)or(x==-200 and y==75)

        or(x==0 and y==100)or(x==-75 and y==100)or(x==-100 and y==100)or(x==-125 and y==100)or(x==-150 and y==100)or(x==-175 and y==100)

        or(x==-25 and y==125)or(x==-50 and y==125)or(x==-125 and y==125)

        or(x==0 and y==150)or(x==-25 and y==150)or(x==-175 and y==150)or(x==-200 and y==150)

        or(x==0 and y==175)or(x==-125 and y==175)or(x==-175 and y==175)or(x==-200 and y==175))and head=="w":

        y=y+25

        setheading(90)

        goto(x,y)

    elif ((x==-50 and y==25)or(x==-100 and y==25)or(x==-125 and y==25)or(x==-150 and y==25)or(x==-200 and y==25)

          or(x==0 and y==50)or(x==-25 and y==50)or(x==-50 and y==50)or(x==-75 and y==50)or(x==-100 and y==50)or(x==-175 and y==50)or(x==-200 and y==50)

          or(x==0 and y==75)or(x==-25 and y==75)or(x==-50 and y==75)or(x==-125 and y==75)or(x==-175 and y==75)or(x==-200 and y==75)

          or(x==0 and y==100)or(x==-25 and y==100)or(x==-100 and y==100)or(x==-125 and y==100)or(x==-150 and y==100)or(x==-175 and y==100)or(x==-200 and y==100)

          or(x==0 and y==125)or(x==-75 and y==125)or(x==-100 and y==125)or(x==-125 and y==125)or(x==-150 and y==125)or(x==-175 and y==125)

          or(x==-25 and y==150)or(x==-50 and y==150)or(x==-125 and y==150)

          or(x==0 and y==175)or(x==-25 and y==175)or(x==-175 and y==175)or(x==-200 and y==175)

          or(x==0 and y== 200)or(x==-125 and y== 200)or(x==-175 and y== 200))and head=="s":

          y=y-25

          setheading(270)

          goto(x,y)

    elif ((x==-25 and y==0)or(x==-50 and y==0)or(x==-75 and y==0)or(x==-100 and y==0)or(x==-175 and y==0)or(x==-200 and y==0)

          or(x==-25 and y==25)or(x==-150 and y==25)or(x==-200 and y==25)

          or(x==-100 and y==50)or(x==-125 and y==50)or(x==-150 and y==50)or(x==-175 and y==50)

          or(x==-75 and y==75)or(x==-100 and y==75)

          or(x==-50 and y==100)or(x==-75 and y==100)or(x==-150 and y==100)

          or(x==-25 and y==125)or(x==-100 and y==125)or(x==-200 and y==125)

          or(x==-75 and y==150)or(x==-100 and y==150)or(x==-125 and y==150)or(x==-150 and y==150)or(x==-200 and y==150)

          or(x==-50 and y==-175)or(x==-75 and y==-175)or(x==-100 and y==-175)or(x==-125 and y==-175)or(x==-150 and y==175)

          or(x==-25 and y==200)or(x==-50 and y==200)or(x==-75 and y==200)or(x==-100 and y==200)or(x==-125 and y==200)or(x==-150 and y==200)or(x==-175 and y==200))and head=="d":

        x=x+25

        setheading(0)

        goto(x,y)

    elif ((x==0 and y==0)or(x==-25 and y==0)or(x==-50 and y==0)or(x==-75 and y==0)or(x==-150 and y==0)or(x==-175 and y==0)

          or(x==0 and y==25)or(x==-125 and y==25)or(x==-175 and y==25)

          or(x==-75 and y==50)or(x==-100 and y==50)or(x==-125 and y==50)or(x==-150 and y==50)

          or(x==-50 and y==75)or(x==-75 and y==75)

          or(x==-25 and y==100)or(x==-50 and y==100)or(x==-125 and y==100)

          or(x==0 and y==125)or(x==-75 and y==125)or(x==-175 and y==125)

          or(x==-50 and y==150)or(x==-75 and y==150)or(x==-100 and y==150)or(x==-125 and y==150)or(x==-175 and y==150)

          or(x==-25 and y==175)or(x==-50 and y==175)or(x==-75 and y==175)or(x==-100 and y==175)or(x==-125 and y==175)

          or(x==0 and y==200)or(x==-25 and y==200)or(x==-50 and y==200)or(x==-75 and y==200)or(x==-100 and y==200)or(x==-125 and y==200)or(x==-150 and y==200))and head=="a":

        x=x-25

        setheading(180)

        goto(x,y)

    else:

        goto(x,y)

    if x==-200 and y==200:

        print("you win!!!")

        break

 

 

이전글 10221최재민 파이썬 타자게임
다음글 동아리 활동 결과 보고서