파이썬 마우스

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 = … Read more

파이썬 키보드 조작

import pygame pygame.init() background = pygame.display.set_mode((1280, 760)) pygame.display.set_caption(“SONOL”) fps = pygame.time.Clock() x_pos = background.get_size()[0] // 2 y_pos = background.get_size()[1] // 2 to_x = 0 to_y = 0 play = True while play: deltaTime = fps.tick(60) for event in pygame.event.get(): if event.type == pygame.QUIT: # 창 닫기 이벤트 play = False if event.type == pygame.KEYDOWN: if … Read more

함수 리턴

def return_test(): return 100 value = return_test() print(value) def return_test(): return value = return_test() print(value) def sum_all(start, end): output = 0 for i in range(start, end + 1): output += i return output print(“0 to 100:”, sum_all(0, 100)) print(“0 to 1000:”, sum_all(0, 1000)) print(“50 to 100:”, sum_all(50, 100)) print(“500 to 1000:”, sum_all(500, 1000)) def sum_all(start=0, … Read more