fill images instead od colors
This commit is contained in:
parent
7617ff8220
commit
2eadb299f0
30
app/board.py
30
app/board.py
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import random
|
||||
import pygame
|
||||
from images import *
|
||||
|
||||
from config import *
|
||||
|
||||
@ -20,13 +20,29 @@ class Board:
|
||||
self.__fields[i].append(None)
|
||||
|
||||
def fill(self):
|
||||
colors = [C_RED, C_GREEN, C_BLUE]
|
||||
# colors = [C_RED, C_GREEN, C_BLUE]
|
||||
for i in range(len(self.__fields)):
|
||||
for j in range(len(self.__fields[i])):
|
||||
self.__fields[i][j] = random.choice(colors)
|
||||
self.__fields[i][j] = random.choice(soilType)
|
||||
|
||||
|
||||
def draw(self, screen: pygame.Surface):
|
||||
for i in range(len(self.__fields)):
|
||||
for j in range(len(self.__fields[i])):
|
||||
rect = pygame.Rect(FIELD_SIZE*i, FIELD_SIZE*j, FIELD_SIZE, FIELD_SIZE)
|
||||
pygame.draw.rect(screen, self.__fields[i][j], rect)
|
||||
for x in range(len(self.__fields)):
|
||||
for y in range(len(self.__fields[x])):
|
||||
obj = self.__fields[x][y]
|
||||
if obj == 'grass':
|
||||
grassrect.center = (x, y)
|
||||
screen.blit(grass, grassrect)
|
||||
if obj == 'corn':
|
||||
cornrect.center = (x, y)
|
||||
screen.blit(corn, cornrect)
|
||||
if obj == 'sunflower':
|
||||
sunflowerrect.center = (x, y)
|
||||
screen.blit(sunflower, sunflowerrect)
|
||||
if obj == 'sand':
|
||||
sandrect.center = (x, y)
|
||||
screen.blit(sand, sandrect)
|
||||
if obj == 'clay':
|
||||
clayrect.center = (x, y)
|
||||
screen.blit(clay, clayrect)
|
||||
|
||||
|
@ -8,9 +8,9 @@ __all__ = (
|
||||
)
|
||||
|
||||
# Board settings:
|
||||
VERTICAL_NUM_OF_FIELDS = 14
|
||||
HORIZONTAL_NUM_OF_FIELDS = 20
|
||||
FIELD_SIZE = 32
|
||||
VERTICAL_NUM_OF_FIELDS = 6
|
||||
HORIZONTAL_NUM_OF_FIELDS = 6
|
||||
FIELD_SIZE = 64
|
||||
WIDTH = HORIZONTAL_NUM_OF_FIELDS * FIELD_SIZE
|
||||
HEIGHT = VERTICAL_NUM_OF_FIELDS * FIELD_SIZE
|
||||
|
||||
|
19
images.py
Normal file
19
images.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pygame
|
||||
|
||||
soilType = ('sand','clay', 'soil', 'grass', 'corn', 'sunflower')
|
||||
|
||||
tractor = pygame.image.load("resources/tractor.png")
|
||||
clay = pygame.image.load("resources/clay.png")
|
||||
sand = pygame.image.load("resources/sand.png")
|
||||
grass = pygame.image.load("resources/grass.png")
|
||||
corn = pygame.image.load("resources/corn.png")
|
||||
sunflower = pygame.image.load("resources/sunflower.png")
|
||||
|
||||
tractorrect = tractor.get_rect()
|
||||
clayrect = clay.get_rect()
|
||||
sandrect = sand.get_rect()
|
||||
grassrect = grass.get_rect()
|
||||
cornrect = corn.get_rect()
|
||||
sunflowerrect = sunflower.get_rect()
|
||||
|
||||
|
BIN
resources/clay.png
Normal file
BIN
resources/clay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
BIN
resources/corn.png
Normal file
BIN
resources/corn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
BIN
resources/grass.png
Normal file
BIN
resources/grass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
BIN
resources/sand.png
Normal file
BIN
resources/sand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
BIN
resources/sunflower.png
Normal file
BIN
resources/sunflower.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
BIN
resources/tractor.png
Normal file
BIN
resources/tractor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 516 B |
Loading…
Reference in New Issue
Block a user