파이썬 마우스

import pygame

import pygame.draw

# 초기화

pygame.init()

# 화면 설정

background = pygame.display.set_mode((480, 360))

pygame.display.set_caption(“SONOL”)

x_pos = background.get_size()[0] // 2

y_pos = background.get_size()[1] // 2

play = True

while play:

# 이벤트 처리

for event in pygame.event.get():

if event.type == pygame.QUIT: # 창 닫기 이벤트

play = False

if event.type == pygame.MOUSEMOTION:

x_pos, y_pos = pygame.mouse.get_pos()

pygame.draw.circle(background,(255,0,255),(x_pos,y_pos), 10)

print(“MOUSEMOTION”)

print(pygame.mouse.get_pos())

if event.type == pygame.MOUSEBUTTONDOWN:

if event.button == 1:

background.fill((0,0,0))

print(“MOUSEBUTTONDOWN”)

if event.type == pygame.MOUSEBUTTONUP:

print(“MOUSEBUTTONUP”)

#background.fill((0,0,0))

#pygame.draw.circle(background,(255,0,255),(x_pos,y_pos), 10)

pygame.display.update()

pygame.quit()

Leave a Comment