좋아, 내 학교에서 우리는 시니어 프로젝트를해야하고, 나는 프로그램을 배우려고 노력했다. 시작하려면 VEX 클래스를 시작하기로 결정했습니다.이 클래스는 기본적인 "C"언어를 가르쳐주었습니다. 저는 실제 프로젝트를 위해 게임을 만들고 싶었 기 때문에 마우스로 벽을 만지지 않도록해야하는 어리석은 미로 게임 중 하나를 만들기로했습니다. 준비된 버튼 위로 마우스를 가져 가면 실제지도를로드 할 지점까지 도달하지만 실제 게임은 거기서 끝나지 않습니다. 지금까지의 코드는 미로입니다. 미로를로드 한 후 벽을 터치하거나 끝 지점을 터치 할 때 프로그램이 수행하지 않을 것이기 때문에 혼란 스럽습니다.파이 게임 미로 게임
import pygame
from pygame import *
pygame.init()
done = False
getready = image.load('ready.png')
backdrop = image.load('map.png')
goon = image.load('continue.png')
maze2 = image.load('map2.png')
loose = image.load('loose.png')
screen = display.set_mode((700, 500))
display.set_caption('Maze Game')
event.set_grab(1)
while done == False:
screen.blit(getready, (0, 0))
display.update()
for e in event.get():
if e.type == KEYUP:
if e.key == K_ESCAPE:
done = True
if screen.get_at((mouse.get_pos())) == (0, 0, 0):
while done == False:
screen.blit(backdrop, (0, 0))
display.update()
if screen.get_at((mouse.get_pos())) == (0, 0, 0):
print("You touched the wall!")
done = True
elif screen.get_at((mouse.get_pos())) == (0, 255, 0):
screen.blit(goon, (0, 0))
display.update()
if e in event.get():
if e.type == KEYUP:
if e.key == K_y:
screen.blit(maze2, (0, 0))
display.update()
if e in event.get():
if e.type == KEYUP:
if e.key == K_y:
done = True
if screen.get_at((mouse.get_pos())) == (0, 0, 0):
screen.blit(victory, (0, 0))
display.update()
time.sleep(3)
for e in event.get():
if e.type == KEYUP:
if e.key == K_ESCAPE:
done = True
pygame.quit()
나는 이것이 아마 정말 원유 코드 알고 있지만 난 그냥 시작 해요 명심하고, 어떤 도움이 입력에 감사드립니다 것을 :
UPDATE : 내가, 내 사촌 코드를 전송하고 그는 이것을 다음과 같이 변경했습니다 :
import pygame
from pygame import *
pygame.init()
done = False
done2 = False
ref = image.load('ready.png')
loose = image.load('loose.png')
cntnu = image.load('continue.png')
goon = 0
screen = display.set_mode((700, 500))
display.set_caption('Maze Game')
event.set_grab(1)
while done == False:
screen.blit(ref, (0, 0))
display.update()
done2 = False
for e in event.get():
if e.type == KEYUP:
if e.key == K_ESCAPE:
done = True
if screen.get_at((mouse.get_pos())) == (0, 0, 0):
ref = image.load('map.png')
done2 = True
if screen.get_at((mouse.get_pos())) == (1, 0, 0):
screen.blit(loose, (0, 0))
display.update()
done2 = True
time.wait(2000)
done = True
if screen.get_at((mouse.get_pos())) == (0, 255, 0):
screen.blit(cntnu, (0, 0))
display.update()
time.wait(3000)
pygame.quit()
사실 내 파이썬 문제는 내 파이썬 폴더에 없습니다. 파이썬 (새로운 인스톨러로)을 다시 설치했는데 제대로 작동합니다. 도움을 주신 모든 분들께 감사드립니다.
그래서 실제 문제는 무엇입니까? – Raptor
[여기 당신이 이해하는 데 도움이되는 비디오] (http://youtu.be/Nq0pB8M6XNY) –
는 (리눅스 머신에서) 코드를 시도했는데 사용했던 예제 이미지에서 작동합니다. 나는 get_pos()와 이미지의 색깔에 문제가 있다는 것을 기대한다. 색상 값을 print'ing하여 확인 했습니까? – zormit