42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from config import *
|
|
from templates import *
|
|
|
|
|
|
class Grid:
|
|
|
|
def __init__(self):
|
|
# Creating a new drawing surface
|
|
self.floor = [[0 for x in range(map_width)] for y in range(map_height)]
|
|
self.surface = pg.display.set_mode((tile_size * map_width, tile_size * (map_height + legend_height)))
|
|
|
|
# Making a mouse cursor invisible
|
|
pg.mouse.set_visible(True)
|
|
|
|
# Elements of the legend bar beneath the map
|
|
self.time = 0
|
|
|
|
|
|
def generate_map(self):
|
|
# Generating an empty map and filling it with floors of a randomly chosen type
|
|
A = random_part()
|
|
for i in range(16):
|
|
for j in range(9):
|
|
self.floor[j][i] = A[j][i]
|
|
B = random_part()
|
|
for i in range(16, 32):
|
|
for j in range(9):
|
|
self.floor[j][i] = B[j][i - 16]
|
|
C = random_part()
|
|
for i in range(16):
|
|
for j in range(9, 18):
|
|
self.floor[j][i] = C[j - 9][i]
|
|
D = random_part()
|
|
for i in range(16, 32):
|
|
for j in range(9, 18):
|
|
self.floor[j][i] = D[j - 9][i - 16]
|
|
|
|
def display_map(self):
|
|
for x in range(map_width):
|
|
for y in range(map_height):
|
|
self.surface.blit(textures[self.floor[y][x]],
|
|
(x * tile_size, y * tile_size)) |