diff --git a/__pycache__/tractor.cpython-310.pyc b/__pycache__/tractor.cpython-310.pyc index c375915..5a6779d 100644 Binary files a/__pycache__/tractor.cpython-310.pyc and b/__pycache__/tractor.cpython-310.pyc differ diff --git a/assets/Beetroot.png b/assets/Beetroot.png new file mode 100644 index 0000000..b32a19b Binary files /dev/null and b/assets/Beetroot.png differ diff --git a/assets/Carrot.png b/assets/Carrot.png new file mode 100644 index 0000000..d77c289 Binary files /dev/null and b/assets/Carrot.png differ diff --git a/assets/Potato.png b/assets/Potato.png new file mode 100644 index 0000000..c677dd3 Binary files /dev/null and b/assets/Potato.png differ diff --git a/assets/Wheat.png b/assets/Wheat.png new file mode 100644 index 0000000..4a012a9 Binary files /dev/null and b/assets/Wheat.png differ diff --git a/assets/farmland.jpg b/assets/farmland.jpg new file mode 100644 index 0000000..7ed3122 Binary files /dev/null and b/assets/farmland.jpg differ diff --git a/main.py b/main.py index 1ccf489..881adbc 100644 --- a/main.py +++ b/main.py @@ -1,23 +1,35 @@ import pygame +import sys import tractor -import screen +import src.screen as screen +import src.plant as plant +from src.Tractor import Tractor as ractor2 +#import src.tractor as tractor2 # pygame initialization pygame.init() +pygame.mouse.set_visible(False) + +# #new tractor sprite - todo +# tr=tractor2('oil','manual',36,36) +# tr_group = pygame.sprite.Group() +# tr_group.add() # creating agent myTractor = tractor.Tractor -if __name__ == "__main__": - running = True +#if __name__ == "__main__": +running = True - while running: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - running = False - # defines agent movement - tractor.movement(myTractor) - # screen visualisation - screen.set_screen(myTractor) - - pygame.quit() \ No newline at end of file +while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + pygame.quit() + sys.exit() + # defines agent movement + tractor.movement(myTractor) + # screen visualisation + screen.set_screen(myTractor) + +#pygame.quit() \ No newline at end of file diff --git a/main2.py b/main2.py new file mode 100644 index 0000000..e2a6666 --- /dev/null +++ b/main2.py @@ -0,0 +1,128 @@ +import pygame +import sys +import random +#import tractor +#import src.screen as screen +import src.plant as plant + +screen_width=900 +screen_height=900 +SIZE = (screen_width, screen_height) +SPECIES=["carrot","potatoe","beetroot","wheat"] +# collected=0 + + +#agent class +class Tractor(pygame.sprite.Sprite): + def __init__(self,engine,transmission): + super().__init__() + self.image=pygame.image.load("assets/tractor/tractor.png") + self.image=pygame.transform.scale(self.image,(36,36)) + self.rect = self.image.get_rect() + + self.engine=engine + self.transmission=transmission + self.fuel=100 + + def collect(self): + print("collected plant") + pygame.sprite.spritecollide(tractor,plant_grup,True) + # collected=collected+1 + # print("plants in trunk "+collected) + + def update(self): + self.rect.center=pygame.mouse.get_pos() + +#plant class +class Plant(pygame.sprite.Sprite): + def __init__(self,species,is_ill,pos_x,pos_y): + super().__init__() + self.species=species + self.is_ill=is_ill + + if species=="carrot": + self.growth_time=100 + self.weight=50 + self.fertilizer="carrot_fertilizer" + self.pic_path="assets/Carrot.png" + + if species=="beetroot": + self.growth_time=200 + self.weight=200 + self.fertilizer="beetroot_fertilizer" + self.pic_path="assets/Beetroot.png" + + if species=="potato": + self.growth_time=100 + self.weight=100 + self.fertilizer="potatoe_fertilizer" + self.pic_path="assets/Potato.png" + + else: + self.growth_time=250 + self.weight=75 + self.fertilizer="wheat_fertilizer" + self.pic_path="assets/Wheat.png" + + self.image = pygame.image.load(self.pic_path) #zmienic + self.image = pygame.transform.scale(self.image,(36,36)) + self.rect = self.image.get_rect() + self.rect.center = [pos_x,pos_y] + + + + +# pygame initialization +pygame.init() +clock = pygame.time.Clock() +pygame.mouse.set_visible(False) + +#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)) + +for line in range(25): + 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])) + +# size in pixels of one tile = 36px/36px +tile = (36, 36) + +# later move it to another class "barn"? +barn_img = pygame.image.load('assets/barn.png') +barn = pygame.transform.scale(barn_img, tile) + +#Tractor +tractor = Tractor('oil','manual') +tractor_group = pygame.sprite.Group() +tractor_group.add(tractor) + +#PLANTS +plant_grup = pygame.sprite.Group() +for plant in range(30): + new_plant = Plant(random.choice(SPECIES),0,random.randrange(0,screen_width),random.randrange(0,screen_height)) + plant_grup.add(new_plant) + +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() + + pygame.display.flip() + screen.blit(background,(0,0)) + plant_grup.draw(screen) + tractor_group.draw(screen) + tractor_group.update() + clock.tick(60) + diff --git a/src/Tractor.py b/src/Tractor.py new file mode 100644 index 0000000..8604da1 --- /dev/null +++ b/src/Tractor.py @@ -0,0 +1,30 @@ +from pygame.sprite import Sprite +import pygame + +class Tractor(pygame.sprite.Sprite): + def __init__(self,engine,transmission,pos_x,pos_y): + super.__init__() + self.image=pygame.image.load("../assets/tractor/tractor.png") + self.image=pygame.transform.scale(self,(36,36)) + self.rect = self.image.get_rect() + + self.engine=engine + self.transmission=transmission + self.pos_x=pos_x + self.pos_y=pos_y + self.fuel=100 + + def update(self): + self.rect.center=pygame.mouse.get_pos() + # self.pos_x=pos_x + # self.pos_y=pos_y + + def movement(self): + print("todo") + + + def rotation(self,direction): + print("todo") + + + diff --git a/src/__pycache__/Tractor.cpython-310.pyc b/src/__pycache__/Tractor.cpython-310.pyc new file mode 100644 index 0000000..54738c9 Binary files /dev/null and b/src/__pycache__/Tractor.cpython-310.pyc differ diff --git a/src/__pycache__/plant.cpython-310.pyc b/src/__pycache__/plant.cpython-310.pyc new file mode 100644 index 0000000..4605e26 Binary files /dev/null and b/src/__pycache__/plant.cpython-310.pyc differ diff --git a/src/__pycache__/screen.cpython-310.pyc b/src/__pycache__/screen.cpython-310.pyc new file mode 100644 index 0000000..de53c8c Binary files /dev/null and b/src/__pycache__/screen.cpython-310.pyc differ diff --git a/src/__pycache__/tractor.cpython-310.pyc b/src/__pycache__/tractor.cpython-310.pyc new file mode 100644 index 0000000..1a4249d Binary files /dev/null and b/src/__pycache__/tractor.cpython-310.pyc differ diff --git a/src/plant.py b/src/plant.py new file mode 100644 index 0000000..997bc8d --- /dev/null +++ b/src/plant.py @@ -0,0 +1,34 @@ +from pygame.sprite import Sprite + +class Plant(Sprite): + def __init__(self,species,location,is_ill,pic_path): + super.__init__() + self.species=species + self.location=location + self.is_ill=is_ill + + if species=="carrot": + self.growth_time=100 + self.weight=50 + self.fertilizer="carrot_fertilizer" + self.pic_path="assets/Carrot.png" + + if species=="beetroot": + self.growth_time=200 + self.weight=200 + self.fertilizer="beetroot_fertilizer" + self.pic_path="assets/Beetroot.png" + + if species=="potato": + self.growth_time=100 + self.weight=100 + self.fertilizer="potatoe_fertilizer" + self.pic_path="assets/Potato.png" + + if species=="wheat": + self.growth_time=250 + self.weight=75 + self.fertilizer="wheat_fertilizer" + self.pic_path="assets/Wheat.png" + + \ No newline at end of file diff --git a/screen.py b/src/screen.py similarity index 100% rename from screen.py rename to src/screen.py