Compare commits

...

15 Commits

10 changed files with 206 additions and 65 deletions

29
src/Bee.py Normal file
View File

@ -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

14
src/Beehive.py Normal file
View File

@ -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

15
src/Flower.py Normal file
View File

@ -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

7
src/Frames.py Normal file
View File

@ -0,0 +1,7 @@
class Frames:
# name = None
# productivity = None
def __init__(self, name, productivity):
self.name = name
self.productivity = productivity

BIN
src/bee.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 KiB

View File

@ -1,65 +1,141 @@
import pygame import pygame
import Flower
pygame.init() import Beehive
import Frames
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0) white = (255, 255, 255)
dis = pygame.display.set_mode((800, 600)) #setting caption and icon
pygame.display.set_caption('Intelegentny Pszczelarz') pygame.display.set_caption('Smart Bee')
setIcon = pygame.image.load('spritesNtiles/bee64.png')
game_over = False pygame.display.set_icon(setIcon)
x1 = 300 #
y1 = 300 ###
########################################
x1_change = 0
y1_change = 0
#SHORT = pygame.image.load('spritesNtiles/shortGrass64.png') #0
block_xy = [[100, 20], [100, 500], [700, 20], [700, 500]] #TALL = pygame.image.load('spritesNtiles/tallGrass64.png') #1
block1 = block_xy[0] #TREE = pygame.image.load('spritesNtiles/dirtTree64.png') #10
block2 = block_xy[1]
block3 = block_xy[2]
block4 = block_xy[3] ### tilemap
SHORT = 0
clock = pygame.time.Clock() TALL = 1
TREE = 10
while not game_over: BEE = pygame.image.load('spritesNtiles/bee64.png')
for event in pygame.event.get():
if event.type == pygame.QUIT: tiles = {
game_over = True SHORT: pygame.image.load('spritesNtiles/shortGrass64.png'),
if event.type == pygame.KEYDOWN: TALL: pygame.image.load('spritesNtiles/tallGrass64.png'),
if event.key == pygame.K_LEFT: TREE: pygame.image.load('spritesNtiles/dirtTree64.png')
x1_change = -10 }
y1_change = 0
elif event.key == pygame.K_RIGHT: tilemap = [
x1_change = 10 [SHORT, SHORT, SHORT, TREE, SHORT, TALL, TALL, SHORT, SHORT, TREE, SHORT, SHORT, TALL, SHORT, SHORT],
y1_change = 0 [SHORT, SHORT, SHORT, TALL, TALL, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT],
elif event.key == pygame.K_UP: [SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT],
y1_change = -10 [TALL, TREE, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, TREE],
x1_change = 0 [SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT],
elif event.key == pygame.K_DOWN: [SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, TALL],
y1_change = 10 [SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, TREE, SHORT, SHORT, SHORT],
x1_change = 0 [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],
x1 += x1_change [TALL, SHORT, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, TALL],
y1 += y1_change [SHORT, SHORT, SHORT, SHORT, SHORT, TREE, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, SHORT],
dis.fill(white) [SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, SHORT, TALL, SHORT, SHORT],
pygame.draw.rect(dis, black, [x1, y1, 10, 10])
]
if [x1,y1] in block_xy: tilemapSizeY = 12
game_over = True tilemapSizeX = 15
tileSize = 64
pygame.draw.rect(dis, red, [block1[0], block1[1], 20, 20]) ###
pygame.draw.rect(dis, red, [block2[0], block2[1], 20, 20])
pygame.draw.rect(dis, red, [block3[0], block3[1], 20, 20]) #calculate the window size
pygame.draw.rect(dis, red, [block4[0], block4[1], 20, 20]) disX = tilemapSizeX * tileSize
disY = tilemapSizeY * tileSize
pygame.display.update()
# tilemap = [
clock.tick(30) # [0, 0, 0, 10, 0, 1, 1, 0, 0, 10],
# [0, 0, 0, 1, 1, 0, 0, 10, 0, 0],
pygame.quit() # [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
quit() # [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)

BIN
src/spritesNtiles/bee64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB