I'm working with animation in my game, but I've got an error.. Can you help me pls?)
Or do I need to add all of my code?
class Animation:
def __init__(self, x, y, sprites=None, time=100):
self.x = x
self.y = y
self.sprites = sprites
self.time = time
self.work_time = 0
self.skip_frame = 0
self.frame = 0
def update(self, dt):
self.work_time += dt
self.skip_frame = self.work_time // self.time
if self.skip_frame > 0:
self.work_time = self.work_time % self.time
self.frame += self.skip_frame
if self.frame >= len(self.sprites):
self.frame = 0
def get_sprite(self):
return self.sprites[self.frame]
Traceback (most recent call last):
File "C:\Users\Zyzz\Desktop\game\bin.py", line 210, in <module>
target.update(dt)
File "C:\Users\Zyzz\Desktop\game\bin.py", line 98, in update
self.skip_frame = self.work_time // self.time
TypeError: unsupported operand type(s) for //: 'int' and 'module'
Animation(..)constructors.timeparameter...timewhen you createAnimation? That is themodulethe error is complaining about, and it would happen regardless of Python version. Of course, it may happen that because of something elsewhere in the code, Python 3 is passing amodulewhere Python 2 was passing anint.