The code to calculate the actual position is the calculate_origin function, that I have copied here straight from the tutorial:
def calculate_origin(self):
# - spawn bullet at end of turret barrel instead tank center -
# cannon is around Tank.side long, calculatet from Tank center
# later subtracted 20 pixel from this distance
# so that bullet spawns closer to tank muzzle
self.pos[0] += math.cos(degrees_to_radians(self.boss.turretAngle)) * (Tank.side-20)
self.pos[1] += math.sin(degrees_to_radians(-self.boss.turretAngle)) * (Tank.side-20)
Now my code doesn't look like that of course, my calculate_origin function looks like this:
def calculate_origin(self):
# - spawn bullet at end of turret barrel instead tank center -
# cannon is around Tank.side long, calculatet from Tank center
# later subtracted 20 pixel from this distance
# so that bullet spawns closer to tank muzzle
self.pos[0] += math.cos(degrees_to_radians(self.boss.angle_to_pointer +1))# * (104)
self.pos[1] += math.sin(degrees_to_radians(-self.boss.angle_to_pointer -1))# *(104)
Obviously that did not work, so here's where you come in Here is a link to all my relevant files: link. In the file game.py there is a class called Player with a method called update, that's where all the code is for the Player. In the class Projectile there is also an update method and __init__ method with the necessary code. The calculate_origin function can be found in the Projectile class.
If you have any questions, just ask.
Thanks!