|
20鱼币
- import pygame
- import sys
- from pygame.locals import *
- pygame.init()
- size = width, height = 600, 400
- white = (255, 255, 255)
- fullscreen = False
- modes = pygame.display.list_modes()
- clock = pygame.time.Clock()
- bg = pygame.transform.smoothscale(pygame.image.load("waterfall.jpg"), (650, 450))
- pygame.display.set_caption("MyUndertale")
- screen = pygame.display.set_mode(size)
- bg_position = size[0] // 2 - 300, size[1] // 2 - 200
- F4_font = pygame.font.Font(None, 20)
- while True:
- screen.blit(bg, bg_position)
- for event in pygame.event.get():
- if event.type == QUIT:
- sys.exit()
- if event.type == KEYDOWN:
- if event.key == K_F4:
- fullscreen = not fullscreen
- if fullscreen:
- bg_position = modes[0][0] // 2 - 960, modes[0][1] // 2 - 700
- bg = pygame.transform.smoothscale(pygame.image.load("waterfall.jpg"), (1950, 1350))
- screen = pygame.display.set_mode(modes[0], FULLSCREEN | HWSURFACE)
- else:
- bg_position = size[0] // 2 - 300, size[1] // 2 - 200
- bg = pygame.transform.smoothscale(pygame.image.load("waterfall.jpg"), (650, 450))
- screen = pygame.display.set_mode(size)
- F4_text = F4_font.render("请按下F4变成全屏", True, white)
- screen.blit(F4_text, (200, 200))
-
- pygame.display.flip()
- clock.tick(100)
- #pygame.time.delay(10)
复制代码
问为什么文字"请按下F4变成全屏"打不出来?
默认字体None不支持中文
字体你改成pygame.font.SysFont("字体", 大小)
pygame.font.get_fonts()也很好用
|
最佳答案
查看完整内容
默认字体None不支持中文
字体你改成pygame.font.SysFont("字体", 大小)
pygame.font.get_fonts()也很好用
|