#keep in mind this all deals with SCREEN COORDINATES ONLY
#this is in a foor loop (for all active sprites)
if s.move_init and not s.moving: #s is the sprite (a class i made)
s.steep = abs(s.y1 - s.y0) > abs(s.x1 - s.x0)
if s.steep:
s.x0, s.y0 = s.y0, s.x0 #x0, y0 are current position, x1, y1 are destination
s.x1, s.y1 = s.y1, s.x1
if s.x0 > s.x1:
#if python gets HERE, then it messes stuff up. its fine if it does not go here
s.x0, s.x1 = s.x1, s.x0
s.y0, s.y1 = s.y1, s.y0
s.delta_x = s.x1 - s.x0
s.delta_y = abs(s.y1 - s.y0)
s.error = 0
s.x = s.x0
s.y = s.y0
if s.y0 < s.y1:
s.y_step = 1
else:
s.y_step = -1
s.moving = True
if s.moving:
if s.steep:
s.s_x = s.y
s.s_y = s.x
else:
s.s_x = s.x
s.s_y = s.y
s.update_pos() #stops sprite when it reaches its destination
s.error = s.error + s.delta_y
if 2 * s.error >= s.delta_x:
s.y = s.y + s.y_step
s.error = s.error - s.delta_x
s.x += 1
glTranslatef(s.s_x, s.s_y, 0) #translate the sprite