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

Re: [pygame] split newbie strikes back



Miguel Sicart wrote:
> About the physics code - it is the method I learned from Andy Harris'
> Game Programming book. I think it's a great book (it put me up to speed
> with pygame in about a month), but I guess it is a beginners book after
> all. 
> So what should I do, a function that checks the boundaries? (and same
> goes for all the physics checking?)

I personally would prefer to structure things as:

Sprite keeps a reference to the object it represents.
Sprite.update() changes self.rect.center to be object.pos
A separate function or class or something changes the velocity of the
object and its position as needed.

But note that I don't speak with authority here; it's possible that
your structure works better for some types of games. (I was developing
using an external physics library, Open Dynamics Engine, so I *had* to
keep my physics separate in some way.)

Ethan

Attachment: signature.asc
Description: OpenPGP digital signature