import pygame
import winsound
import time
from datetime import timedelta
stime = []
timee = []
name = []
tnum = 0
done = True
knum = 0
schcnt = 0
k = 10
def schedule():
global schcnt
while True:
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])
schcnt += 1
print('e')
except:
break
#이걸 pygame에서
def do():
global schcnt
global done
global tnum
for i in range(schcnt):
ttime = int(time.time())
print(ttime)
duration = timedelta(seconds=ttime)
tsec = int(duration.total_seconds())
rsec = tsec % 3600
timeh = rsec // 60
timem = rsec % 60
print(timeh)
print(timem)
if timeh == stime[tnum][0] and timem == stime[tnum][1]:
pass
winsound.Beep(1000, 1000)
if done == True:
if timeh <= timee[tnum][0]:
garden()
elif timeh == timee[tnum][0]:
if timem <= timee[tnum][1]:
garden()
tnum += 1
def garden():
global k
global knum
knum += 1
print('flower')
winsound.Beep(1000, 1000)
# 모션 표시
if knum == k:
winsound.Beep(1000, 1000)
# 넘어가기
k += 5
knum = 0
top of page

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



import pygame import pygame_textinput import sys from datetime import datetime # 초기화 pygame.init() # 화면 설정 WIDTH, HEIGHT = 600, 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("하루 일정 관리 (3시 ~ 10시)") # 한글 폰트 설정 (환경에 맞게 경로 수정) font_path = "C:/Windows/Fonts/malgun.ttf" font = pygame.font.Font(font_path, 22) big_font = pygame.font.Font(font_path, 36) # 색상 정의 WHITE = (255, 255, 255) GRAY = (200, 200, 200) DARK_GRAY = (150, 150, 150) BLACK = (0, 0, 0) GREEN = (0, 200, 0) BLUE = (165, 205, 255) RED = (255, 25, 50) # 시간대 START_HOUR = 3 END_HOUR = 10 # 상태 변수 tasks = {} text_inputs = {} # 시간별 입력 객체 active_input = None score = 0 # 초기화 for i, hour in enumerate(range(START_HOUR, END_HOUR + 1)): tasks[hour] = { "text": "", "completed": False, "rect": pygame.Rect(50, 80 + i * 60, 300, 40), "btn_rect": pygame.Rect(370, 80 + i * 60, 100, 40) } # 텍스트 입력 객체 생성 text_inputs[hour] = pygame_textinput.TextInputVisualizer(font_object=font) # 입력 박스를 눌렀을 때 def handle_click(pos): global active_input for hour, task in tasks.items(): if task["rect"].collidepoint(pos) and not task["completed"]: active_input = hour text_inputs[hour].value = task["text"] elif task["btn_rect"].collidepoint(pos): if task["text"] and not task["completed"]: task["completed"] = True # if datetime.now().hour <= hour: global score score += 1 if active_input == hour: active_input = None # 키보드 이벤트 처리 def handle_key(event): global active_input if active_input is not None: if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN: tasks[active_input]["text"] = text_inputs[active_input].value active_input = None # 화면 그리기 def draw(events): global score screen.fill(WHITE) # 점수 표시 score_text = big_font.render(f"점수: {score}", True, BLACK) screen.blit(score_text, (50, 20)) # 일정들 for hour, task in tasks.items(): # 색상 결정 color = DARK_GRAY if task["completed"] else (BLUE if active_input == hour else GRAY) pygame.draw.rect(screen, color, task["rect"]) # 시간 텍스트 출력 time_text = font.render(f"{hour}시", True, BLACK) screen.blit(time_text, (task["rect"].x - 45, task["rect"].y + 8)) # 입력 중이면 textinput 사용 if active_input == hour: text_inputs[hour].update(events) screen.blit(text_inputs[hour].surface, (task["rect"].x + 5, task["rect"].y + 5)) elif task["text"]: text_surface = font.render(task["text"], True, BLACK) screen.blit(text_surface, (task["rect"].x + 10, task["rect"].y + 8)) # 버튼 그리기 enabled = bool(task["text"]) and not task["completed"] if enabled: btn_color = GREEN pygame.draw.rect(screen, btn_color, task["btn_rect"]) btn_text = font.render("완료하기", True, WHITE) elif task["completed"]: btn_color = RED pygame.draw.rect(screen, btn_color, task["btn_rect"]) btn_text = font.render("완료함", True, WHITE) else: btn_color = DARK_GRAY pygame.draw.rect(screen, btn_color, task["btn_rect"]) btn_text = font.render("일정 없음", True, WHITE) screen.blit(btn_text, (task["btn_rect"].x + 3, task["btn_rect"].y + 8)) pygame.display.flip() # 메인 루프 def main(): clock = pygame.time.Clock() while True: events = pygame.event.get() # 한 번만 호출! for event in events: if event.type == pygame.QUIT: pygame.quit() sys.exit() elif event.type == pygame.MOUSEBUTTONDOWN: handle_click(event.pos) elif event.type == pygame.KEYDOWN: handle_key(event) draw(events) clock.tick(30) if __name__ == "__main__": main()