console_snake/out.py

42 lines
989 B
Python
Raw Normal View History

2022-10-26 21:57:29 +03:00
from settings import *
from player import Player
from frame import Frame
class Out:
2022-10-27 00:29:36 +03:00
def __init__(self, pl: Player) -> None:
2022-10-26 21:57:29 +03:00
self.width = WIDTH
self.height = HEIGHT
2022-10-27 00:29:36 +03:00
self.pl = pl
2022-10-26 21:57:29 +03:00
2022-10-27 00:29:36 +03:00
def draw(self) -> None:
2022-10-26 21:57:29 +03:00
frame = Frame(self.width, self.height)
2022-10-27 00:29:36 +03:00
pl = self.pl
2022-10-26 21:57:29 +03:00
for point in pl.body:
frame.draw(
x=point.x, y=point.y,
value=WALL,
width=1, height=1
)
2022-10-27 17:03:11 +03:00
frame.draw(
x=pl.body[-1].x, y=pl.body[-1].y,
value=HEAD,
width=1, height=1
)
2022-10-26 21:57:29 +03:00
if frame.see(pl.food.x, pl.food.y) == WALL:
frame.draw(
x=pl.food.x, y=pl.food.y,
value=WALL_FOOD
)
else:
frame.draw(
x=pl.food.x, y=pl.food.y,
value=FOOD
)
frame.show()
2022-10-27 00:29:36 +03:00
print(f"Score: {pl.score}")