MacOS下Python下使用pygame输出颜色不对

Keris1024 2019-01-14 11:51:45
跟着Python入门到实践里面,用pygame弄出来 的窗口一直都是白色的。不知道为什么。

import sys
import pygame
def run_game():
pygame.init()
screen=pygame.display.set_mode((1200,800))
pygame.display.set_caption("Alien Invasion")
bg_color=(230,230,230)
while True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()
screen.fill(bg_color)
pygame.display.flip()
run_game()

pygame运行如下。

希望大神们帮忙看一下
...全文
164 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Keris1024 2019-01-14
  • 打赏
  • 举报
回复
那个rgb的值怎么改,都永远是这个颜色。。。。
Keris1024 2019-01-14
  • 打赏
  • 举报
回复
我使用的是Python3,macOS Mojave10.14.2
陈年椰子 2019-01-14
  • 打赏
  • 举报
回复
引用 2 楼 Keris1024 的回复:
那个rgb的值怎么改,都永远是这个颜色。。。。


参考下这篇文章
https://blog.csdn.net/qq_24909089/article/details/83542526
陈年椰子 2019-01-14
  • 打赏
  • 举报
回复
win 下代码没啥问题。
bg_color=(0,0,255)
看到是蓝色。
python命令行方式,直接运行py文件试试?

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧