import pygame, sys
from pygame.locals import *
pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.lock()
pygame.draw.rect(screen, (140,240,130), Rect((100,100),(130,170)))
screen.unlock()
pygame.display.update()
It's supposed to show a retangle in a 640x360 window, and it doesn't do that, and I don't know why it doesn't do that. Please help me.
It works like that:
You may be expected to behave differently?
The following code works for me well.
#!/usr/bin/python
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640,360),0,32)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.lock()
pygame.draw.rect(screen, (140,240,130), Rect((100,100),(130,170)))
screen.unlock()
pygame.display.update()
Though if you are facing any error, please share the error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.