diff --git a/program/.DS_Store b/program/.DS_Store new file mode 100644 index 00000000..f140fd21 Binary files /dev/null and b/program/.DS_Store differ diff --git a/program/__pycache__/field.cpython-311.pyc b/program/__pycache__/field.cpython-311.pyc new file mode 100644 index 00000000..3442b77f Binary files /dev/null and b/program/__pycache__/field.cpython-311.pyc differ diff --git a/program/__pycache__/tile.cpython-311.pyc b/program/__pycache__/tile.cpython-311.pyc new file mode 100644 index 00000000..0019ee06 Binary files /dev/null and b/program/__pycache__/tile.cpython-311.pyc differ diff --git a/program/__pycache__/tractor.cpython-311.pyc b/program/__pycache__/tractor.cpython-311.pyc new file mode 100644 index 00000000..d9c02e21 Binary files /dev/null and b/program/__pycache__/tractor.cpython-311.pyc differ diff --git a/program/field.py b/program/field.py new file mode 100644 index 00000000..9da56fbb --- /dev/null +++ b/program/field.py @@ -0,0 +1,14 @@ +import pygame +from tile import Tile +from tractor import Tractor + +class Field: + def __init__(self): + self.tiles = pygame.sprite.Group() + for x in range(256): + self.tiles.add(Tile(x, 'grass', self)) + self.tractor = Tractor(self) + + def draw(self, surface): + self.tiles.draw(surface) + self.tractor.draw(surface) \ No newline at end of file diff --git a/program/images/grass.png b/program/images/grass.png new file mode 100644 index 00000000..a4975e53 Binary files /dev/null and b/program/images/grass.png differ diff --git a/program/images/tractor.png b/program/images/tractor.png new file mode 100644 index 00000000..833d1762 Binary files /dev/null and b/program/images/tractor.png differ diff --git a/program/main.py b/program/main.py new file mode 100644 index 00000000..5b1aefab --- /dev/null +++ b/program/main.py @@ -0,0 +1,21 @@ +import sys +import pygame +from field import Field + +if __name__ == "__main__": + pygame.init() + WHITE = (255, 255, 255) + SCREEN_WIDTH, SCREEN_HEIGHT = 1024, 1024 + screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) + field = Field() + running = True + while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + screen.fill(WHITE) + field.draw(screen) + + pygame.display.flip() + pygame.time.Clock().tick(30) \ No newline at end of file diff --git a/program/tile.py b/program/tile.py new file mode 100644 index 00000000..bef04ae6 --- /dev/null +++ b/program/tile.py @@ -0,0 +1,19 @@ +import os +import pygame + +class Tile(pygame.sprite.Sprite): + def __init__(self, id, type, field): + super().__init__() + self.id = id + x = id%16 + y = id//16 + self.type = type + self.field = field + if type=='grass': + self.image = pygame.image.load('images/grass.png').convert() + self.image = pygame.transform.scale(self.image, (64, 64)) + self.rect = self.image.get_rect() + self.rect.topleft = (x * 64, y * 64) + + def draw(self, surface): + self.tiles.draw(surface) \ No newline at end of file diff --git a/program/tractor.py b/program/tractor.py new file mode 100644 index 00000000..2935fd9f --- /dev/null +++ b/program/tractor.py @@ -0,0 +1,15 @@ +import pygame +import os +class Tractor(pygame.sprite.Sprite): + def __init__(self, field): + super().__init__() + self.type = type + self.field = field + self.image = pygame.image.load('images/tractor.png').convert_alpha() + self.image = pygame.transform.scale(self.image, (64, 64)) + self.rect = self.image.get_rect() + x, y = 0, 0 + self.rect.topleft = (x, y) + + def draw(self, surface): + surface.blit(self.image, self.rect)