python 특정 좌표에서 게임을 발생시키고 싶습니다.

ksm5318의 이미지

안녕하세요. 파이썬 공부를 하는 학생입니다.

이번에 간단한 게임을 만들고자 파이썬으로 프로그래밍 도중

특정 좌표에서 for문과 if문을 써서 사건을 발생시키고 싶은데.

무엇이 문제인지 안되네요...

그래서 사각형처리해서 그 내부에 들어오면 사건이라도 발생시키고 싶은데

사각형 그리고 그 주변위치를 어찌 잡아야할지 모르겠네요;;

import turtle
import random
wn=turtle.Screen()
t1=turtle.Turtle()
 
size=50
nMax=0
level="low"
wn.bgpic(Users\KimSungMoGram\Documents\p161+Maze.jpg) //제가 그린 미로입니다. 
 
def setPosition(pos): //위치를 잡아서 별을 그리기 위함.(특정위치 지정)
    t1.penup()
    t1.setpos(pos)
    t1.pendown()
    t1.right(72)
    t1.fd(20)
    for k in range (0,4):
        t1.right(144)
        t1.fd(20)
 
def drawStars():
    setPosition((200,200))
    setPosition((-200,200))
    setPosition((-200,-200))
    setPosition((200,-200))
    t1.penup()
    oldpos=t1.pos()
    oldhead=t1.heading()
    t1.home()
    t1.pendown()
 
drawStars()
 
level=raw_input("Choose level : high, mid, low ")
 
if (level=="high"): //이동 횟수를 제한시켜서 난이도 조절 
    nMax=20
elif (level=="mid"):
    nMax=35
elif(level=="low"):
    nMax=50   
 
for i in range(0,nMax):
    curser=raw_input()
    position = t1.pos()
    if t1.pos()==(200.00,200.00):       ///문제의 부분입니다. 입력을 받고 좌표를 반환시켜서 만약좌표
        print "Let the game begin"      //가 이와 같다면 게임을 시작시키고 싶습니다..
 
        player = raw_input("Enter your choice (rock/paper/scissors): ")
        player = player.lower()
        computer = random.randint(1,3)
        if (computer == 1):
                computer = "rock"
        elif (computer == 2):
                computer = "paper"
        elif (computer == 3):
                computer = "scissors"
        else:
            print ("Error. Enter your choice from rock, paper, scissors.")
 
        if (player == computer):
                print ("Draw!")
        elif (player == "rock"):
            if (computer == "paper"):
                    print ("You won.");
            if (computer == "scissors"):
                    print ("You lost.");
        elif (player == "paper"):
            if (computer == "rock"):
                    print ("You won.");
            if (computer == "scissors"):
                    print ("You lost.");
        elif (player == "scissors"):
            if (computer == "rock"):
                    print ("You lost.");
            if (computer == "paper"):
                    print ("You won.");
 
                     #restart
        userInput = raw_input("Finish? Yes or No: ")
        userInput = userInput.lower()
        if (userInput == "yes"):
                play = False
                print ("See you again.")
        else:
                play = True
 
 
 
    else:                        
        if (curser=="w"):
            t1.left(90)
            t1.fd(size)
        elif (curser=="d"):
            t1.fd(size)
        elif(curser=="s"):
            t1.right(90)
            t1.fd(size)
        elif(curser=="a"):
            t1.left(180)
            t1.fd(size)
        else:
            print("Error")
        position = t1.pos()
        print position
        t1.setheading(0)    //입력받아서 이동후 좌표 출력
 
 
## 만약 위치가 200,200 즉 별의 위치라면 이벤트 발생시키기. 
## 근데 200,200인데도 이벤트가 안뜹니다
## 근데 이 코드로 게임을 시작한다해도 그 다음에 wdas의 입력을 다시 받을 수 있나요? 아니면 다시 저 함수를 써서 되돌아가야하나요??? 

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.