Compare commits

..

No commits in common. "d72ba0090915d81feb22c19f1f60737c33b92130" and "5a3ae08f614bfc366bbe393399c64fa7a1b36cd1" have entirely different histories.

5 changed files with 32 additions and 53 deletions

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

75
main.py
View File

@ -2,24 +2,9 @@ import pygame
class Field: class Field:
def __init__(self, fieldType, plantType, isWet, wetTime, isFertilized, fertilizedTime): def __init__(self, isWet, thingOn):
self.fieldType = fieldType # good/bad self.isWet = isWet
self.plantType = plantType # wheat/carrot/cabbage self.thingOn = thingOn
self.isWet = isWet # yes/no
self.wetTime = wetTime # number
self.isFertilized = isFertilized # yes/no
self.fertilizedTime = fertilizedTime # number
class Plant:
def __init__(self, plantType, growthState):
self.plantType = plantType # wheat/carrot/cabbage
self.growthState = growthState # growing/grown
class Fertilizer:
def __init__(self, fertilizerType):
self.fertilizerType = fertilizerType # wheat/carrot/cabbage
class Player: class Player:
@ -28,22 +13,19 @@ class Player:
rotation = 0 rotation = 0
T = [[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)], T = [[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)], [Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)], [Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)], [Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)], [Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)], [Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)], [Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)], [Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)]]
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)],
[Field(1,0,0,0,0,0),Field(0,0,1,0,0,0),Field(1,1,1,0,0,0),Field(1,2,0,0,0,0),Field(0,3,1,0,0,0),Field(0,0,0,0,0,0),Field(0,0,0,0,0,0),Field(1,0,1,0,0,0),Field(1,0,0,0,0,0),Field(1,0,1,0,0,0)]]
pygame.init() pygame.init()
player = Player() player = Player()
screen = pygame.display.set_mode([600, 600]) screen = pygame.display.set_mode([500, 500])
running = True running = True
clock = pygame.time.Clock() clock = pygame.time.Clock()
@ -59,34 +41,32 @@ while running:
if player.y > 0: if player.y > 0:
player.y = player.y - 1 player.y = player.y - 1
if event.key ==pygame.K_RIGHT: if event.key ==pygame.K_RIGHT:
if player.x < 9: if player.x < 7:
player.x = player.x + 1 player.x = player.x + 1
if event.key ==pygame.K_DOWN: if event.key ==pygame.K_DOWN:
if player.y < 9: if player.y < 7:
player.y = player.y + 1 player.y = player.y + 1
screen.fill((178, 255, 51))
screen.fill((175, 255, 50)) img1 = pygame.image.load('1.png')
imgWheat = pygame.image.load('img/wheat.png') img2 = pygame.image.load('2.png')
imgCarrot = pygame.image.load('img/carrot.png') img3 = pygame.image.load('3.png')
imgCabbage = pygame.image.load('img/cabbage.png') imgPlayer = pygame.image.load('player.png')
imgPlayer = pygame.image.load('img/player.png')
i = 0 i = 0
while i < len(T): while i < len(T):
j = 0 j = 0
while j < len(T[i]): while j < len(T[i]):
color = (0, 0, 0) color = (0, 0, 0)
if T[i][j].isWet == 0: if T[i][j].isWet == 0:
color = (160, 80, 40) color = (160, 82, 45)
else: else:
color = (50, 25, 0) color = (51, 25, 0)
pygame.draw.rect(screen, color, pygame.Rect(50 + 50 * i, 50 + 50 * j, 50, 50)) pygame.draw.rect(screen, color, pygame.Rect(50 + 50 * i, 50 + 50 * j, 50, 50))
if T[i][j].plantType == 1: if T[i][j].thingOn==1:
screen.blit(imgWheat, (50 + 50 * i, 50 + 50 * j)) screen.blit(img1, (50 + 50 * i, 50 + 50 * j))
if T[i][j].plantType == 2: if T[i][j].thingOn==2:
screen.blit(imgCarrot, (50 + 50 * i, 50 + 50 * j)) screen.blit(img2, (50 + 50 * i, 50 + 50 * j))
if T[i][j].plantType == 3: if T[i][j].thingOn==3:
screen.blit(imgCabbage, (50 + 50 * i, 50 + 50 * j)) screen.blit(img3, (50 + 50 * i, 50 + 50 * j))
j = j + 1 j = j + 1
i = i + 1 i = i + 1
@ -95,7 +75,6 @@ while running:
pygame.draw.line(screen, (0, 0, 0), (50 + i * 50, 50), (50 + i * 50, 50 + len(T) * 50),5) pygame.draw.line(screen, (0, 0, 0), (50 + i * 50, 50), (50 + i * 50, 50 + len(T) * 50),5)
pygame.draw.line(screen, (0, 0, 0), (50, 50 + i * 50), (50 + len(T) * 50, 50 + i * 50),5) pygame.draw.line(screen, (0, 0, 0), (50, 50 + i * 50), (50 + len(T) * 50, 50 + i * 50),5)
i = i + 1 i = i + 1
tmpImg = pygame.transform.rotate(imgPlayer, player.rotation) tmpImg = pygame.transform.rotate(imgPlayer, player.rotation)
screen.blit(tmpImg, (55 + 50 * player.x, 55 + 50 * player.y)) screen.blit(tmpImg, (55 + 50 * player.x, 55 + 50 * player.y))
pygame.display.flip() pygame.display.flip()

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB