Re: Difference between frames and milliseconds?
What pygame.clock found here does is limit how fast your game runs. I.e, if you set it at 60 FPS and you finish before 16.66 ms were up, Pygame will call the wait function on it's own to keep the game at 60 FPS. This is what confuses me.
get_time()
time used in the previous tick
get_time() -> milliseconds
The number of milliseconds that passed between the previous two calls to Clock.tick().
It seems like this already calculates delta under the hood... or am I misunderstanding this? I tried googling framerates in Pygame, but I haven't found anything helpful... most of what I found pointed me back to Pygame docs, which doesn't really help. In addition, the Pygame examples themselves seem to keep track of times in frames? If you look at aliens.py, you'll find the following (Lines 55 - 61):
# each type of game object gets an init and an
# update function. the update function is called
# once per frame, and it is when each object should
# change it's current position and state. the Player
# object actually gets a "move" function instead of
# update, since it is passed extra information about
# the keyboard
Here is a sample of the alien class
class Alien(pygame.sprite.Sprite):
speed = 13
animcycle = 12
images = []
def __init__(self):
pygame.sprite.Sprite.__init__(self, self.containers)
self.image = self.images[0]
self.rect = self.image.get_rect()
self.facing = random.choice((-1,1)) * Alien.speed
self.frame = 0
if self.facing < 0:
self.rect.right = SCREENRECT.right
def update(self): self.rect.move_ip(self.facing, 0) if not SCREENRECT.contains(self.rect): self.facing = -self.facing; self.rect.top = self.rect.bottom + 1 self.rect = self.rect.clamp(SCREENRECT) self.frame = self.frame + 1 self.image = self.images[self.frame//self.animcycle%3]
So again, no mention of delta anywhere which is surprising because, ur, that's supposed to be the core of each sighted game, right?
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector