Pygame sceen.fill() 没有正确填充颜色 [英] Pygame sceen.fill() not filling up the color properly
本文介绍了Pygame sceen.fill() 没有正确填充颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始学习 Pygame .我正在关注本教程.我运行了以下程序,但它显示黑色而不是蓝色:
I've just started learning Pygame . I'm following this tutorial. I ran the following program but it shows black color instead of blue :
import pygame
h = input("Enter the height of the window : ")
w = input("Enter the width of the window : ")
screen = pygame.display.set_mode((w,h))
running = True
while running:
event = pygame.event.poll()
if event.type == pygame.QUIT:
running=0
screen.fill((0,0,1))
pygame.display.flip()
推荐答案
对于蓝色,您应该使用 255
作为元组中的第三个元素,而不是 1
.
For Blue color, you should use 255
as the third element in the tuple, not 1
.
示例 -
while running:
event = pygame.event.poll()
if event.type == pygame.QUIT:
running=0
screen.fill((0,0,255))
pygame.display.flip()
这篇关于Pygame sceen.fill() 没有正确填充颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文