parent
713504a3d5
commit
3982e7ab40
2
main.py
2
main.py
|
@ -38,6 +38,8 @@ class Game:
|
||||||
self.running = False
|
self.running = False
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
input("Press enter to leave from game")
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
Game().play()
|
Game().play()
|
||||||
|
|
1
out.py
1
out.py
|
@ -36,3 +36,4 @@ class Out:
|
||||||
)
|
)
|
||||||
|
|
||||||
frame.show()
|
frame.show()
|
||||||
|
print(F"Score: {pl.score}")
|
||||||
|
|
|
@ -13,6 +13,8 @@ class Player:
|
||||||
self.food = Food(0, 0, self)
|
self.food = Food(0, 0, self)
|
||||||
self.food.generate_new()
|
self.food.generate_new()
|
||||||
|
|
||||||
|
self.score = 0
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
sleep(1 / FPS)
|
sleep(1 / FPS)
|
||||||
|
|
||||||
|
@ -31,6 +33,7 @@ class Player:
|
||||||
|
|
||||||
if self.body[-1] == self.food:
|
if self.body[-1] == self.food:
|
||||||
self.food.generate_new()
|
self.food.generate_new()
|
||||||
|
self.score += 1
|
||||||
else:
|
else:
|
||||||
self.body.pop(0)
|
self.body.pop(0)
|
||||||
|
|
||||||
|
|
2
point.py
2
point.py
|
@ -12,7 +12,7 @@ class Point:
|
||||||
else:
|
else:
|
||||||
raise TypeError("You can compare only Point with Point")
|
raise TypeError("You can compare only Point with Point")
|
||||||
|
|
||||||
def __hash__(self) -> None:
|
def __hash__(self) -> int:
|
||||||
return int(f"{abs(self.x)}000{abs(self.y)}")
|
return int(f"{abs(self.x)}000{abs(self.y)}")
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
|
Loading…
Reference in New Issue