summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ward <peteraward@gmail.com>2012-07-01 14:29:33 +1000
committerPeter Ward <peteraward@gmail.com>2012-07-01 14:29:33 +1000
commit7fb2789ea7b25a4825ff4b99a832758d3533ded5 (patch)
tree075e11ac2dae642f1bcd11bb5874cff3b5eff5ee
parent0549a8a244a89778e2c39d14b98adfcc8a0b2526 (diff)
Some refactoring.
-rwxr-xr-xpyglet_snake.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/pyglet_snake.py b/pyglet_snake.py
index 3d3cfc1..5a17ac0 100755
--- a/pyglet_snake.py
+++ b/pyglet_snake.py
@@ -2,15 +2,13 @@
from __future__ import division
-import time
-
import pyglet
pyglet.resource.path = ['images']
pyglet.resource.reindex()
-from pyglet.gl import *
+from pyglet import gl
-from common import *
+import common
from snake import SnakeEngine
def scale_aspect((source_width, source_height), (target_width, target_height)):
@@ -33,8 +31,8 @@ class PygletSnakeEngine(SnakeEngine, pyglet.window.Window):
def __init__(self, rows, columns, n_apples, *args, **kwargs):
super(PygletSnakeEngine, self).__init__(rows, columns, n_apples, *args, **kwargs)
- glEnable(GL_BLEND)
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
+ gl.glEnable(gl.GL_BLEND)
+ gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
pyglet.clock.schedule_interval(lambda t: self.update_snakes(), 0.025)
@@ -77,20 +75,20 @@ class PygletSnakeEngine(SnakeEngine, pyglet.window.Window):
r = (left, top, right, top, right, bottom, left, bottom)
# Draw a square.
- glLineWidth(self.EDGE_WIDTH)
- pyglet.graphics.draw(4, GL_LINE_LOOP,
+ gl.glLineWidth(self.EDGE_WIDTH)
+ pyglet.graphics.draw(4, gl.GL_LINE_LOOP,
('v2f', r),
('c4B', self.EDGE_COLOR * 4))
# Draw the things on the square.
- if cell == Squares.APPLE:
+ if cell == common.Squares.APPLE:
w, h = self.apple.size
self.apple.blit(left + (xscale - w) / 2.0, top - h, width=w, height=h)
elif cell.isalpha(): # Snake...
colour = self.bots[cell.lower()][1] + (255,)
- glPolygonMode(GL_FRONT, GL_FILL)
- pyglet.graphics.draw(4, GL_POLYGON,
+ gl.glPolygonMode(gl.GL_FRONT, gl.GL_FILL)
+ pyglet.graphics.draw(4, gl.GL_POLYGON,
('v2f', r),
('c4B', colour * 4),
)