Inteligentny_Traktor_Grupa_16/main.py
2022-04-07 13:01:11 +02:00

43 lines
1.1 KiB
Python

import pygame
from src.world import World
from src.tractor import Tractor
from src.settings import Settings
from src.utils.bfs import BFSSearcher
from src.constants import Constants
def main():
pygame.init()
settings = Settings()
world = World(settings)
tractor = Tractor("Spalinowy", "Nawóz 1", settings, 8*settings.tile_size, 8*settings.tile_size)
obstacles = [tile for tile in world.tiles if tile.type == 'rock']
clock = pygame.time.Clock() # FPS purpose
screen = pygame.display.set_mode((settings.screen_width, settings.screen_height))
pygame.display.set_caption('TRAKTOHOLIK')
path = BFSSearcher().search((8, 1), (6, 2), Constants.UP)
run = True
while run:
clock.tick(settings.fps)
world.draw_tiles(screen)
world.draw_lines(screen)
tractor.draw(screen)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
tractor.update(path)
tractor.check_collision(obstacles)
pygame.display.update()
pygame.quit()
if __name__ == '__main__':
main()