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

Re: [pygame] Game played over the desktop?



Chris, this is awesome.

I'm thinking that upon "startup", I could grab a screenshot of their desktop and load it as the pygame background. I'd also perform some sort of effect, like a fade, or a screen flash or something, and then the game would start. Their desktop would remain inaccessible, as you state, during gameplay but I think that's totally acceptable. Upon game exit, I could perform another effect to let them know it's over and the desktop is theirs once again. Of course, it's also entirely possible something changed underneath the game during play that would let them know it's back too (someone IM'd them, a terminal window scrolled, etc).

Now, to play.

Thanks!
Myles

Chris Ashurst wrote:
Your first issue would be that unless you used hardware acceleration,
running a Pygame app at the native desktop resolution may result in serious
slowdown. However, others on this list may know more than this than I do,
since controlling fps is an area in which I lack knowledge :)

However, I'm a wxPython nutball, so I know of a few things that may help
you... Basically, your original ideas are logically sound, but only the
second idea would be the most feasible.

There's a recipe on the wxPython wiki that demonstrates transparent windows
by changing the alpha value of the frame through win32api calls, but this
changes the alpha of everything in the frame, so that throw it out the
window (haha). http://wiki.wxpython.org/index.cgi/Transparent_Frames_on_MSW

The second method is exactly as you describe it. A quick search revealed
this small recipe:
http://mail.python.org/pipermail/python-list/2003-June/166806.html.

It basically screengrabs the current desktop and saves it as a bmp (although
I'm certain you could easily run it through PIL or whatever to convert it to
something less huge).

If you didn't want to use wxPython and remain with straight Pygame, you
could easily build a wx application that lived in the system tray (since a
wxPython main thread doesn't die if the app loads itself into the system
tray) whilst the game was running, and updated the dekstop bitmap every X
seconds/minutes/whatever (since you can't access wx functionality without
starting an application loop).

The only problem with the second method would be that a user would not be
able to use their desktop icons (as it's just a picture), unless you built a
procedure that recognised what an icon looked like and extracted their
positional information which could then handle icon events if and when a
user decides to try and use their desktop stuff.

Hope some of my waffling helps you with your ideas :)

~Chris