Me and a few friends have been coding an intresting new shooting mechanic. For It to work, we need to shoot in the direction the player is facing. The Sprite is being rotate
You have angle
in degrees so try this:
import math
# angle examples
for angle in [0, 30, 45, 60, 0+90, 30+90, 45+90, 60+90, 0+180, 30+180, 45+180, 60+180, 0+270, 30+270, 45+270, 60+270]:
bullet_speed = 10
bullet_move_x = bullet_speed * math.cos( math.radians(angle) )
bullet_move_y = -bullet_speed * math.sin( math.radians(angle) )
print angle, bullet_move_x, bullet_move_y
Now you can add bullet_move_x
, bullet_move_y
to bullet positon.
For better results keep bullet position as float
and convert to int
when you blit bullet