Reputation: 161
I'm just going to give you all the code and say that I think it's probably something with the pygame. If someone sees the error or you try it on your own compiler and it works, it would be great if you could tell me what it is. Right now for me it just opens a black screen. Thanks so much, here's the code:
import pygame
from pygame.locals import *
pygame.init()
test = pygame.display.set_mode((1280, 660))
pygame.display.flip()
pygame.draw.rect(test, (255,255,255), (100, 100, 100, 100))
running = True
while running:
for event in pygame.event.get():
if event.type==QUIT:
running = False
pygame.quit()
Upvotes: 0
Views: 51
Reputation: 641
We want move pygame.display.flip()
after all the drawing commands. This is basically telling the program to update the screen after all the draw commands. That being said, all draw commands after this line will not be updated in the visual screen.
Here is the revised code:
import pygame
from pygame.locals import *
pygame.init()
test = pygame.display.set_mode((1280, 660))
pygame.draw.rect(test, (255,255,255), (100, 100, 100, 100))
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.type==QUIT:
running = False
pygame.quit()
Upvotes: 1
Reputation: 37
If you are using a white screen 255,255,255 is white and your rectangles are just white, try to use (0, 0, 0) or any other color what are you experiencing?
Edited:
The problem is with pygame.display.flip() it is updating the display you should call it after the call to draw
Upvotes: 0