This bug is just freaky... a method that is supposed to act on attribuite pos of that class is acting on pos OF ANOTHER CLASS!
in
Programming Questions
•
1 year ago
so
this link lets you download my sketchbook. The sketch Tilde is what I'm talking about here.
When you click the mouse, it's supposed to add a new bullet to the game, which is supposed to shoot off towards the bottom of the screen. The problem is, the bullet is somehow dragging the player character along with it! I traced the problem to method update() of MotileRect, which does
pos.add(speed); //this is supposed to add this MotileRect's speed vector to this MotileRect's position vector,
thus moving it. But somehow it adds the MotileRect speed vector to the Player's position vector! how?!!?!
When you click the mouse, it's supposed to add a new bullet to the game, which is supposed to shoot off towards the bottom of the screen. The problem is, the bullet is somehow dragging the player character along with it! I traced the problem to method update() of MotileRect, which does
pos.add(speed); //this is supposed to add this MotileRect's speed vector to this MotileRect's position vector,
thus moving it. But somehow it adds the MotileRect speed vector to the Player's position vector! how?!!?!
1