[英]Nothing being displayed by Pygame
I am using Pygame for the first time so I am following a tutorial online.我是第一次使用 Pygame,所以我正在学习在线教程。 I recreated the code almost exactly and the window opens normally but nothing will display.
我几乎完全准确地重新创建了代码,窗口正常打开但不会显示任何内容。 I've tried copying other examples for simple Pygame setup and each time I run it the window opens but nothing else happens.
我尝试复制其他示例以进行简单的 Pygame 设置,每次运行它时,窗口都会打开,但没有其他任何反应。
I am using python 3.7.5我正在使用 python 3.7.5
Here is my code for reference:这是我的代码供参考:
import pygame
from pygame.locals import *
def game_init() :
global SURFACE_MAIN
SURFACE_MAIN = pygame.display.set_mode( ( GAME_WIDTH, GAME_HEIGHT ) )
pygame.display.set_caption( "rouge_like" )
def game_draw() :
# Clear surface
SURFACE_MAIN.fill( COLOR_DEFAULT_BG )
# Draw map
# Draw player
SURFACE_MAIN.blit( PLAYER_SPRITE, ( 100, 100 ) )
# Update display
pygame.display.flip()
pygame.display.update()
def game_main_loop() :
while True :
# Process events
for event in pygame.event.get() :
#print(event)
if event.type == QUIT :
pygame.quit()
sys.exit()
# Draw Game
game_draw()
def main() :
pygame.init()
game_init()
game_main_loop()
if __name__ == '__main__' :
main()
Turns out this is an issue with VSCode.原来这是 VSCode 的问题。 Running the program from my regular computer terminal works just fine.
从我的常规计算机终端运行该程序工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.