summaryrefslogtreecommitdiff
path: root/GameView.py
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-11-04 19:16:14 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-11-04 19:16:14 +0200
commita60a1403b7335719ceca18c745ff663bd6852e94 (patch)
tree1bf6683abf2cfa5c63ab4a2188c4430c7e3195e7 /GameView.py
parentd1c404fe8eac3c743004a9a48a683e9361c8f7b3 (diff)
downloadSnakePuzzle-a60a1403b7335719ceca18c745ff663bd6852e94.tar.gz
SnakePuzzle-a60a1403b7335719ceca18c745ff663bd6852e94.zip
feat: implemented get in OptionalUtils
Diffstat (limited to 'GameView.py')
-rw-r--r--GameView.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/GameView.py b/GameView.py
index 0303445..a670d7c 100644
--- a/GameView.py
+++ b/GameView.py
@@ -1,4 +1,5 @@
+from OptionalUtils import get
from typing import Optional
from Vec import Vec2
from Game import Game
@@ -13,7 +14,7 @@ import pygame
class GameView:
- def __init__(self, timeBased: bool = True):
+ def __init__(self, timeBased: bool = False):
self.timeBased = timeBased
self.game = Game([
@@ -155,24 +156,23 @@ class GameView:
if self.timeBased and (self._previousTick + self._tickTime <= time):
self._previousTick = time
match self.nextControlDirection:
- case None: return None
+ case None: None
case _:
- match self.game.snake:
- case None: return None
- case _:
- self.game.snake.heading = self.nextControlDirection
- self.nextControlDirection = None
+ get(self.game.snake).heading = self.nextControlDirection
+ self.nextControlDirection = None
+# match self.game.snake:
+# case None: return None
+# case _:
+# self.game.snake.heading = self.nextControlDirection
+# self.nextControlDirection = None
self.game.tick()
- else:
+ elif not self.timeBased:
match self.nextControlDirection:
- case None: return None
+ case None: None
case _:
self._previousTick = time
- match self.game.snake:
- case None: return None
- case _:
- self.game.snake.heading = self.nextControlDirection
- self.nextControlDirection = None
+ get(self.game.snake).heading = self.nextControlDirection
+ self.nextControlDirection = None
self.game.tick()