From 078ce5ac8028ddaff27db9aa1030c4c954808550 Mon Sep 17 00:00:00 2001 From: Yevheniia Kryzhanovska Date: Mon, 10 Apr 2023 19:41:56 +0200 Subject: [PATCH] =?UTF-8?q?Prze=C5=9Blij=20pliki=20do=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bee.py | 29 +++++++++++ Beehive.py | 14 ++++++ Flower.py | 15 ++++++ Frames.py | 7 +++ main.py | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 206 insertions(+) create mode 100644 Bee.py create mode 100644 Beehive.py create mode 100644 Flower.py create mode 100644 Frames.py create mode 100644 main.py diff --git a/Bee.py b/Bee.py new file mode 100644 index 00000000..4420bb41 --- /dev/null +++ b/Bee.py @@ -0,0 +1,29 @@ +import pygame +import Flower +class Bee: + # typeOfBee = None + # genotype = None + # favFloweColor = None + # biome = None + # product = None + + def __init__(self, typeOfBee, genotype, biome, product, favFlowerColor = Flower.Flower.color): + # self.x = 64 + # self.y = 64 + # self.xChange = 0 + # self.yChange = 0 + # self.height = 64 + # self.width = 64 + # self.beeImg = pygame.image.load("spritesNtiles/bee64.png") + + self.typeOfBee = typeOfBee + self.genotype = genotype + self.favFlowerColor = favFlowerColor + self.biome = biome + self.product = product + self.amountOfPollinatedFlowers = 0 + self.favFlowerColor = favFlowerColor + self.amountOfPollinatedFlowers = 0 + + + diff --git a/Beehive.py b/Beehive.py new file mode 100644 index 00000000..f9ba3e95 --- /dev/null +++ b/Beehive.py @@ -0,0 +1,14 @@ +import Frames +import Bee + +class Beehive: + bees = [] + coordinate = None + frames = [] #Frames + outputSlots = None #? + + def __init__(self, bees, coordinate, frames, outputSlots): + self.bees = bees + self.coordinate = coordinate + self.frames = frames + self.outputSlots = outputSlots diff --git a/Flower.py b/Flower.py new file mode 100644 index 00000000..383f78ee --- /dev/null +++ b/Flower.py @@ -0,0 +1,15 @@ +import random + +class PossibleFlower: + color = ['red', 'blue', 'yellow', 'white', 'pink'] + name = ['tulip', 'sunflower', 'rose', 'dandelion', 'daisy'] + +class Flower: + color = None + name = None + coordinates = [] + + def __init__(self, coordinates, color = PossibleFlower.color[random.randint(0, 4)], name = PossibleFlower.name[random.randint(0, 4)]): + self.color = color + self.name = name + self.coordinates = coordinates diff --git a/Frames.py b/Frames.py new file mode 100644 index 00000000..00cfa559 --- /dev/null +++ b/Frames.py @@ -0,0 +1,7 @@ +class Frames: + # name = None + # productivity = None + + def __init__(self, name, productivity): + self.name = name + self.productivity = productivity diff --git a/main.py b/main.py new file mode 100644 index 00000000..47a79ec4 --- /dev/null +++ b/main.py @@ -0,0 +1,141 @@ +import pygame +import Flower +import Beehive +import Frames + + +white = (255, 255, 255) + +#setting caption and icon +pygame.display.set_caption('Smart Bee') +setIcon = pygame.image.load('spritesNtiles/bee64.png') +pygame.display.set_icon(setIcon) + +# +### +######################################## + + +#SHORT = pygame.image.load('spritesNtiles/shortGrass64.png') #0 +#TALL = pygame.image.load('spritesNtiles/tallGrass64.png') #1 +#TREE = pygame.image.load('spritesNtiles/dirtTree64.png') #10 + + +### tilemap +SHORT = 0 +TALL = 1 +TREE = 10 +BEE = pygame.image.load('spritesNtiles/bee64.png') + +tiles = { + SHORT: pygame.image.load('spritesNtiles/shortGrass64.png'), + TALL: pygame.image.load('spritesNtiles/tallGrass64.png'), + TREE: pygame.image.load('spritesNtiles/dirtTree64.png') +} + +tilemap = [ + [SHORT, SHORT, SHORT, TREE, SHORT, TALL, TALL, SHORT, SHORT, TREE, SHORT, SHORT, TALL, SHORT, SHORT], + [SHORT, SHORT, SHORT, TALL, TALL, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT], + [SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT], + [TALL, TREE, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, TREE], + [SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT], + [SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, TALL], + [SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, TREE, SHORT, SHORT, SHORT], + [SHORT, TREE, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, TALL, TALL, SHORT, SHORT, SHORT, TALL, SHORT], + [SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT], + [TALL, SHORT, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, TALL], + [SHORT, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, SHORT], + [SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT], + +] +tilemapSizeY = 12 +tilemapSizeX = 15 +tileSize = 64 +### + + +#calculate the window size +disX = tilemapSizeX * tileSize +disY = tilemapSizeY * tileSize + +# tilemap = [ +# [0, 0, 0, 10, 0, 1, 1, 0, 0, 10], +# [0, 0, 0, 1, 1, 0, 0, 10, 0, 0], +# [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], +# [1, 10, 0, 0, 0, 10, 0, 0, 0, 0], +# [0, 0, 0, 0, 0, 0, 0, 10, 0, 10], +# [0, 0, 0, 0, 1, 0, 0, 0, 0, 1], +# [0, 0, 1, 0, 0, 0, 0, 0, 10, 0], +# [0, 10, 0, 10, 0, 0, 0, 0, 1, 1], +# [0, 0, 0, 0, 1, 0, 0, 0, 0, 10], +# [1, 0, 0, 0, 0, 0, 10, 0, 0, 0] +# ] + + +pygame.init() +dis = pygame.display.set_mode((disX, disY)) +clock = pygame.time.Clock() + +#position of the bee and pos changings +XChanges = 0 +XPosBee = 64 + +YChanges = 0 +YPosBee = 64 + +while True: + + for event in pygame.event.get(): + #check to quit + if (event.type == pygame.QUIT) or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE): + # game_over = True + pygame.quit() + quit() + + #printing map + for i in range(len(tilemap)): + for j in range(len(tilemap[i])): + dis.blit(tiles[tilemap[i][j]], (j * tileSize, i * tileSize)) + + #movement speed + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_UP: + XChanges = 0 + YChanges = -16 + if event.key == pygame.K_DOWN: + XChanges = 0 + YChanges = 16 + if event.key == pygame.K_LEFT: + XChanges = -16 + YChanges = 0 + if event.key == pygame.K_RIGHT: + XChanges = 16 + YChanges = 0 + #stopmovement when a key is up + if event.type == pygame.KEYUP: + XChanges = 0 + YChanges = 0 + #calculating position of the bee + if disX >= XPosBee >= 0: + XPosBee = XPosBee + XChanges + if disY >= YPosBee >= 0: + YPosBee = YPosBee + YChanges + + #left and up restriction + if XPosBee <= 0: + XPosBee = 0 + elif XPosBee >= disX: + XPosBee = disX + elif YPosBee <= 0: + YPosBee = 0 + elif YPosBee >= disY: + YPosBee = disY + + #beatiful bee + dis.blit(BEE, (XPosBee, YPosBee)) + + #updating + # pygame.display.flip() + pygame.display.update() + clock.tick(10000) +