码步停蹄 2022-08-23 11:06 采纳率: 80%
浏览 22
已结题

关于#PYGAME#的问题,如何解决?

**Pygame求解决方法
**

img

img

import pygame
import random

pygame.init()
screen = pygame.display.set_mode((600, 600))  # 创建窗口,设置大小

font_name = pygame.font.match_font('microsoftyahei')
fonts = pygame.font.Font(font_name, 30)
text = "EVERYONE HAS THE CROSS TO BEAR"
text_show = fonts.render(text, True, 'white')

EVENTA = pygame.USEREVENT  # 建立一个任意一个常量

pygame.time.set_timer(EVENTA, 2000)



class TexRun:
    def __init__(self):
        self.x = random.randint(20, 400)
        self.y = random.randint(20, 600)
        self.tex = text_show


while True:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
        if event.type == EVENTA:
            t1 = TexRun()
            screen.blit(t1.tex, (t1.x, t1.y))
        if event.type == EVENTB:
            del t1

    pygame.time.Clock().tick(5)
    pygame.display.update()


  • 写回答

1条回答 默认 最新

  • 浪客 2022-08-23 11:54
    关注

    screen.blit(t1.tex, (t1.x, t1.y))前面加一句
    screen.fill((0,0,0))

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 8月31日
  • 已采纳回答 8月23日
  • 创建了问题 8月23日

悬赏问题

  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示