controlling fields with water and trees #16
@ -15,6 +15,8 @@ LEFT_KNIGHTS_SPAWN_FIRST_ROW = 6
|
|||||||
LEFT_KNIGHTS_SPAWN_FIRST_COL = 0
|
LEFT_KNIGHTS_SPAWN_FIRST_COL = 0
|
||||||
RIGHT_KNIGHTS_SPAWN_FIRST_ROW = 6
|
RIGHT_KNIGHTS_SPAWN_FIRST_ROW = 6
|
||||||
RIGHT_KNIGHTS_SPAWN_FIRST_COL = 20
|
RIGHT_KNIGHTS_SPAWN_FIRST_COL = 20
|
||||||
|
NBR_OF_WATER = 10
|
||||||
|
NBR_OF_TREES = 16
|
||||||
|
|
||||||
CASTLE_SPAWN_WIDTH = 6
|
CASTLE_SPAWN_WIDTH = 6
|
||||||
CASTLE_SPAWN_HEIGHT = 5
|
CASTLE_SPAWN_HEIGHT = 5
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import random
|
import random
|
||||||
|
import numpy as np
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
from common.constants import ROWS, COLUMNS, GRID_CELL_PADDING, GRID_CELL_WIDTH, GRID_CELL_HEIGHT, BORDER_WIDTH, \
|
from common.constants import ROWS, COLUMNS, GRID_CELL_PADDING, GRID_CELL_WIDTH, GRID_CELL_HEIGHT, BORDER_WIDTH, \
|
||||||
BORDER_RADIUS
|
BORDER_RADIUS, NBR_OF_TREES, NBR_OF_WATER
|
||||||
from .field import Field
|
from .field import Field
|
||||||
|
|
||||||
|
|
||||||
@ -13,6 +13,22 @@ class Grid:
|
|||||||
self.grid = []
|
self.grid = []
|
||||||
self.free_fields = []
|
self.free_fields = []
|
||||||
self.busy_fields = []
|
self.busy_fields = []
|
||||||
|
podkladka = np.zeros((ROWS, COLUMNS))
|
||||||
|
for drzewa in range(0, NBR_OF_TREES):
|
||||||
|
rzad = random.randint(0, ROWS-1)
|
||||||
|
kolumna = random.randint(0, COLUMNS-1)
|
||||||
|
if podkladka[rzad][kolumna] == 0:
|
||||||
|
podkladka[rzad][kolumna] = 1
|
||||||
|
else:
|
||||||
|
drzewa = drzewa - 1
|
||||||
|
for i in range(0, NBR_OF_WATER):
|
||||||
|
rzad = random.randint(0, ROWS-1)
|
||||||
|
kolumna = random.randint(0, COLUMNS-1)
|
||||||
|
if podkladka[rzad][kolumna] == 0:
|
||||||
|
podkladka[rzad][kolumna] = 2
|
||||||
|
else:
|
||||||
|
drzewa = drzewa - 1
|
||||||
|
print(podkladka)
|
||||||
for row in range(ROWS):
|
for row in range(ROWS):
|
||||||
self.grid.append(pygame.sprite.Group())
|
self.grid.append(pygame.sprite.Group())
|
||||||
for column in range(COLUMNS):
|
for column in range(COLUMNS):
|
||||||
@ -20,6 +36,11 @@ class Grid:
|
|||||||
(GRID_CELL_PADDING + GRID_CELL_HEIGHT) * row + GRID_CELL_PADDING + 7,
|
(GRID_CELL_PADDING + GRID_CELL_HEIGHT) * row + GRID_CELL_PADDING + 7,
|
||||||
GRID_CELL_WIDTH,
|
GRID_CELL_WIDTH,
|
||||||
GRID_CELL_HEIGHT]
|
GRID_CELL_HEIGHT]
|
||||||
|
if podkladka[row][column] == 1:
|
||||||
|
texture_path, converted_texture = self.textures[-1]
|
||||||
|
elif podkladka[row][column] == 2:
|
||||||
|
texture_path, converted_texture = self.textures[-2]
|
||||||
|
else:
|
||||||
texture_path, converted_texture = self.get_random_texture()
|
texture_path, converted_texture = self.get_random_texture()
|
||||||
field = Field(
|
field = Field(
|
||||||
texture_path,
|
texture_path,
|
||||||
@ -42,7 +63,7 @@ class Grid:
|
|||||||
self.draw(screen)
|
self.draw(screen)
|
||||||
|
|
||||||
def get_random_texture(self):
|
def get_random_texture(self):
|
||||||
texture_index = random.randint(0, len(self.textures) - 1)
|
texture_index = random.randint(0, len(self.textures) - 3)
|
||||||
return self.textures[texture_index]
|
return self.textures[texture_index]
|
||||||
|
|
||||||
def draw(self, screen):
|
def draw(self, screen):
|
||||||
|
Loading…
Reference in New Issue
Block a user