From b869a5ade3c82a4f24e447413b3644dce2acbe18 Mon Sep 17 00:00:00 2001 From: JakubPaszke Date: Sat, 25 Mar 2023 12:33:24 +0100 Subject: [PATCH] Changing the way that farm is generating first corps on all fields --- __pycache__/settings.cpython-310.pyc | Bin 402 -> 480 bytes __pycache__/tractor.cpython-310.pyc | Bin 1034 -> 1037 bytes main.py | 71 ++++++++++++++++--------- main2.py | 57 -------------------- settings.py | 15 ++++-- src/__pycache__/map.cpython-310.pyc | Bin 796 -> 1424 bytes src/__pycache__/screen.cpython-310.pyc | Bin 804 -> 807 bytes src/map.py | 28 +++++++--- src/plant.py | 33 ------------ 9 files changed, 77 insertions(+), 127 deletions(-) delete mode 100644 main2.py delete mode 100644 src/plant.py diff --git a/__pycache__/settings.cpython-310.pyc b/__pycache__/settings.cpython-310.pyc index 77a57934ec8608bee8eac9e9b53be5a198761463..534c1bf681553d1ec6fdaecccf818fb2d41dae40 100644 GIT binary patch delta 314 zcmXAiOG?B*5Qe*x&g9uU!3Q|5gD@`LhZRPTp|Dg+L4|LN(p$v!}6sk{mK)pCg8tO z5daf22t?_;&#Av(%QK2vmj-JMVS z2orO5hH{m28?5@$G|EF9KQFFRHIz`ShCzY0Y1PUOiiZ|VW3w$ZvaK6qlP&4?Nm~9t z>!R$3&Dwkrb>JR2`8|HQq(`SGS{l=?YrVL8w9#2Vz^0Su6c_X!N=BH^XoSf;*BPdx EKTBawjQ{`u delta 233 zcmaFBJc*e%pO=@50SMkON~N$*F+~6X diff --git a/__pycache__/tractor.cpython-310.pyc b/__pycache__/tractor.cpython-310.pyc index 5a6779d02ce03e8e174f9793c08b856a40bc7881..4faba8f3653926a6fe58cf7da39ff395060722f0 100644 GIT binary patch delta 45 zcmeC;=;h$f=jG*M00Mbtv5nmO8HKg=;Gkc=jG*M00PMf@r~U383ok!GxBp&^>Z_G@{6nV9X&VSWi(&{0L(56A^-pY diff --git a/main.py b/main.py index 881adbc..6b262b8 100644 --- a/main.py +++ b/main.py @@ -1,35 +1,54 @@ import pygame import sys -import tractor -import src.screen as screen -import src.plant as plant -from src.Tractor import Tractor as ractor2 -#import src.tractor as tractor2 +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 # pygame initialization pygame.init() +clock = pygame.time.Clock() pygame.mouse.set_visible(False) -# #new tractor sprite - todo -# tr=tractor2('oil','manual',36,36) -# tr_group = pygame.sprite.Group() -# tr_group.add() +#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) -# creating agent -myTractor = tractor.Tractor +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() + +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) -#if __name__ == "__main__": -running = True - -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 deleted file mode 100644 index f8538f7..0000000 --- a/main2.py +++ /dev/null @@ -1,57 +0,0 @@ -import pygame -import sys -import random -from settings import screen_height, screen_width, SIZE, SPECIES, block_size, tile, road_coords_y, road_coords_x -from src.map import drawRoads -from src.Tractor import Tractor -from src.Plant import Plant - -# 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)) -background = drawRoads(background) - -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])) - - -#TRACTOR -tractor = Tractor('oil','manual') -tractor_group = pygame.sprite.Group() -tractor_group.add(tractor) - -#PLANTS -plant_group = pygame.sprite.Group() -for plant in range(30): - new_plant = Plant(random.choice(SPECIES),0,random.randrange(0,25)*36+18,random.randrange(0,25)*36+18) - plant_group.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(plant_group) - - pygame.display.flip() - screen.blit(background,(0,0)) - plant_group.draw(screen) - tractor_group.draw(screen) - tractor_group.update() - clock.tick(60) - diff --git a/settings.py b/settings.py index 2fa0b41..f807018 100644 --- a/settings.py +++ b/settings.py @@ -1,10 +1,15 @@ -screen_width=900 -screen_height=900 +from cmath import sqrt + + +screen_width=936 +screen_height=936 SIZE = (screen_width, screen_height) SPECIES=["carrot","potato","beetroot","wheat"] # size in pixels of one tile = 36px/36px tile = (36, 36) block_size = 36 -road_coords_x = [0, 5, 10, 15, 20] -road_coords_y = [4, 9, 14, 19, 24] - +road_coords = [0, 5, 10, 15, 20, 25] +field_width = 4 +field_height = 4 +field_size = field_width*field_height +fields_amount = 25 diff --git a/src/__pycache__/map.cpython-310.pyc b/src/__pycache__/map.cpython-310.pyc index e89cdff789585b9948010f6cac438f03ddc0c326..efd55d62e7a1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nr;vO=12;bS7k%_sU;qFB delta 341 zcmY*TJx{|h5Vf5+P5QMkQCbNkkea1Y#a30o%)kJhycD;NN@!eH=R{CuegKs>#K^|N zuVKhP=wD#MW`Y~u-Mc%z_g)%rL0h$2b!6-7qbpwhZM%CpwoD*_bHrRHIhKSG=`m0G z%$Jl=8L&XsSWSj3lo5+C5}xp%5vvP)gJQaKf>&|4{XFlrKyfjhD+NMNAFF?KV@5c` zb@Pr_c;D=iqu|yGx_@140WG1-@FOl|Rd~0s^;=%o91i=-BalklZPmCii?< z&JtaeBIC)VgqfNEUls}u`@=ZVFi#|357wJ162Kp>Z6;04j+}J5RwQmf(;0<2EsAWl j&_FCTlpYV=8Jy7{IQab?OC`!YJ;Ro1mnuYk-1L3`wB=Lk diff --git a/src/__pycache__/screen.cpython-310.pyc b/src/__pycache__/screen.cpython-310.pyc index de53c8c42e78b2ed780414ca8ffe4d45c04f4e7f..905b9ab01a03fab6d03a027b04120685770d2cbb 100644 GIT binary patch delta 44 ycmZ3&ww#SSpO=@50SIjWNp9rUWD?fZ&&bbB)z3=IE=|%eE-6jPOq}e(^Z)?$)C~6k delta 41 vcmZ3^wuFs4pO=@50SF``#5ZzlG6`tuXXNLm>gQ(W