Reputation: 11
I imported math. whenever I try to use it and run the code, I get this error:
AttributeError: module 'pygame.math' has no attribute 'sin'
This is my code:
def move(steps,):
try_move(steps * math.sin(direction),0)
try_move(0,steps * math.cos(direction) )
Upvotes: -3
Views: 59
Reputation: 262204
It doesn't look like you imported the builtin math
module, but rather pygame.math
(which doesn't have a sin
function).
You should import math
and not from pygame import math
:
import math
math.sin(direction)
Your error is quite clear about it, notice the pygame.math
:
AttributeError: module 'pygame.math' has no attribute 'sin'
Upvotes: 7