using “lastx” and “lasty” to store ball position before update