A graphic should fall at a random position from top to bottom. When the graphic has fallen down, and has "disappeared" from the screen, it should fall again at a random position from top to bottom. I always get the following error message: "empty range for randrange() (0,-799, -799)". Before the graphic appears in the game window it must have a negative y-coordinate? So, how can i make falling objects?
from random import randint
import pygame
WIDTH = 800
HEIGHT = 800
apple = Actor("apple")
apple.pos = randint(0, 800), randint(0, -800)
score = 0
def draw():
screen.clear()
apple.draw()
screen.draw.text("Punkte: " + str(score), (700, 5), color = "white")
def update():
if apple.y < 800:
apple.y = apple.y + 4
else:
apple.x = randint(0, 800)
apple.y = randint(0, -800)