vielleicht statt wait(4) sleep(40), dann hast dus noch frameratenunabhängig 25 mal pro sekunde.