Fixed sprite vertex arrays and sprite gravity
LEFT = 0
CENTER = 1
RIGHT = 2
+TOP = 2
+BOTTOM = 0
class Sprite:
frames = None
if self.gravity[i] == LEFT:
c[i] = 0
elif self.gravity[i] == CENTER:
- c[i] = -self.size[0]/2
+ c[i] = -self.size[i]/2
elif self.gravity[i] == RIGHT:
- c[i] = -self.size[0]
+ c[i] = -self.size[i]
else:
print "Invalid gravity:",x
c[i] = 0
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, self.frames[i])
glColor4fv(self.color)
- glVertexPointerf(vertexarray)
- glTexCoordPointerf(texcoordarray)
+ glVertexPointer(3, GL_FLOAT, 0, vertexarray)
+ glTexCoordPointer(2, GL_FLOAT, 0, texcoordarray)
glDrawArrays(GL_QUADS, 0, 4)
glEndList()
# If your card has trouble with non-square textures (my TNT seems to), set this
# to true to make all textures square
-square_textures = False
+square_textures = True
#scalefactor = 2
#fullscreen = True
ground.position = [0,0]
stars = Collage('data/stars')
stars.position = [0,0]
+candelabra = Sprite(['Sprites/candelabra_short/cand_s_1.png','Sprites/candelabra_short/cand_s_2.png','Sprites/candelabra_short/cand_s_3.png','Sprites/candelabra_short/cand_s_4.png'],False)
+candelabra.position = [64, 50]
+candelabra.gravity = (CENTER, BOTTOM)
+candelabra.framerate = 10.0
+candelabra.anim_start()
+candelabra.gen_displaylist()
def update():
ground.position[0] -= 5
stars.position[0] -= 1
if stars.position[0] < 0:
stars.position[0] += 640
+ candelabra.position[0] -= 5
+ if candelabra.position[0] < 0:
+ candelabra.position[0] += 640
def draw():
stars.draw()
ground.position[0] -= 640
ground.draw()
ground.position[0] += 640
+ candelabra.draw()
n = 0
def fpsthing():