summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--peter.py11
-rwxr-xr-xpyglet_snake.py6
2 files changed, 16 insertions, 1 deletions
diff --git a/peter.py b/peter.py
new file mode 100644
index 0000000..dd3920b
--- /dev/null
+++ b/peter.py
@@ -0,0 +1,11 @@
+from pyglet_snake import PygletSnakeEngine
+
+def my_bot(board, position):
+ x, y = position
+ print board[y][x]
+ return 'U'
+
+p = PygletSnakeEngine(25, 25, 10)
+p.add_bot(my_bot)
+p.run()
+
diff --git a/pyglet_snake.py b/pyglet_snake.py
index e600c7f..4ad174e 100755
--- a/pyglet_snake.py
+++ b/pyglet_snake.py
@@ -10,6 +10,7 @@ pyglet.resource.reindex()
from pyglet.gl import *
+from common import *
from snake import SnakeEngine
def scale_aspect((source_width, source_height), (target_width, target_height)):
@@ -103,6 +104,9 @@ class PygletSnakeEngine(SnakeEngine, pyglet.window.Window):
pyglet.app.exit()
super(PygletSnakeEngine, self).update_snakes(*args)
+ def run(self):
+ pyglet.app.run()
+
if __name__ == '__main__':
from bots import *
from oldbot import BotWrapper
@@ -113,5 +117,5 @@ if __name__ == '__main__':
game.add_bot(random_bounds_bot)
game.add_bot(random_square_bot)
game.add_bot(BotWrapper('oldbots/peter.py'))
- pyglet.app.run()
+ game.run()