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

RE: [pygame] time progression independent of game "ticks"



Have you considered using time deltas?

Each fish instance could be initialised a timestamp of its creation, and
each iteration of the main loop you could get a timestamp of *now* and pass
it to each fish (or get each fish to get its own *now* for comparison),
which could then use Python's builtin timedelta class to work out how much
real time has passed, rather than how much game time has passed in game
ticks.

So if an instance of fish was "born" on 4:15pm in-game then at 4:30pm, your
fish instance will roll out the birthday cake.

I realise this may seem like more overhead, since pygame already has a clock
class, but for me, I rely on the clock class to provide a nice and friendly
way of adjusting framerate, rather than a definitive timepiece for my game.

Of course, I could just be spouting bollocks.



~Chris

-----Original Message-----
From: owner-pygame-users@xxxxxxxx [mailto:owner-pygame-users@xxxxxxxx]On
Behalf Of Daniel Nixon
Sent: Friday, July 20, 2007 00:20
To: pygame-users@xxxxxxxx
Subject: [pygame] time progression independent of game "ticks"


Hi list,

I'm working on a game in which the player looks after a fishtank full
of fish. Each fish ages, gestates while pregnant, grows hungrier, etc.
For arguments sake lets say 15 minutes = 1 fish year. I want this
passage of time to be independent of frame rate and iterations through
the main game loop (or do I?).

What is the best way to go about such a thing? Use MVC and run the
model in its own thread? If that is the case what is the best way to
keep track of the passage of actual time within the model?

Thanks for reading.

-- 
Regards
Daniel Nixon




CONFIDENTIAL NOTICE: This email including any attachments, contains 
confidential information belonging to the sender. It may also be 
privileged or otherwise protected by work product immunity or other 
legal rules. This information is intended only for the use of the 
individual or entity named above.  If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, 
distribution or the taking of any action in reliance on the contents 
of this emailed information is strictly prohibited.  If you have 
received this email in error, please immediately notify us by 
reply email of the error and then delete this email immediately.