In pyglet's sprite module, all vertex coordinates are converted to int
and put into an int-based vertex list. After applying the small patch
below you'll notice the animation in the astraea example is much
smoother, particularly the slow moving objects.
@@ -363,15 +363,15 @@ class Sprite(event.EventDispatcher):
self._texture = texture
def _create_vertex_list(self):
if self._batch is None:
self._vertex_list = graphics.vertex_list(4,
- 'v2i/%s' % self._usage,
+ 'v2f/%s' % self._usage,
'c4B', ('t3f', self._texture.tex_coords))
else:
self._vertex_list = self._batch.add(4, GL_QUADS,
self._group,
- 'v2i/%s' % self._usage,
+ 'v2f/%s' % self._usage,
'c4B', ('t3f', self._texture.tex_coords))
self._update_position()
self._update_color()
def _update_position(self):
@@ -387,29 +387,29 @@ class Sprite(event.EventDispatcher):
y = self._y
r = -math.radians(self._rotation)
cr = math.cos(r)
sr = math.sin(r)
- ax = int(x1 * cr - y1 * sr + x)
- ay = int(x1 * sr + y1 * cr + y)
- bx = int(x2 * cr - y1 * sr + x)
- by = int(x2 * sr + y1 * cr + y)
- cx = int(x2 * cr - y2 * sr + x)
- cy = int(x2 * sr + y2 * cr + y)
- dx = int(x1 * cr - y2 * sr + x)
- dy = int(x1 * sr + y2 * cr + y)
+ ax = (x1 * cr - y1 * sr + x)
+ ay = (x1 * sr + y1 * cr + y)
+ bx = (x2 * cr - y1 * sr + x)
+ by = (x2 * sr + y1 * cr + y)
+ cx = (x2 * cr - y2 * sr + x)
+ cy = (x2 * sr + y2 * cr + y)
+ dx = (x1 * cr - y2 * sr + x)
+ dy = (x1 * sr + y2 * cr + y)
self._vertex_list.vertices[:] = [ax, ay, bx, by, cx, cy,
dx, dy]
elif self._scale != 1.0:
- x1 = int(self._x - img.anchor_x * self._scale)
- y1 = int(self._y - img.anchor_y * self._scale)
- x2 = int(x1 + img.width * self._scale)
- y2 = int(y1 + img.height * self._scale)
+ x1 = (self._x - img.anchor_x * self._scale)
+ y1 = (self._y - img.anchor_y * self._scale)
+ x2 = (x1 + img.width * self._scale)
+ y2 = (y1 + img.height * self._scale)
self._vertex_list.vertices[:] = [x1, y1, x2, y1, x2, y2,
x1, y2]
else:
- x1 = int(self._x - img.anchor_x)
- y1 = int(self._y - img.anchor_y)
+ x1 = (self._x - img.anchor_x)
+ y1 = (self._y - img.anchor_y)
x2 = x1 + img.width
y2 = y1 + img.height
self._vertex_list.vertices[:] = [x1, y1, x2, y1, x2, y2,
x1, y2]
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.