[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] New on the mailing list with a strange FPS behavior



Hi all and thanks for your quick answers.

First I will explain how I did measure and what make me think it's the
draw that stucks :

I use a custom MVC model and the main game object sends a "cpu_tick"
event as quick as it can. I this "cpu_tick" loop, many things happen
(objects move, towers fire, lose life, ....) and the screen is drawn.

In my controller object (the one which receives all the events and
send them back to objects, I've a function like this that is called on
every event received :

def post(self,event):
  for listener in self.listeners:
    now = pygame.time.get_ticks()
    listener.notify(event)
    self.stats[listener].append((pygame.time.get_ticks() - now,event))

So, as you can see, I measure the time taken by each object to react
to each event and the "freeze" is really created by the draw function.

To be sure, I've added in my draw_function :
def draw(self):
  now = pygame.time.get_ticks()
  # clear stuff
  # draw stuff
  self.stats.append(pygame.time.get_ticks() - now)

And I can see the freezing.

This morning, I tried my game on Windows (I'm developping on Linux)
and, on Windows, the game is faster and don't freeze. So maybe RR4CLB
is right and I just have another program using some of my CPU on the
LInux box...

I'll investigate more



-- 
Ghislain Lévêque