1 from __future__
import division
3 from pyglet
.gl
import *
9 def __init__ (self
, seg
= None, img
= None):
10 self
.bounce
, self
.friction
, self
.stiction
= 0, 0, 0
11 self
.seg
, self
.__seg
, self
.tex
= seg
or line (), None, img
and img
.texture
15 perp
= seg
.perp ().normed (self
.tex
.height
)
16 self
.__seg
= line (seg
.p1
- perp
, seg
.p2
- perp
)
18 glBindTexture (GL_TEXTURE_2D
, self
.tex
.id)
19 glTexParameteri (GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_BORDER
)
20 except ZeroDivisionError:
25 u
= self
.seg
.length () / self
.tex
.width
26 glBindTexture (GL_TEXTURE_2D
, self
.tex
.id)
27 glBegin (GL_TRIANGLE_STRIP
)
28 glColor4d (1, 1, 1, 1)
30 glTexCoord2d (0, self
.tex
.tex_coords
[10])
31 glVertex3d (self
.seg
.p1
.x
,
35 glTexCoord2d (u
, self
.tex
.tex_coords
[7])
36 glVertex3d (self
.seg
.p2
.x
,
40 glTexCoord2d (0, self
.tex
.tex_coords
[1])
41 glVertex3d (self
.__seg
.p1
.x
,
45 glTexCoord2d (u
, self
.tex
.tex_coords
[4])
46 glVertex3d (self
.__seg
.p2
.x
,