import pygame import time import random from area.constants import WIDTH, HEIGHT, TILE_SIZE, GREY from area.field import drawWindow from area.tractor import Tractor from area.field import tiles, fieldX, fieldY from area.field import update_tiles from ground import Dirt from plant import Plant WIN = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption('Intelligent tractor') trail = pygame.image.load("resources/images/background.jpg").convert_alpha() trail = pygame.transform.scale(trail, (TILE_SIZE, TILE_SIZE)) def main(): run = True window = drawWindow(WIN) pygame.display.update() while run: for event in pygame.event.get(): if event.type == pygame.QUIT: run = False #small test: time.sleep(1) tile1 = tiles[0] p1 = Plant('wheat', 'cereal', random.randint(1,100), random.randint(1,100), random.randint(1,100)) d1 = Dirt(random.randint(1, 100), random.randint(1,100)) d1.pests_and_weeds() tile1.ground=d1 tractor = Tractor(0*TILE_SIZE, 0*TILE_SIZE, 1) tractor.rotate_to_right() tractor.rect.x += fieldX tractor.rect.y += fieldY tractor.draw_tractor(WIN) time.sleep(1) for _ in range(5): WIN.blit(trail, (tractor.rect.x, tractor.rect.y, TILE_SIZE, TILE_SIZE)) tractor.move() tractor.draw_tractor(WIN) pygame.display.flip() tractor.work_on_field(tile1, d1, p1) time.sleep(2) print("\n") # in loop move tractor: main()