summaryrefslogtreecommitdiff
path: root/GameView.py
diff options
context:
space:
mode:
Diffstat (limited to 'GameView.py')
-rw-r--r--GameView.py96
1 files changed, 82 insertions, 14 deletions
diff --git a/GameView.py b/GameView.py
index 3b458d8..d2badfe 100644
--- a/GameView.py
+++ b/GameView.py
@@ -10,15 +10,77 @@ import pygame
class GameView:
- game = Game()
-
- cellWidth = 64
-
- _tickTime = 700
-
- _previousTick = None
-
- nextControlDirection = None
+ def __init__(self):
+ self.game = Game([
+
+"""#####O#####
+# # # #
+# # # #
+# # # #
+# #
+# #
+# #
+# #
+# #
+# #
+#####I#####""",
+
+"""#####D#####
+# + #
+# _ #
+# #
+# #
+# #
+# #
+# #
+# #
+# #
+#####I#####""",
+
+"""#####D#####
+# + #
+# + #
+# + #
+# + #
+# b _ #
+# #
+# #
+# #
+# #
+#####I#####""",
+
+"""#####D#####
+#+++++ #
+#+ #
+#+ #
+#_ #
+#####D#####
+# + #
+# b + #
+# + #
+# _ #
+#####I#####""",
+
+"""###########
+# #
+# #
+# #
+# #
+# #
+# #
+# #
+# #
+# #
+#####I#####""",
+ ])
+
+ self.cellWidth = 64
+
+ self._tickTime = 700
+
+ self._previousTick = None
+
+ self.nextControlDirection = None
def isRunning(self): return not self.game.isLost()
@@ -68,10 +130,16 @@ class GameView:
def update(self, time):
- if (self._previousTick == None) or (self._previousTick + self._tickTime <= time):
- self._previousTick = time
- if self.nextControlDirection != None:
- self.game.snake.heading = self.nextControlDirection
- self.nextControlDirection = None
+ if self.nextControlDirection != None:
+ self.game.snake.heading = self.nextControlDirection
+ self.nextControlDirection = None
self.game.tick()
+ # Time-dependent:
+ # if (self._previousTick == None) or (self._previousTick + self._tickTime <= time):
+ # self._previousTick = time
+ # if self.nextControlDirection != None:
+ # self.game.snake.heading = self.nextControlDirection
+ # self.nextControlDirection = None
+ # self.game.tick()
+