The mouse position is an integral value, but self.game.dt
is not integral.
If self.vel
is a list or tuple, self.vel * self.game.dt
doesn't do what you'd expect. It doesn't multiply each element of the list, it doubles the list.
You must change the components of the coordinate separately:
self.pos += self.vel * self.game.dt
self.pos = (
self.pos[0] + self.vel[0]*self.game.dt,
self.pos[1] + self.vel[1]*self.game.dt)
If self.pos
is not a tuple but a list, it can be made shorter:
self.pos[0] += self.vel[0]*self.game.dt
self.pos[1] += self.vel[1]*self.game.dt
Pygame provides pygame.math.Vector2
for vector arithmetic.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…