I wrote the following program about pygame
import sys
import pygame
from pygame.locals import QUIT
# globals
WINDOW_SIZE= (400,300)
WINDOW_TITLE="Pygame Count"
defmain():
pygame.init()
surface=pygame.display.set_mode (WINDOW_SIZE)
pygame.display.set_caption(WINDOW_TITLE)
sysfont=pygame.font.SysFont(None,36)
counter = 0
while True:
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
counter+=1
surface.fill((255,255,255))
count_image=sysfont.render(
"count is {0}".format(counter), True, (0, 0, 0))
pygame.display.update()
if__name__=="__main__":
main()
When you run this program, the following things happen:
(Run Environment: macOS Mojave, python 3.7.0, pygame 1.9.4)
The background color is the basic color of Mojave's dark mode.(When I changed to light mode, it turned white, which is the basic color, but there was no change in color.)
Also, I tested it by referring to the following, but I didn't see any color change.
https://stackoverflow.com/questions/41873581/pygame-surface-fill-not-working
On Windows, if you change the number, the color will look different.
import sys
import pygame
from pygame.locals import QUIT
# globals
WINDOW_SIZE= (400,300)
WINDOW_TITLE="Pygame Count"
defmain():
pygame.init()
surface=pygame.display.set_mode (WINDOW_SIZE)
pygame.display.set_caption(WINDOW_TITLE)
sysfont=pygame.font.SysFont(None,36)
counter = 0
while True:
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
counter+=1
surface.fill((255,255,255))#=>Change this number to change the background color.
count_image=sysfont.render(
"count is {0}".format(counter), True, (0, 0, 0))#=>The character color changes as well.
Surface.blit(count_image, (64,64))#=> Inserted to draw characters.
pygame.display.update()
Inserted a delay of time to see that the pygame.time.delay(100)#=> counter has changed.
if__name__=="__main__":
main()
There was only one article that moved when I clearly specified the number of python versions.
However, it seems that some other cases have not been resolved.
Screen.Fill() in Pygame isn't changing the screen
Why are my pygame images not getting the alpha set after changing from windows to mac
Pygame:display.update() does not update until after clock delay
pygame:window changing color after minimize and restore
This is Mac OS Mojave 10.14.6.I had the same problem with PYTHON programming that I can enjoy learning while making games.
PYTHON 3.7.3 (brew install)
pygame2.0.0.dev1
I installed it by specifying .
© 2024 OneMinuteCode. All rights reserved.