Regarding the global/local variables: local variables are erased from memory once the function, from wich they where created, finishes. That means that your using less resources.
Global variables stay in memory unless until you close the program, thus using memory space and wasting resources if not needed to be global.
Quote: "how does one get updated and the other stays old? in the same loop?"
Because your thinking too much. You think (i suppose) that everything gets updated once the loop finishes, but tell me.... where does its sats that (for example) oldy# gets updated?, because once the command oldy#=y# was executed in the loop, it doesn't get executed until it does all the loop again, or you move the pointer there.
I've got a friend that gets confused with that also. He thinks that "x1=x1+1" has no sense. And in maths, it does has no sense, because "x1" can never be equal to "x1+1", but this is not maths (not all at least). That same line is read like "x1 'takes the value of' x1+1", but remember that the line is executed on that moment. On the next line the program doesn't care about the previous line.
.So on oldy#=y#, oldy# gets y# value, and then y# changes, but oldy# has already been given the value, and won't change unless you tell it to.
Further on my stuff at...