I am making a tank game and I have tank and bullet objects. When I fire, following method is executed:
def newshot(self,tank):
shot = bullet()
shot.loc = tank.loc
shot.speed = tank.direction
self.shots.append(shot)
loc is a list that show the location [x,y], speed and direction are lists that show the speed [dx,dy].
To move each of the bullets speed vector was added to its location in a for loop. But whenever I changed the location of the bullet, the location of my tank also changed (I printed out a tanks location before and after the for loop). What I did that solved my problem was that instead of doing
shot.loc = tank.loc
I did
shot.loc = [tank.loc[0],tank.loc[1]]
My question is where is the difference?