2023-03-07 12:28:13 +01:00
|
|
|
import pygame
|
2023-03-19 21:00:49 +01:00
|
|
|
import sys
|
2023-03-25 12:33:24 +01:00
|
|
|
import random
|
|
|
|
from settings import screen_height, screen_width, SIZE, SPECIES, block_size, tile, road_coords
|
|
|
|
from src.map import drawRoads, seedForFirstTime
|
|
|
|
from src.Tractor import Tractor
|
|
|
|
from src.Plant import Plant
|
2023-03-07 12:28:13 +01:00
|
|
|
|
2023-03-15 19:58:49 +01:00
|
|
|
# pygame initialization
|
2023-03-07 12:28:13 +01:00
|
|
|
pygame.init()
|
2023-03-25 12:33:24 +01:00
|
|
|
clock = pygame.time.Clock()
|
2023-03-19 21:00:49 +01:00
|
|
|
pygame.mouse.set_visible(False)
|
|
|
|
|
2023-03-25 12:33:24 +01:00
|
|
|
#GAME SCREEN
|
|
|
|
screen = pygame.display.set_mode(SIZE)
|
|
|
|
pygame.display.set_caption("Traktor_interaktor")
|
|
|
|
background = pygame.image.load("assets/farmland.jpg")
|
|
|
|
background = pygame.transform.scale(background,SIZE)
|
|
|
|
screen.fill((90,50,20))
|
|
|
|
background.fill((90,50,20))
|
|
|
|
background = drawRoads(background)
|
2023-03-07 12:28:13 +01:00
|
|
|
|
2023-03-25 12:33:24 +01:00
|
|
|
for line in range(26):
|
|
|
|
pygame.draw.line(background, (0, 0, 0), (0, line * 36), (SIZE[0], line * 36))
|
|
|
|
pygame.draw.line(background, (0, 0, 0), (line * 36, 0), (line * 36, SIZE[1]))
|
|
|
|
|
|
|
|
#TRACTOR
|
|
|
|
tractor = Tractor('oil','manual')
|
|
|
|
tractor_group = pygame.sprite.Group()
|
|
|
|
tractor_group.add(tractor)
|
|
|
|
|
|
|
|
#PLANTS
|
|
|
|
plant_group = pygame.sprite.Group()
|
|
|
|
plant_group = seedForFirstTime()
|
2023-03-07 12:28:13 +01:00
|
|
|
|
2023-03-25 12:33:24 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
running = True
|
|
|
|
|
|
|
|
while running:
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
running = False
|
|
|
|
pygame.quit()
|
|
|
|
sys.exit()
|
|
|
|
if event.type == pygame.MOUSEBUTTONDOWN:
|
|
|
|
tractor.collect(plant_group)
|
|
|
|
|
|
|
|
pygame.display.flip()
|
|
|
|
screen.blit(background,(0,0))
|
|
|
|
plant_group.draw(screen)
|
|
|
|
tractor_group.draw(screen)
|
|
|
|
tractor_group.update()
|
|
|
|
clock.tick(60)
|
|
|
|
|