53 lines
1.1 KiB
Python
53 lines
1.1 KiB
Python
from gui import *
|
|
from vector2 import *
|
|
|
|
class World:
|
|
"""
|
|
Staticky herni svet
|
|
|
|
@Author: zbyv
|
|
@Date: 22.11.2023
|
|
"""
|
|
def __init__(self, data: list[list[int]], symbols: list[str]) -> None:
|
|
self.__width = len(data[0])
|
|
self.__height = len(data)
|
|
self.__data = data
|
|
self.__symbols = symbols
|
|
|
|
"""
|
|
Sirka sveta
|
|
"""
|
|
@property
|
|
def width(self) -> int:
|
|
return self.__width
|
|
|
|
"""
|
|
Vyska sveta
|
|
"""
|
|
@property
|
|
def height(self) -> int:
|
|
return self.__height
|
|
|
|
"""
|
|
Zjisti, jestli je policko na zadane pozici prazdne.
|
|
|
|
Args:
|
|
position: Pozice pro kontrolu
|
|
|
|
Returns:
|
|
True pokud je policko prazdne, jinak False
|
|
"""
|
|
def is_empty(self, position: Vector2) -> bool:
|
|
return self.__data[position.y][position.x] == 0
|
|
|
|
"""
|
|
Vykresli svet na zadanou instanci Gui
|
|
|
|
Args:
|
|
gui: Gui, na ktere se svet vykresli
|
|
"""
|
|
def draw(self, gui: Gui) -> None:
|
|
for y in range(self.height):
|
|
for x in range(self.width):
|
|
gui.draw(x, y, self.__symbols[self.__data[y][x]])
|