# import pygame
# import time
#
# starttime = []
# timetime = []
# name = []
# end = False
# k = 10
#
# def schedule():
# global snum
# while not end:
# try:
# nam, starttim, timetim = input().split()
# name.append(nam)
# starttime.append(starttim)
# timetime.append(timetim)
# except EOFError:
# end = True
#
#
# schedule()
import pygame
import sys
# 초기화
pygame.init()
# 화면 설정
screen = pygame.display.set_mode((1960, 480))
pygame.display.set_caption('키보드 입력 예제')
# 색상 설정
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
# 폰트 설정
font = pygame.font.Font(None, 74)
# 텍스트 초기화
text = ""
text_surface = font.render(text, True, BLACK)
# 메인 루프
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
elif event.key == pygame.K_BACKSPACE:
text = text[:-1] # 마지막 문자 삭제
else:
text += event.unicode # 입력된 키 추가
text_surface = font.render(text, True, BLACK) # 텍스트 렌더링
# 화면 채우기
screen.fill(WHITE)
# 텍스트 화면에 그리기
screen.blit(text_surface, (20, 20))
# 화면 업데이트
pygame.display.flip()
# 종료 처리
pygame.quit()
sys.exit()
# 출처: https: // originalchoi.tistory.com / entry / pygame - 으로 - 미니 - 게임 - 만들기[originalchoi:티스토리]top of page

실제 작동 상태를 확인하려면 라이브 사이트로 이동하세요.
2025.09.28
2025.09.28
댓글 1개
좋아요
댓글(1)
더 이상 게시물에 대한 댓글 기능이 지원되지 않습니다. 자세한 사항은 사이트 소유자에게 문의하세요.
bottom of page



import pygame import time stime = [] timee = [] name = [] tnum = 0 end = False done = False k = 10 def schedule(): global end while not end: try: nam, st, tt = input().split() sth, stm = map(int, st.split(':')) tth, ttm = map(int, tt.split(':')) name.append(nam) stime.append([sth, stm]) timee.append([tth, ttm]) except EOFError: end = True #이걸 화면에서 def do(): global done global tnum while not done: ttime = int(time.time()) if ttime == stime[tnum]: pass # 소리내기 elif ttime == timee[tnum]: tnum += 1 schedule() do() # import pygame # import sys # # # 초기화 # pygame.init() # # # 화면 설정 # screen = pygame.display.set_mode((1960, 480)) # pygame.display.set_caption('키보드 입력 예제') # # # 색상 설정 # WHITE = (255, 255, 255) # BLACK = (0, 0, 0) # # # 폰트 설정 # font = pygame.font.Font(None, 74) # # # 텍스트 초기화 # text = "" # text_surface = font.render(text, True, BLACK) # # # 메인 루프 # running = True # while running: # for event in pygame.event.get(): # if event.type == pygame.QUIT: # running = False # elif event.type == pygame.KEYDOWN: # if event.key == pygame.K_ESCAPE: # running = False # elif event.key == pygame.K_BACKSPACE: # text = text[:-1] # 마지막 문자 삭제 # else: # text += event.unicode # 입력된 키 추가 # text_surface = font.render(text, True, BLACK) # 텍스트 렌더링 # # # 화면 채우기 # screen.fill(WHITE) # # # 텍스트 화면에 그리기 # screen.blit(text_surface, (20, 20)) # # # 화면 업데이트 # pygame.display.flip() # # # 종료 처리 # pygame.quit() # sys.exit()