Java is pass by value, period, end of story. Pass by Reference means you can write this, which you cannot do in Java:
public void swap(Object a, Object b)
All non-primitives are accessed by references, but those references are passed by value. “Pass by reference” and “passing references” are two different things. I’m not just nitpicking here; when you explain this stuff to people coming from C++ or C# or PHP which actually does have pass-by-reference, it gets confusing when they get told Java passes by reference when it does not.
Remember the formula of the distance traveled by a body (I really don’t know how you guys call this, I’m not a native english speaker. I’m talking about accelerated movement in a vertical shot):
From the way I see it, this movement resembles a lot to the one of a boomerang (Only if you throw it with a 90º angle. If you click above the head of the player)
If you already have a way to calculate the angle between the player and the position where the user clicked…
…then I’m pretty sure there is a way to “shift” the trajectory of the boomerang by multiplying it for the sine or cosine of the angle. I’m afraid I can’t help you with that because I suck at math, even worse than how I suck at speaking english. But I think someone smarter should have no problem.
I hope I didn’t misunderstood the problem and this could actually help.
thanks, that’s really helpful for when I figure out what the hell is going on with the boomerang inexplicably starting from the wrong position and travelling in the wrong direction.
I’m going to try using floats for my co-ordinates and see if that makes any difference.
IMHO there is no need to distinguish primitives and non-primitives. In both cases a ‘copy’ is pushed on the stack of the call site, which is popped by the target - whether that is a primitive or a reference doesn’t matter.
Sure, but it’s a copy of the reference, not the contents of the object. Most people who’ve learned Java first have just internalized this stuff, and others who have learned a bunch of languages before are aware of all the different conventions, so it’s really just people who only knew maybe one or two other languages beforehand who get confused.