xpenguins cont'd - repainting a window after penguins walk on it, and when penguins overlap.

Alan Cox alan at lxorguk.ukuu.org.uk
Mon Jun 6 02:10:56 PDT 2011


> Can anyone think of a nice way to handle this?  The only thing I can think
> of is to do some sort of collision/overlapping detection and then be careful
> about the bits of background that gets copied between the penguins in
> question.

Or accumulate all your updates then merge them and do them

> However I'm not a computer scientist and the only way that makes sense for
> me to implement this is lots of inefficient loops to check every penguin
> against every other penguin.

That's a beginners game writing question not surprisingly. Games
often solve this in simple form by keeping all their sprites (penguins in
your case) in a sorted list (eg top to bottom, left to right). You still
have to do a bit of scanning as obviously the top of one penguin can land
on the feet of another, but you can do a lot less scanning that way.

> A related question -- do you think it's viable to make one (transparent)
> window per penguin? It would be easier than drawing them directly onto an
> existing window (Famous Last Words), but say I had 25 penguins -- would 25
> new windows be a big memory drain or is X good at that sort of thing

X really doesn't care mich about lots of windows. A modern X server
should also handle lots of penguins Ok. The old X implementation was very
bad at complicated shaped windows but nowdays it seems much better.



More information about the xorg mailing list