pygame: current time millis and delta time

pygame, python, python-3.x

Solution

From the documentation: `pygame.time.Clock.get_time` will return the number of milliseconds between the previous two calls to `Clock.tick`.

There is also `pygame.time.get_ticks` which will return the number of milliseconds since `pygame.init()` was called.

Delta-time is simply the amount of time that passed since the last frame, something like:

t = pygame.time.get_ticks()
# deltaTime in seconds.
deltaTime = (t - getTicksLastFrame) / 1000.0
getTicksLastFrame = t

Problem

As you can see in the below code I have a basic timer system ``` done = False clock = pygame.time.Clock() # Create an instance of the Game class game = space_world.SpaceWorld() # Main game loop while not done: # Process events (keystrokes, mouse clicks, etc) done = game.process_events() # Update object positions, check for collisions... game.update() # Render the current frame game.render(screen) # Pause for the next frame clock.tick(30) ``` My question is, how can I get the current time milli seconds and how do I create delta time, so I can use it in the update method ?

Original source