python 2.7上的pygame,在macOS Mojave v10.14.6上使用pygame_WINDOW.screen.fill
我正在macOS Mojave上使用python 2.7.16解释器创建一个pygame窗口。 它加载了适当的窗口大小和位置,但没有添加背景色,我无法在此背景上绘制形状。pygame窗口保持空白白色表面,无论绘制表面和背景是什么,颜色都没有任何变化 屏幕应该是红色的,但无论我传递给python 2.7上的pygame,在macOS Mojave v10.14.6上使用pygame_WINDOW.screen.fill,python,python-2.7,pygame,Python,Python 2.7,Pygame,我正在macOS Mojave上使用python 2.7.16解释器创建一个pygame窗口。 它加载了适当的窗口大小和位置,但没有添加背景色,我无法在此背景上绘制形状。pygame窗口保持空白白色表面,无论绘制表面和背景是什么,颜色都没有任何变化 屏幕应该是红色的,但无论我传递给self.screen.fill((int,int,int))方法的值是什么,它都不会改变颜色 常数.py pygameWindowWidth = 1500 pygameWindowDepth = 1500 from
self.screen.fill((int,int,int))
方法的值是什么,它都不会改变颜色
常数.py
pygameWindowWidth = 1500
pygameWindowDepth = 1500
from pygameWindow import PYGAME_WINDOW
pygameWindow = PYGAME_WINDOW()
print(pygameWindow)
while True:
pygameWindow.Prepare()
pygameWindow.Draw_Black_Circle(100,100)
pygameWindow.Reveal()
realTimeDraw.py
pygameWindowWidth = 1500
pygameWindowDepth = 1500
from pygameWindow import PYGAME_WINDOW
pygameWindow = PYGAME_WINDOW()
print(pygameWindow)
while True:
pygameWindow.Prepare()
pygameWindow.Draw_Black_Circle(100,100)
pygameWindow.Reveal()
pygameWindow.py文件
import pygame
from constants import *
class PYGAME_WINDOW:
def __init__(self):
pygame.init()
self.width = pygameWindowWidth
self.depth = pygameWindowDepth
self.screen = pygame.display.set_mode((pygameWindowWidth, pygameWindowDepth))
def Prepare(self):
self.screen.fill((255, 0, 0))
def Reveal(self):
pygame.display.update()
def Draw_Black_Circle(self, x, y):
pygame.draw.circle(self.screen, (255, 0, 0), (x, y), 45, 0)
pygame.display.update()
要使程序工作,必须通过或来处理事件队列中挂起的事件。e、 g:
pygameWindow=PYGAME\u WINDOW()
运行=真
运行时:
对于pygame.event.get()中的事件:
如果event.type==pygame.QUIT:
运行=错误
pygameWindow.Prepare()
pygameWindow.绘制黑色圆圈(100100)
pygameWindow.discover()文件
这很有效!!!但你们知道为什么颜色只在终端而不是在pycharm中改变吗?