63 lines
1.4 KiB
Python
63 lines
1.4 KiB
Python
from vector2 import *
|
|
|
|
class Gui:
|
|
"""
|
|
Zahrnuje funkcionalitu pro uzivatelsky vstup a vystup
|
|
|
|
@Author: zbyv
|
|
@Date: 22.11.2023
|
|
"""
|
|
def __init__(self, width: int, height: int) -> None:
|
|
self.__width = width
|
|
self.__height = height
|
|
# self.__data = None
|
|
self.clear()
|
|
|
|
"""
|
|
Nastavi zadany symbol na zadanou pozici
|
|
|
|
Args:
|
|
x: `x` souradnice
|
|
y: `y` souradnice
|
|
symbol: znak pro vykresleni
|
|
"""
|
|
def draw(self, x: int, y: int, symbol: str) -> None:
|
|
self.__data[x + y * self.__width] = symbol
|
|
|
|
"""
|
|
Vykresli cele herni pole
|
|
"""
|
|
def show(self) -> None:
|
|
for y in range(self.__height):
|
|
for x in range(self.__width):
|
|
print(self.__data[x + y * self.__width], end="")
|
|
|
|
print("")
|
|
|
|
"""
|
|
Vycisti cele herni pole
|
|
"""
|
|
def clear(self):
|
|
self.__data = [" " for _ in range(self.__width * self.__height)]
|
|
|
|
"""
|
|
Vyzada si od uzivatele smer pohybu
|
|
|
|
Returns:
|
|
Vector2 reprezentujici zadany smer pohybu
|
|
"""
|
|
|
|
def input_direction(self) -> Vector2:
|
|
match input("pohyb: "):
|
|
case "2":
|
|
return Vector2(0, 1)
|
|
case "4":
|
|
return Vector2(-1, 0)
|
|
case "6":
|
|
return Vector2(1, 0)
|
|
case "8":
|
|
return Vector2(0, -1)
|
|
case _:
|
|
return Vector2(0, 0)
|
|
|