Python Forum
why does the counter need to go to -50000 for this to work?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why does the counter need to go to -50000 for this to work?
#4
I don't believe you need all that for that function. This isn't tested (I don't have pygame), but it should accomplish the same task:

    def update(self):
        for co_ord in self.img_co_ords:
            #print "co_ord.sx = " + str(co_ord.sx) + " co_ord.ex = " + str(co_ord.ex) 
            if not co_ord.in_place:
                if co_ord.sx != co_ord.ex:
                    co_ord.sx += (co_ord.ex - co_ord.sx)

                if co_ord.sy != co_ord.ey:
                    co_ord.sy += (co_ord.ey - co_ord.sy)

                co_ord.in_place == True
         
        self.draw()
It's checking if the coordinates match. If they do not, it adds a value to the sx or sy attribute based on the difference between it and its associated partner. If the value is too high, this should add a negative to decrease it; if it is too low, this should add a position to raise it. With this logic, you should only require one pass through the list rendering the outer while loop, the done variable, and the done_count superfluous.

Give it a shot and see if it works.
Reply


Messages In This Thread
RE: why does the counter need to go to -50000 for this to work? - by stullis - Oct-25-2018, 02:25 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020