Почему то не отображаются изменения на экране?
у меня круг должен перемещаться к красному, функция выполняется но зеленый круг не меняет положения на экране.
Сам код:
import random
import pygame
pygame.init()
width = 1000
height = 800
screen = pygame.display.set_mode((width, height))
bactery_x = 100
bactery_y = 100
bactery_radius = 100
food_x = random.randrange(0, 990)
food_y = random.randrange(0, 790)
food_radius = 10
screen.fill((255, 255, 255))
clock = pygame.time.Clock()
def game():
global bactery_x, bactery_y
game = True
while game:
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
pygame.quit()
clock.tick(60)
bactery.move(bactery_x, bactery_y, food_x, food_y)
pygame.display.update()
def food_generate():
pygame.draw.circle(screen, (255, 0, 0), (food_x, food_y), food_radius)
return food_y, food_x
class Bactery:
global bactery_x, bactery_y
def __init__(self):
self.x = bactery_x
self.y = bactery_y
def move(self, bactery_x, bactery_y, food_x, food_y):
if bactery_x < food_x:
bactery_x += 1
elif bactery_x > food_x:
bactery_x -= 1
if bactery_y < food_y:
bactery_y += 1
elif bactery_y > food_y:
bactery_y -= 1
def create_bactery(self):
pygame.draw.circle(screen, (0, 255, 0), (bactery_x, bactery_y), bactery_radius)
food_generate()
bactery = Bactery()
bactery.create_bactery()
pygame.display.update()
game()