[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] update() or tick()
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] update() or tick()
- From: Tom Wardill <tom@xxxxxxxxxxxxx>
- Date: Wed, 24 May 2006 19:55:16 +0100
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Wed, 24 May 2006 14:55:13 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=MRB6CMgDXeuTwO25cVrNuCwT91oBwch7ZmZrtPeaMtAh4ab2K46ZIaCcdr4JU8V9LDodTamaGDAX3ifIUXC8Ln0TMRH1uk4+oxG0wRbAw3DvqvnelyEwa6kGVirM2QrAwaEeIL3XAQt7nf8tbq8I+bfBMxM53zRW/Vhz4Ta6GA4=
- In-reply-to: <44747CBB.5020100@bluewin.ch>
- References: <448ACE3E@minerva2.ex.ac.uk> <44747CBB.5020100@bluewin.ch>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Thunderbird 1.5.0.2 (Windows/20060308)
DR0ID wrote:
In many examples and tutorials of pygame a update() method is used.
This means that in the main loop in one place one has to go through
the objects list and call the update() method. This is done every
frame of the game.
This is the 'normal' method of dealing with animation, with the addition
of a timer to ensure smooth movement across the screen. Relatively easy
to program, develop and work with.
A similar but eventbased approach is using a special event, lets call
it E_tick(). But then a event dispatching mechanisme is needed and for
updating the objects a special event E_tick() would be used to update
the objects. E_tick() has the actual time or the time elapsed in the
last frame, so the object can update accordingly (I think the elapsed
time is more usefull as the absolute time but perhaps one should pass
both so the object can use what it need).
This works in places but I can see two main flaws in it (off the top of
my head, I've never worked this way before). The first is that the
overhead is going to be relatively large in dealing with the events, so
it may be slower than the other method (no numbers on this, as I said,
not done this). The other is that if you use an event to cause something
to happen, you have to wait for an event for it to happen, if this makes
sense. Your program will not run until an event is triggered.
You could cause a trigger based on the time or something equivalent, but
then you've just recreated the above method.
It will also be more work to implement.
Hope this helps, if I've misunderstood the problem, I apologise, post
again and I'll see if I can help.
--
TomW