Pygame屏幕颜色将无法填充,直到屏幕移至开始菜单下方?

时间:2019-11-06 09:53:40

标签: pygame

我对python非常陌生,但我正在尝试在pygame中构建一个简单的游戏。我以前曾经使用过它,但是现在当我运行pygame时,背景色将无法填充。但是,如果我将pygame屏幕移到Windows开始菜单下方,则移至下面的部分将被填充。我在做什么错了?

这是代码(很抱歉,我的随机学习笔记内容如此):

import pygame

    #screen dimensions
SCREEN_TITLE = 'Crossy RPG'
SCREEN_WIDTH= 800
SCREEN_HEIGHT= 800
WHITE_COLOR=(255,255,255)#this is pure white and pure black
BLACK_COLOR=(0,0,0)
GREEN_COLOR=(0,255,200)
clock = pygame.time.Clock()#updates game events and frames (FPS)

class Game:

    TICK_RATE = 60
    def __init__(self, title, width, height):
        self.title = title
        self.width = width
        self.height = height

    #specified screen size
        self.game_screen = pygame.display.set_mode((width, height))
        self.game_screen.fill(WHITE_COLOR)
        pygame.display.set_caption(title)

    def run_game_loop(self):
        is_game_over = False

        #runs until is_game_over = True, this is a main loop updates with any gameplay
        while not is_game_over:
            #events are mouse movemnt, clicks, or buttons/keys
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    is_game_over = True

                print(event)

        pygame.display.update()
        clock.tick(self.TICK_RATE)




pygame.init()

new_game = Game(SCREEN_TITLE,SCREEN_WIDTH,SCREEN_HEIGHT)
new_game.run_game_loop()

0 个答案:

没有答案