0
정말 간단한 코드가 있습니다. 60fps에서 프로그램 루프가 발생하기 때문에 이전 마우스 클릭 상태를 참조하고 싶습니다. 즉, 마우스 클릭 상태의 변수로 '하나', 클릭하지 않은 경우 0, 클릭 한 경우 1이 있습니다. 내가 원하는 것은 마우스가 현재 클릭되어있는 경우입니다. 즉, 1 = 1 & 이전 값 1이 0이면 클릭 한 다음 마우스 좌표 인 mx와 my 값을 저장합니다. 코드 아래를 참조하십시오 :이전 프레임 값 참조하기 파이썬 파이 게임
이PDimageFull = pygame.image.load('F:\Project files\coils\PDsinwaveResize.jpg')
PDresX = 300
PDresY = 720
gameDisplay = pygame.display.set_mode((Display_Width,Display_Height))
pygame.display.set_caption('PD diagnostic tool')
clock = pygame.time.Clock()
def PDimage(x, y):
gameDisplay.blit(PDimageFull, (x, y))
# Defining our main programing loop
def mainProgram_loop():
dx1 = (Display_Width-PDresX)
dy1 = (Display_Height-PDresY)
gameExit = False
# Event handling
while not gameExit:
mx, my = pygame.mouse.get_pos()
one, two, three = pygame.mouse.get_pressed()
for event in pygame.event.get():
if event.type == pygame.QUIT:
gameExit = True
# This expression controls the movement of the overall PD graph
# The section in the IF statement defines the boundary by which you can move the object
if one == 1 and mx > dx1 and mx < dx1 + PDresX and my > dy1 and my < dy1+PDresY:
dx1 = dx1 + (mx - PDresX)
dy1 = dy1 + (my - PDresY)
gameDisplay.fill(white)
PDimage(dx1, dy1)
pygame.display.update()
clock.tick(60)
mainProgram_loop()
Brilliant! 고마워요. –
걱정하지 마세요. 기꺼이 도와주었습니다 (= – 101