python运行时黑屏什么原因_为什么Pygame在运行我的代码时显示黑屏?

第一个for循环之后的return似乎是罪魁祸首。你能评论一下然后再试一次吗?

我认为代码应该是这样的:import pygame

from pygame.locals import *

from sys import exit

pygame.init()

screen = pygame.display.set_mode((640,480),0,32)

def create_scales(height):

red_scale_surface = pygame.surface.Surface((640,height))

blue_scale_surface = pygame.surface.Surface((640,height))

green_scale_surface = pygame.surface.Surface((640,height))

for x in range(640):

c = int((x/639.)*255.)

red = (c,0,0)

green = (0,c,0)

blue = (0,0,c)

line_rect = Rect(x,0,1,height)

pygame.draw.rect(red_scale_surface,red,line_rect)

pygame.draw.rect(green_scale_surface,green,line_rect)

pygame.draw.rect(blue_scale_surface,blue,line_rect)

return red_scale_surface, green_scale_surface, blue_scale_surface

red_scale, gre

Original: https://blog.csdn.net/weixin_42535703/article/details/113991739
Author: 王正威
Title: python运行时黑屏什么原因_为什么Pygame在运行我的代码时显示黑屏?

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/781308/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球