I am making a 2D game. I want to be able to display a texture on the screen after rotating its specific value around a center point. This is mainly for rotating the level around the player. The player’s position is the pivot point and the player’s direction as an angle. This code will not work:
def draw_texture(texture,offset,size,a,rounded,rotation,point):
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glColor4f(1,1,1,float(a)/255.0)
glTranslatef(point[0],point[1],0)
glRotatef(rotation,0,0,1)
glBindTexture(GL_TEXTURE_2D, texture)
if rounded == 0:
glBegin(GL_QUADS)
glTexCoord2f(0.0, 0.0)
glVertex2i(*offset)
glTexCoord2f(0.0, 1.0)
glVertex2i(offset[0],offset[1] + size[1])
glTexCoord2f(1.0, 1.0)
glVertex2i(offset[0] + size[0],offset[1] + size[1])
glTexCoord2f(1.0, 0.0)
glVertex2i(offset[0] + size[0],offset[1])
glEnd()
else:
glEnd()
Any way to make it work? Thank.
source
share