Replace main.py

上级 d072def8
......@@ -23,26 +23,29 @@ def New_window(window_x,window_y,window_name,background):
background_imarges = pygame.image.load(f'./imarges/background/{background}.png').convert()
return screen,background_imarges
def New_file(screen,file_imarge,file_x,file_y,file_text,text_x,text_y,text_color,text_S,text_font):
def New_file(screen,file_imarge,file_x,file_y,file_text,text_x,text_y,text_color,text_S,text_font,text_bold,text_italic):
file_imarge = pygame.image.load(f'./imarges/{file_imarge}.png').convert()
font = pygame.font.Font(text_font,text_S)
font.set_bold(text_bold)
font.set_italic(text_italic)
file_text = font.render(file_text,True,text_color)
screen.blit(file_imarge,(file_x,file_y))
screen.blit(file_text,(text_x,text_y))
return None
def New_button(screen,event,button_imarge,button_x,button_y,text,text_x,text_y,text_color,text_S,text_font):
New_file(screen,button_imarge,button_x,button_y,text,text_x,text_y,text_color,text_S,text_font)
def New_button(screen,event,button_imarge,button_x,button_y,text,text_x,text_y,text_color,text_S,text_font,text_bold,text_italic):
New_file(screen,button_imarge,button_x,button_y,text,text_x,text_y,text_color,text_S,text_font,text_bold,text_italic)
def Opensys(a):
with open(a,encoding='UTF-8') as files:
file = files.readlines()
title = file[0].rstrip()
title_x,title_y = int(file[1].rstrip()),int(file[2].rstrip())
title_S,title_color = int(file[3].rstrip()),(int(file[4].rstrip()),int(file[5].rstrip()),int(file[6].rstrip()))
return title,title_x,title_y,title_S,title_color
title_bold,title_italic = bool(file[6].rstrip()),bool(file[7].rstrip())
return title,title_x,title_y,title_S,title_color,title_bold,title_italic
def first_window():
first_window,first_window_background = New_window(400,600,'说我(TAM) ——定义你自己','first_window')
title,title_x,title_y,title_S,title_color = Opensys('./sys/first_window/title.txt')
title,title_x,title_y,title_S,title_color,title_bold,title_italic = Opensys('./sys/first_window/title.txt')
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
......@@ -50,7 +53,7 @@ def first_window():
elif event.type == pygame.VIDEORESIZE:
size = (event.size[0], event.size[1])
first_window.blit(first_window_background,(0,0))
New_file(first_window,"title_box/first_window",0,0,title,title_x,title_y,title_color,title_S,'./sys/first_window/title.ttf')
New_file(first_window,"title_box/first_window",0,0,title,title_x,title_y,title_color,title_S,'./sys/first_window/title.ttf',title_bold,title_italic)
pygame.display.flip()
......@@ -60,3 +63,4 @@ t_First = threading.Thread(target = first_window)
t_First.start()
t_First.join()
pygame.quit()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册