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

关于#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日