Evening there. I need to return an (x,y) tuple of an object, This x,y will be used to help 1 object calculate where the other object is and move towards it.
My problem is that both the objects need to know the others' x,y.
(i'm unsure how to get the x,y of both the objects in one tuple and still tell them apart.)
While writing that i thought that maybe i put 4 values in the tuple say, x1,y1,x2,y2 and then for the 1st object call x1,y1 only and the same for object 2, would that work?
Also i thought tuples are not changable and hence after the objects move towards each other, the loop'll start again and check their x,y but the x,y will be the same wont it because tuples cant be changed?
am i right or am i missing some way around this?
Sorry if i'm unclear and i apologies for the long post, i sometime have ideas of solving things while i'm writing the problem out.
Gets your brain moving and all.
Traceback (most recent call last):
r1.step(r2.getPos()[0],r2.getPos()[1])
AttributeError: r2 instance has no attribute 'getPos'
thats quite a shortened down version, it might be enough.
The part that confuses me is the part in the error was written by my lecturer and therefore is correct.
I have defined getPos() for both r1 and r2 (my objects), so why do i get that error?
Any one got any clues? As i dont.
cheers
Last edited by thehivetyrant; Oct 26th, 2009 at 9:46 am.
But then again you're using r1 and r2 inside this function, which may indicate this isn't a class function at all. So in that case, you wouldn't use r2.getPos(), you should just use getPos().
Maybe you should post a little bit more code so that we have some context to go by.
r1.step(r2.getPos()[0],r2.getPos()[1])
TypeError: getPos() takes no arguments (1 given)
i've given 1 arguement for getPos which apprently shouldnt take one.
Is that my r1=x,y=100,100 thing? should i not give them the values of 100,100 and let them do by themselves?
Last edited by thehivetyrant; Oct 26th, 2009 at 10:00 am.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.