Previously to ask this question it is worth noting that I have consulted several sources looking for some answer to my problem. None of them seems to have served. Despite trying to solve my problem on my own, rereading the code, the error still exists.
Here is my code:
import pygame,sys
from pygame.locals import *
from random import randint
pygame.init()
ventana = pygame.display.set_mode((1000,1000))
#abajo se encuentra el fondo de la ventana
#ventana.fill(ColorDos)
pygame.display.set_caption("Retouch")
Mi_imagen = pygame.image.load("Image/meflag.png")
Imagen_Dos = pygame.image.load("Image/Kool-Aid.gif")
posX= randint (100, 300)
posY = randint (101, 200)
velocidad=4
Color = (66, 133 ,244)#Azul
ColorDos = pygame.Color(244, 180, 0)#Amarillo
ColorTres = (244,67,54)#Rojo
ColorCuatro = (0,135,68) #verde
derecha=True
rectangulo = pygame.Rect(0,0,100,50)
print posY, posX
# Color = (244,180,0)
#primero donde, despues, color(tupla u objeto), tupla de cordenadas en X, Y. El ultimo parametro es el tamano del radio.
pygame.draw.circle(ventana, Color, (200, 300), 500)
"""Primero donde, despues que color, despues tupla con cuatro valores.
Los primeros dos valores (X,Y) son la esquina izquierda superior.
El tercer valor es el ancho de nuestro rectangulo.
Y el cuarto valor es el alto del rectangulo:"""
pygame.draw.rect(ventana, ColorCuatro,(100,100,100,50) )
"""Primero donde, despues color, despues el tercer parametro es una tupla con tuplas dentro de esta.
Dentro de esa tupla se encuentras las cordenadas, posiciones (X,Y) de los puntos que al final pygame une."""
pygame.draw.polygon(ventana, ColorTres, ((80,90),(200,400), (80,10)) )
while True:
ventana.fill(ColorDos)
# ventana.blit(Mi_imagen,(posX, posY))
ventana.blit(Imagen_Dos,(posX, posY))
pygame.draw.rect(ventana, ColorTres,rectangulo)
rectangulo.left, rectangulo.top = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
"""Este de abajo mueve a Kool-Aid"""
# posX,posY=pygame.mouse.get_pos()
# posX=posX-100
# posY=posY-50
"""Lo de abajo(comentado) mueve la imagen sin parar"""
if derecha==True:
if posX <400:
posX+=velocidad
else:
derecha=False
else:
if posX>1:
posX-=velocidad
else:
derecha=True
# elif event.type == pygame.KEYDOWN:
# if event.key == K_LEFT:
# posX-=velocidad
# elif event.key == K_RIGHT:
# posX+=velocidad
pygame.display.update()
How can I resolve this error (black screen)? How can I avoid this kind of error?