I've seen fixes to this problem elsewhere on StackOverflow, but I'm too new to this language to apply them to mine.
I'm making a Surface, drawing stuff on it, and then rotating it. The result is the same as this guy's issue:
The rectangle moves erratically as it rotates. Is this fixable, or must I change my approach?
from pygame import *
import sys
def drawShip(pos,angle,width,height,surface):
canvas = Surface((width,height))#A canvas to draw the ship on
r = ((1),(1),width,height)#A placeholder rectangle
draw.rect(canvas,(255,0,0),r)#Draw r on the surface
canvas = transform.rotate(canvas,angle)#Rotate the canvas
surface.blit(canvas,((pos[0] - width/2),(pos[1] - height/2)))#Draw the canvas onto the main surface
s = display.set_mode((500,500))#Create the main surface
i = 0
while True:
for e in event.get():
if e.type == QUIT:
sys.exit()
if e.type == KEYDOWN:
i += 5
drawShip((250,250),i,100,100,s)#Draw a ship
display.flip()#Update the display