Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Clocking  (Read 3599 times)

0 Members and 1 Guest are viewing this topic.

sebastiend

  • Newbie
  • *
  • Posts: 9
    • View Profile
Clocking
« on: March 11, 2008, 08:37:22 pm »
I get a problem with the clock.

The following code works:

Code: [Select]
from PySFML import *

if __name__ == "__main__":
    clock = sf.Clock()
    print clock.GetElapsedTime()
    clock.Reset()
    while True:
        if clock.GetElapsedTime() >= 10.0:
            print "Tick"
            clock.Reset()


I followed the same scheme into a class making units and a program havind a drawing part but clock looks staying at this value: 1205263872.0

Here is my function:
Code: [Select]
       if self.clock.GetElapsedTime() >= 10 and len(self.buildingQueue) > 0:
            self.parent.addUnit()
            self.buildingQueue.pop(0)
            self.clock.Reset()

Seconds don't seem to matter, the queue is completely proceeded with no delay. The function is called each frame to check if a unit must be created according to the delay.

sebastiend

  • Newbie
  • *
  • Posts: 9
    • View Profile
Clocking
« Reply #1 on: March 13, 2008, 08:43:18 pm »
Sorry.
It is my fault. Reusing the class in the same way into a test program works, except that I still don't know what make the first implementation wrong.

 

anything