commit 56ae2c85de2a5ab4038ac5446e5aec1c71f13b06 Author: s481808 Date: Thu Mar 7 18:01:12 2024 +0100 Commit of the field board diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..eaf91e2 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/Traktor AI.iml b/.idea/Traktor AI.iml new file mode 100644 index 0000000..d9e6024 --- /dev/null +++ b/.idea/Traktor AI.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8d93904 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2fb6555 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..c8397c9 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/source/.idea/.gitignore b/source/.idea/.gitignore new file mode 100644 index 0000000..eaf91e2 --- /dev/null +++ b/source/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/source/.idea/inspectionProfiles/profiles_settings.xml b/source/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/source/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/source/.idea/misc.xml b/source/.idea/misc.xml new file mode 100644 index 0000000..8d93904 --- /dev/null +++ b/source/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/source/.idea/modules.xml b/source/.idea/modules.xml new file mode 100644 index 0000000..d67a7a7 --- /dev/null +++ b/source/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/source/.idea/source.iml b/source/.idea/source.iml new file mode 100644 index 0000000..d9e6024 --- /dev/null +++ b/source/.idea/source.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/source/.idea/vcs.xml b/source/.idea/vcs.xml new file mode 100644 index 0000000..7336f89 --- /dev/null +++ b/source/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/source/__init__.py b/source/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/source/area/__init__.py b/source/area/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/source/area/constants.py b/source/area/constants.py new file mode 100644 index 0000000..99a9fcd --- /dev/null +++ b/source/area/constants.py @@ -0,0 +1,17 @@ +# contains all constants +import pygame + +WIDTH, HEIGHT = 1000, 1000 +FIELD_WIDTH, FIELD_HEIGHT = 660, 330 +ROWS, COLS = 10, 5 +# number of tiles in a row and column +TILE_SIZE = FIELD_WIDTH//ROWS +PLANT = "" +# path to plant image +GROUND = "" +# path to ground image +GREY = (20, 17, 17, 255) + + + + diff --git a/source/area/field.py b/source/area/field.py new file mode 100644 index 0000000..0968ba0 --- /dev/null +++ b/source/area/field.py @@ -0,0 +1,45 @@ +# create a field here : 1: add tiles, 2: place them +import pygame + +from area.constants import WIDTH,HEIGHT,FIELD_WIDTH,FIELD_HEIGHT,TILE_SIZE,GREY,ROWS,COLS +from area.tractor import Tractor +from tile import Tile + +tiles = [] +tractor = Tractor(0*TILE_SIZE, 0*TILE_SIZE) +fieldX = (WIDTH-FIELD_WIDTH)/2 +# in center of the screen +fieldY = 100 + +# move field elements to field position + +def positionFieldElements(): + for t in tiles: + t.x += fieldX + t.y += fieldY + tractor.x += fieldX + tractor.y += fieldY + +def createTiles(): + for y in range (0,COLS): + for x in range (0,ROWS): + tile = Tile(x*TILE_SIZE, y*TILE_SIZE) + tile.randomizeContent() + tiles.append(tile) + positionFieldElements() + +def createField(win): + createTiles() + for t in tiles: + image = pygame.image.load(t.image).convert() + image = pygame.transform.scale(image, (TILE_SIZE, TILE_SIZE)) + win.blit(image, (t.x, t.y)) + pygame.display.flip() + imageTractor = pygame.image.load(tractor.image).convert_alpha() + imageTractor = pygame.transform.scale(imageTractor, (TILE_SIZE, TILE_SIZE)) + win.blit(imageTractor, (tractor.x, tractor.y)) + pygame.display.flip() + +def drawWindow(win): + win.fill(GREY) + createField(win) diff --git a/source/area/tractor.py b/source/area/tractor.py new file mode 100644 index 0000000..5e1c355 --- /dev/null +++ b/source/area/tractor.py @@ -0,0 +1,9 @@ +class Tractor: + x = None + y = None + image = None +# etc + def __init__(self,x,y): + self.x = x + self.y = y + self.image = 'resources/images/tractor.png' diff --git a/source/ground.py b/source/ground.py new file mode 100644 index 0000000..a564c4c --- /dev/null +++ b/source/ground.py @@ -0,0 +1,6 @@ +class Dirt: + state = None +# add a couple new properties + +# add init, getters,setters + diff --git a/source/main.py b/source/main.py new file mode 100644 index 0000000..3361f3a --- /dev/null +++ b/source/main.py @@ -0,0 +1,20 @@ +import pygame + +from area.constants import WIDTH, HEIGHT +from area.field import drawWindow +WIN = pygame.display.set_mode((WIDTH, HEIGHT)) +pygame.display.set_caption('Intelligent tractor') + + +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 + +# in loop move tractor + +main() diff --git a/source/plant.py b/source/plant.py new file mode 100644 index 0000000..39f1a6c --- /dev/null +++ b/source/plant.py @@ -0,0 +1,8 @@ + +class Plant: + name = None +# more properties + + +# add init, getters,setters + diff --git a/source/resources/images/dirt.png b/source/resources/images/dirt.png new file mode 100644 index 0000000..9d27746 Binary files /dev/null and b/source/resources/images/dirt.png differ diff --git a/source/resources/images/sampling.png b/source/resources/images/sampling.png new file mode 100644 index 0000000..bbeb4e6 Binary files /dev/null and b/source/resources/images/sampling.png differ diff --git a/source/resources/images/tractor.png b/source/resources/images/tractor.png new file mode 100644 index 0000000..42a9154 Binary files /dev/null and b/source/resources/images/tractor.png differ diff --git a/source/tile.py b/source/tile.py new file mode 100644 index 0000000..e41e652 --- /dev/null +++ b/source/tile.py @@ -0,0 +1,34 @@ +import random + +class Tile: + x = 0 + y = 0 + plant = None + ground = None + + photo = None + image = None + + # after checking a photo add information plant object ("potato"/ "wheat"/"none") + + # add Ground instance + + def __init__(self, x, y): + self.x = x + self.y = y + + # add to init ground instance + + # called on a created tile + + def randomizeContent(self): + i = random.randint(1, 3) #szansa 1/3 + if i == 1: + self.image = "resources/images/sampling.png" + #self.picture losuje dodatkowo zdjecie jakies rosliny do danego rzędu + else: + self.image = "resources/images/dirt.png" + + +# DISCLAMER check column and choose plant type ("potato","wheat" etc) +