Re: [pygame] Pixel Spaceships

2008-03-06 Thread Greg Ewing

Kris Schnee wrote:
I tried rotating a ship to build a list of rotated images, but the 
rotated versions are often larger than the original, making it hard to 
figure out where to place them. How can that problem be addressed?


Use the centre of the image as the point of reference for
positioning it.

--
Greg


Re: [pygame] get_wm_info on linux

2008-03-06 Thread Patrick Mullen
On Wed, Mar 5, 2008 at 9:47 PM, René Dudfield [EMAIL PROTECTED] wrote:
 Is window as an int in there?

  Have a look at src/display.c  There you'll see the X11 properties put in 
 there.

  Is this what you're after?
info = pygame.display.get_wm_info()
windowid = info.get(window)
print The window ID is, hex(windowid)


  display is a pointer on X11.

Right, display is what I am after.  I can get the windowid, but not
the display.  I guess what I am trying to do is impossible?  It's
weird because ogre is expecting a string like this: display
*:screenid,windowid, and I'm not sure how you would put a display *
as a string.  Is it the memory location?

I guess I can ask the ogre guys, although maybe I'll play around with
display.c for a bit - thanks for pointing that out!


Re: [pygame] Pixel Spaceships

2008-03-06 Thread Nick Moffitt
Kris Schnee:
 Fun little exercise. Here's my version of the ship generator,
 attached.  Screenshot:
 http://kschnee.xepher.net/pics/080305pixel_spaceships.jpg I didn't
 get the cockpit designs right in the way Bollinger did, but tried
 superimposing a smaller ship design atop a larger one to get a
 two-tone effect (not seen in that shot).

Neat!  The cool thing about the Bollinger pixel-based technique is that
your bit pattern actually describes a *volume*, so what you're really
doing is drawing a border on any empty pixels NSEW of the one specified.
You then paint the interior with whatever gradient or pattern you're
using separately.

Bollinger did everything on a white background (I blame his desktop
publishing background, which treats screens as paper (even though black
text on a white background is like trying to read the label on a lit
fluorescent bulb to me)).  

For the black background ships I just defined the border as same HSV
pattern, but with the value cranked way up and the saturation down a
touch or similar.  This tended to make a more textured look, which I
was quite happy with.

 I tried rotating a ship to build a list of rotated images, but the
 rotated versions are often larger than the original, making it hard to
 figure out where to place them. How can that problem be addressed?

As others have said here, it's easier to make a rect of the appropriate
size and then just set its center to the center point you want to anchor
on.  I still get wiggly artifacts with the rotation methods though
(haven't tried rotozoom yet).

-- 
N'aimez pas votre voiture?   Nick Moffitt
Alor, l'heure est arrive pour la brulé! [EMAIL PROTECTED]
-- Mark Jaroski


[pygame] PyDay Starts Tomorrow Night!

2008-03-06 Thread PyMike
The PyDay competition will start tomorrow (Friday) at 7:30 PM GMT-6:00. If
you haven't joined up or voted for the theme go to
http://googlegroups.com/group/pyday Good luck everyone!

-- 
- PyMike


[pygame] Texture for raycasting engine

2008-03-06 Thread Julia
Hi everyone!

I am currently working on a raycasting engine using pygame for graphics.
 The
engine works great and now I'm thinking about adding support for textures.
The problem is that I'm not really sure to with modules and methods to use.
I need to be able to load textures, scale then to fit and then draw the
scaled image. Any tips on a smart way to do this? Good tutorial url's are
also appreciated :)

/ J


Re: [pygame] Texture for raycasting engine

2008-03-06 Thread Ian Mallett
Cool!  I've been trying to do something like that...You can make each pixel
in an image a rectangle in 3D space, but this is, I imagine, slow.  Pygame
really should have a function which scales an image to a four-sided polygon.

Sorry I can't help more.
Ian


[pygame] your game in the messenger

2008-03-06 Thread Michael Schmidt
Hello

We'd love to include some games as a networked game in
http://retroshare.sf.net Instant Messenger V.04
Actually some python games are one of my favourite games.. so I adress to
our list.

some games will be the first games we actually integrate, so the interface
is still a little bit up in the air, so if you have any good interface ideas
please send them.

So the proposal for integrating is:

(1) Retroshare provides all the networking, transport etc
and provides a simple C or C++ API for your python game to communicate
with.

(2) Your game is compiled as a static library, and linked into retroshare
for
the moment. as we don't have a plugin architecture written yet.

(3) Retroshare has a 'GameLauncher' which will work out who's
   online and organise the players, and pass that information to your pyhton
game.

(4) Your pyhton game is Launched in its own window in its own thread, and
has
   complete control of that environment. It just uses retroshares API
   to exchange messages with peers.

(5) you can have multiple concurrent py-games if the/your library can
  handle it.

A rough interface could be something like (or a C equivalent) :

class GameInterface
{
   public:
  /* start / stop (called from GameLauncher) */
virtual  startGame(std::string gameId, std::liststd::string
peerIds); /* in turn order (if applicable) */
virtual  quitGame(std::string gameId);

  /* send/recv msgs */

  bool sendMsg(std::string gameId, std::string peerId, void *data,
uint32_t len); /* NULL peerId = broadcast */
  uint32_t msgAvailable(std::string gameid); /* returns next
message length */
  uint32_t recvMsg(std::string gameId, std::string fromId, void
*data, uint32_t len); /* returns msg len */

  /* information for pygame ... */
  std::string getPeerName(std::string peerId);

};


Is this approach acceptable to you? Someone interested to see his game in
the Instant Messenger launchable?

thanks for a feedback

Mike


Re: [pygame] Texture for raycasting engine

2008-03-06 Thread Jason Ward
Hi
You weren't being too specific. so basically it sounds like you are writing
a software renderer. If it's a 3D one which I assum it is, then I have heard
of a good tutorial.
this site has great help for those who are doing software renderers, just
ask at the forums http://www.devmaster.net also tery googling for
perspective texture mapping. Beware the math behind this is not the simplest
thing out.

But if you are just doing 2D then with a bit of thought you can work it out.

I was writing my own software renderer last year in asm but I got sick of it
and just moved to opengl.


Re: [pygame] Texture for raycasting engine

2008-03-06 Thread kschnee
On Thu, 6 Mar 2008 16:51:22 +0100, Julia [EMAIL PROTECTED] wrote:
 Hi everyone!
 
 I am currently working on a raycasting engine using pygame for graphics.
  The
 engine works great and now I'm thinking about adding support for
textures.
 The problem is that I'm not really sure to with modules and methods to
 use.
 I need to be able to load textures, scale then to fit and then draw the
 scaled image. Any tips on a smart way to do this? Good tutorial url's are
 also appreciated :)


Quick reply: Do you mean the basics of loading images in general? If so,
that's just pygame.image.load(), sometimes adding .convert() or
.convert_alpha() for certain other effects. See the Documentation section
of pygame.org for that.

For scaling that's:
scaled_version = pygame.transform.scale(original,(new_width,new_height))

Also, try pygame.transform.scale2x(), which doubles an image's size using
an interpolation technique that looks a lot better than the most obvious
way of scaling up.

If you mean you need to scale a loaded image to a polygon in 3D, take a
look at my Mode 7 code for a slow but usable example that maps a flat
image to a trapezoidal ground:
http://kschnee.xepher.net/code/mode7test.py

Kris



Re: [pygame] Texture for raycasting engine

2008-03-06 Thread kschnee
http://www.permadi.com/tutorial/raycast/
http://student.kuleuven.be/~m0216922/CG/raycasting.html

Here are two tutorials on the subject. I tried making one of these (no
textures), but never did fix the fisheye distortion problem. My version was
also impractically slow. It looks like it's helpful to use matrix-based
math.



Re: [pygame] Texture for raycasting engine

2008-03-06 Thread Christian Reichlin

hi,

if you are working on a classic raycasting engine like wolfenstein3d or 
similar games used where you only have vertical walls there is a short 
tutorial on http://www.permadi.com/tutorial/raycast/ or one at 
http://student.kuleuven.be/~m0216922/CG/raycasting.html
they are both not in python or pygame but they explain how the textures 
are calculated.
in the end you simply have to draw a scaled one pixel column of a 
texture on every column of the screen. for this you can maybe use 
pygame.transform.chop and pygame.transform.scale but it might be to slow.
if you want to do it yourself you can use a modified bresenham 
algorithmus. http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
because you need only the y coordinates for vertical lines you can use 
the x coordinate for the position in the texture you draw.


chrigi

Julia schrieb:

Hi everyone!

I am currently working on a raycasting engine using pygame for 
graphics.  The

engine works great and now I'm thinking about adding support for textures.
The problem is that I'm not really sure to with modules and methods to 
use.

I need to be able to load textures, scale then to fit and then draw the
scaled image. Any tips on a smart way to do this? Good tutorial url's are
also appreciated :)

/ J




[pygame] Google summer of code, and pygame. Where Google pays students to work on pygame.

2008-03-06 Thread René Dudfield
Hello,

We've almost got pygame 1.8 released!  ya!   Once that's done, we'll
have to figure out what we want to do for the next release... but on
another note, there's this google summer of code thing coming up GSoC(
http://code.google.com/soc/2008/ ).  It's where google pays students
$4500 to work on open source projects for three months.

This year 'pygame' will be seeking to enter GSoC as a mentor
organisation.  Rather than going in with the Python Software
Foundation(PSF) like in a previous year.  This doesn't mean 'pygame'
will be a legal organisation or anything, the google SOC doesn't need
that.  We'll just be a rag-tag group of individuals acting as the
'pygame' organisation.  Going separately from PSF will allow us to
choose which projects are chosen for pygame, rather than allow the
general python organisation to choose which projects are allocated for
pygame.

Other organisations that might be related to pygame are:
- python
- SDL
- OLPC

So if 'pygame' isn't accepted as a mentoring organisation, we can try
to get some projects accepted under these organisations.  We can also
suggest projects for these organisations.  For example we might
suggest an SDL_webcam project for SDL, or a graphics types module for
python, etc.

So far Marcus, Phil Hassey, and I will be prepared to be mentors.
These are three active contributors to pygame.  Hopefully we'll have a
few more mentors too - if suitable people volunteer.  I'll be an
administrator, and Marcus is likely to be a backup administrator for
the 'pygame' organisation.  Perhaps we can get a few more backup
mentors, and/or backup administrators too.

I'm putting together the application for the organisation at the
moment, in consultation with the other mentors, and people on the
pygame mailing list.

'pygame' needs to figure out a few things:
1. some cool ideas for projects.   (we've started a list here
http://pygame.org/wiki/gsoc2008ideas )
2. where pygame wants to go next, and how google SOC can help us get there.
3. if anyone else wants to be a mentor, administrator, backup mentor,
or backup administrator.
4. if anyone want to become a student to figure out what
proposal/proposals you'll make.


Put your ideas for projects here:
http://pygame.org/wiki/gsoc2008ideas

Also please discuss your ideas for projects on the mailing list.


Here's the google Summer Of Code(SOC) page:
http://code.google.com/soc/2008/

How does a mentoring organization apply:
http://code.google.com/soc/2008/faqs.html#0.1_org_apply

mentoring organisations:
http://code.google.com/soc/2008/faqs.html#0.1_mentoring_orgs

deadlines:
http://code.google.com/soc/2008/faqs.html#0.1_timeline

Notes on student allocations:
http://groups.google.com/group/google-summer-of-code-announce/web/notes-on-student-allocations

Notes on organisation selection criteria:
http://groups.google.com/group/google-summer-of-code-announce/web/notes-on-organization-selection-criteria




cheers,


[pygame] pystreamer in pygame? NEW USER

2008-03-06 Thread Darren Enns

Hello folks -- newbie here.  Just joined the list. :)

I wrote my first 'PyGame' application and released it a few days ago 
(mostly of interest just to the Nokia internet tablet community, due to 
the 'side-ways' orientation of the display):


http://www.internettablettalk.com/forums/showthread.php?t=17569

I *wanted* to be able to use 'pystreamer' to play back 'video' in my 
pygame application, but I could find no hints/tips on Google on how to 
do so.  I am sure that it is possible, since someone on an IRC channel 
mentioned that he had succeeded in doing so.  I am hoping that now that 
I have joined this list, that one of you might point me in the right 
direction.  It is unfortunate that I have not been able to find any 
'recent' archives of this mailing list to use as a resource.


Dare


Re: [pygame] Texture for raycasting engine

2008-03-06 Thread Ian Mallett
Ray-tracing or ray-casting is really only useful if you want to make
complex effect like shadows and multiple reflections, like
http://www.openrt.de/Gallery/2002_DynamicRayTracing/Images/teas_kitchen1.jpg.
 If you're just looking for something 3D, use OpenGL.  OpenGL is
faster, and has easy support for textures.  It is also pretty simple
to use.


Re: [pygame] Texture for raycasting engine

2008-03-06 Thread Julia
Kschnee: I've also been using Lode and I also had a fisheye problem. But I
solved it with an extra pair of (). Try it out. If I can solve it – so can
you. Trust me about that one ;)

On Thu, Mar 6, 2008 at 6:26 PM, kschnee [EMAIL PROTECTED] wrote:

 http://www.permadi.com/tutorial/raycast/
 http://student.kuleuven.be/~m0216922/CG/raycasting.html

 Here are two tutorials on the subject. I tried making one of these (no
 textures), but never did fix the fisheye distortion problem. My version
 was
 also impractically slow. It looks like it's helpful to use matrix-based
 math.




Re: [pygame] Texture for raycasting engine

2008-03-06 Thread Dave LeCompte (really)
Ian Mallett [EMAIL PROTECTED] wrote:
 Ray-tracing or ray-casting is really only useful if you want to make
 complex effect like shadows and multiple reflections

Don't confuse ray tracing with ray casting. Doom and Wolfenstein 3d made
good use of ray casting without any reflections.

I certainly wouldn't try to write a software rasterizer in Python if I
were trying to attain interactive speeds, but I don't presume to know what
application the original poster has in mind.

-Dave LeCompte






Re: [pygame] Texture for raycasting engine

2008-03-06 Thread Julia
Thank you for your answers and I'm sorry for the lack of clarity. I've been
working on the project so long I didn't think about the fact that the whole
thing wasn't as clear to you as it was to me.

What I am working on is basically a Wolfenstein 3d type of game. So my
raycasting engine is more of a 2.5d engine. Despite my somewhat limited
trigonometric skills the game acutely works and now I'm trying to get
textures for the game. (And yes, will use using the original Wolf textures ;
)

From Wikipedia: In order to draw the world, a single ray is traced for every
column of screen pixels http://en.wikipedia.org/wiki/Pixel and a vertical
slice of wall texture http://en.wikipedia.org/wiki/Texture_mapping is
selected and scaled according to where in the world the ray hits a wall and
how far it travels before doing so.

My problem is I'm not really sure where to start if I'm going to do this
with images in pygame. So far I've only needed to used pygame.draw.line() so
right now I'm rather lost.

Julia

On Thu, Mar 6, 2008 at 6:32 PM, Christian Reichlin [EMAIL PROTECTED]
wrote:

 hi,

 if you are working on a classic raycasting engine like wolfenstein3d or
 similar games used where you only have vertical walls there is a short
 tutorial on http://www.permadi.com/tutorial/raycast/ or one at
 http://student.kuleuven.be/~m0216922/CG/raycasting.html
 they are both not in python or pygame but they explain how the textures
 are calculated.
 in the end you simply have to draw a scaled one pixel column of a
 texture on every column of the screen. for this you can maybe use
 pygame.transform.chop and pygame.transform.scale but it might be to slow.
 if you want to do it yourself you can use a modified bresenham
 algorithmus. http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
 because you need only the y coordinates for vertical lines you can use
 the x coordinate for the position in the texture you draw.

 chrigi

 Julia schrieb:
  Hi everyone!
 
  I am currently working on a raycasting engine using pygame for
  graphics.  The
  engine works great and now I'm thinking about adding support for
 textures.
  The problem is that I'm not really sure to with modules and methods to
  use.
  I need to be able to load textures, scale then to fit and then draw the
  scaled image. Any tips on a smart way to do this? Good tutorial url's
 are
  also appreciated :)
 
  / J




Re: [pygame] Texture for raycasting engine

2008-03-06 Thread kschnee
On Thu, 6 Mar 2008 09:59:10 -0800, Ian Mallett [EMAIL PROTECTED]
wrote:
  If you're just looking for something 3D, use OpenGL.  OpenGL is
 faster, and has easy support for textures.  It is also pretty simple
 to use.

And if you're trying to fly into space, use a space shuttle -- it's pretty
simple to use. 8)



Re: [pygame] Texture for raycasting engine

2008-03-06 Thread kschnee
On Thu, 6 Mar 2008 18:42:25 +0100, Julia [EMAIL PROTECTED] wrote:
 My problem is I'm not really sure where to start if I'm going to do this
 with images in pygame. So far I've only needed to used pygame.draw.line()
 so
 right now I'm rather lost.

This probably isn't the fastest way, but you could blit the desired portion
of the source image just by passing an extra parameter to the blit
function. Where h is the texture's height, texture_x the desired vertical
strip of it to draw, and (x,y) the desired screen position:

screen.blit(texture,(x,y),(texture_x,0,1,h))

That would blit a one-pixel-wide stripe of texture. To calculate which
stripe to use, apparently you should find how far along the wall the ray
hits, the easiest way being to divide the world into a grid like Wolf3D,
and if it's 25% away from the left edge, set texture_x to the texture's
width * .25.



Re: [pygame] get_wm_info on linux

2008-03-06 Thread Greg Ewing

Patrick Mullen wrote:

ogre is expecting a string like this: display
*:screenid,windowid, and I'm not sure how you would put a display *
as a string.


What *exactly* does the piece of documentation you're
looking at say? That doesn't seem to make any sense.

--
Greg


Re: [pygame] your game in the messenger

2008-03-06 Thread Luke Paireepinart

Michael Schmidt wrote:
We'd love to include some games as a networked game in 
http://retroshare.sf.net Instant Messenger V.04
Actually some python games are one of my favourite games.. so I adress 
to our list.

[snip]
So the proposal for integrating is:

(1) Retroshare provides all the networking, transport etc
and provides a simple C or C++ API for your python game to 
communicate with.

[snip]

Is this approach acceptable to you? Someone interested to see his game 
in the Instant Messenger launchable?

Sure, that sounds pretty awesome!
It'd be best if you could make a ctypes wrapper for the C API so that 
the python-only people can use your system too.


Re: [pygame] Creating unique userevent ids?

2008-03-06 Thread Gary Bishop

Hi Rene,

You can find the rapidly changing current version of the code in CVS at 
http://uncpythontools.cvs.sourceforge.net/uncpythontools/CV/ under 
pygame_cam.py. You'll need CVtypes of course. It appears to work for me 
on Ubuntu, Windows, and Mac OS X.


I've just hacked together an object for the pgu gui kit. If that 
interests you I can create another project for it in CVS.


I'm working as hard as I can to get stuff ready for a trip to Asheville 
week after next so I don't have much time to discuss it now but I'd be 
very pleased to talk to anyone interested about how best to provide such 
capabilities to the pygame community.


gb

René Dudfield wrote:

hi,

that's probably a good idea :)

The upcomming SDL 1.3 has a new method for doing better user events...
until then, it's probably good to do something like Ian suggests -
except maybe start way higher.  Perhaps have some functions for
getting events?  That way your code would be more abstracted for
working with later changes.  eg.  FRAME_READY =
webcam.get_event(FRAME_READY) etc.


ps. do you have a url for your code repository?  I've also been
thinking about starting a webcam module probably based of VidCapture,
and opencv.  I think webcam support would be good for the next release
of pygame, that is version 1.9.  Same with wiimote support.

I think if we include new code with pygame that requires new events,
we would increment USEREVENT, and hopefully that won't break much user
code.

That could be another approach that you take, increment USEREVENT
yourself at init time, and require your init code before USEREVENT
usage.


On Tue, Feb 26, 2008 at 7:40 AM, Ian Mallett [EMAIL PROTECTED] wrote:

I really have no idea what I'm talking about.  :)
If I have separate modules that must use the same set of integers to do
something, (like my solution for wxPython menu bindings), I go like this:
module number + number
  1+1   = 11
  2+52 = 252
  1+31 = 131
...and so on.  This ensures that the bandwidth for each module remains
reserved.  All of the numbers beginning in 1 belong to module 1, like 11,
110, and 1100, all the ones to 2 begin with 2, like 21, 210, and 2100.  You
could add this value to pygame.USEREVENT for each submodule.

I've never used pygame.USEREVENT, so I have no idea what I'm talking about.
This might totally work, or be completely in the wrong direction.  I
apologise in the case of the latter. :)
HTH
Ian
--
There are 10 kinds of people;
those who understand binary and those who don't.
Without order nothing can exist - without chaos nothing can evolve.


Re: [pygame] Google summer of code, and pygame. Where Google pays students to work on pygame.

2008-03-06 Thread Luke Paireepinart

René Dudfield wrote:

Hello,

We've almost got pygame 1.8 released!  ya!   Once that's done, we'll
have to figure out what we want to do for the next release... but on
another note, there's this google summer of code thing coming up GSoC(
http://code.google.com/soc/2008/ ).  It's where google pays students
$4500 to work on open source projects for three months.

This is pretty exciting, Rene!
I'm a student currently, and I'm planning on doing a Summer of Code 
project.  I'll apply for a Pygame one if you guys get accepted.

Thanks for letting us know,
-Luke


Re: [pygame] Texture for raycasting engine

2008-03-06 Thread Greg Ewing

Julia wrote:

Hi everyone!

I am currently working on a raycasting engine using pygame for graphics. 


I need to be able to load textures, scale then to fit and then draw the
scaled image.


It sounds like you really ought to be using OpenGL for this.
There are no functions built into PyGame that will render
a perspective projection of an image, and doing it in
Python would be hopelessly slow.

--
Greg


[pygame] CD Burning Of Games?

2008-03-06 Thread FT


Was there ever a project to write CD/DVD Burning programs to save games?

Bruce



Re: [pygame] CD Burning Of Games?

2008-03-06 Thread Ian Mallett
This does audio in pygame programs:http://www.pygame.org/docs/ref/cdrom.html

If you just want to distribute, can just burn programs onto a cd.

I assume you mean having your program make cds, though?


Re: [pygame] get_wm_info on linux

2008-03-06 Thread Patrick Mullen
Well here's the documentation for ogre:


RenderWindow * createRenderWindow (const String name, unsigned int
width, unsigned int height, bool fullScreen, const NameValuePairList
*miscParams=0)
...
miscParams  A NameValuePairList describing the other parameters for
the new rendering window. Options are case sensitive. Unrecognised
parameters will be ignored silently. These values might be platform
dependent, but these are present for all platorms unless indicated
otherwise:
...
Key: externalWindowHandle [API specific] Description: External
window handle, for embedding the OGRE context Values: positive integer
for W32 (HWND handle) poslong:posint:poslong
(display*:screen:windowHandle) or poslong:posint:poslong:poslong
(display*:screen:windowHandle:XVisualInfo*) for GLX Default: 0 (None)

NameValuePairList only accepts strings.

It works on windows just fine as such:
set[externalWindowHandle] = str(info[window])

But yeah, the glx portion doesn't really make any sense to me.

I guess this is more a python-ogre/ogre issue than a pygame issue though.


Re: [pygame] get_wm_info on linux

2008-03-06 Thread Greg Ewing

Patrick Mullen wrote:

Values: positive integer
for W32 (HWND handle) poslong:posint:poslong
(display*:screen:windowHandle) or poslong:posint:poslong:poslong
(display*:screen:windowHandle:XVisualInfo*) for GLX Default: 0 (None)


I don't think these are strings, I think they're meant to
be some kind of array of values. Certainly 'display*'
and 'XVisualInfo*' are pointers to C data structures.

--
Greg Ewing, Computer Science Dept, +--+
University of Canterbury,  | Carpe post meridiem! |
Christchurch, New Zealand  | (I'm not a morning person.)  |
[EMAIL PROTECTED]  +--+


[pygame] Pixel Ships: Rotation

2008-03-06 Thread Kris Schnee

Here's a bit of code that turns one animation frame into a strip
containing rotated versions of that frame. It uses the pixel ships
code I posted recently and demonstrates a ship rotating. (Hit Escape to 
quit.) Rotations of 10 or 22.5 degrees seem to give smooth-looking rotation.


A friend is interested in getting a single-player PC version of the game 
Binary Homeworlds, made for the Icehouse system. (Anyone interested?) 
I could also imagine these rotating ships being used for something 
inspired by Sinistar, Starfox, The Ur-Quan Masters, Zone 66, or 
Gate 88.


import random
import pygame
from pygame.locals import *
import pixel_ships
SCREEN_SIZE = (1024,480)
screen = pygame.display.set_mode(SCREEN_SIZE)

def MakeSpriteFromFrame(frame,angle_per_frame=45):
## Make the frames, meanwhile determining which is biggest.
frames = 360 / angle_per_frame
max_size = 0
frameset = []
for n in range(frames):
img = pygame.transform.rotate(frame,n*angle_per_frame)
size = img.get_size()
if size  max_size:
max_size = size[0]
frameset.append(img)

## Now combine those into one image strip.
sprite = pygame.surface.Surface((max_size*frames,max_size))
for n in range(len(frameset)):
size = frameset[n].get_size()[0]
##if size  max_size:
##x = (n*max_size) + (max_size-size)/2
##y = (max_size-size)/2
##else:
##x = n*max_size
##y = 0

x = (n*max_size) + (max_size-size)/2
y = (max_size-size)/2

sprite.blit(frameset[n],(x,y))
return sprite, max_size, frames

s = pixel_ships.MakeShip(pixel_ships.BASE)
s = pygame.transform.scale2x(s)
s = pygame.transform.scale2x(s)

angle = 10 ## Try 45, 22.5 or 2 also. 1 makes Pygame crash for me -- big sprite.
ship_sprite, frame_size, frames = MakeSpriteFromFrame(s,angle)

screen.fill((0,0,150))
screen.blit(ship_sprite,(0,50))

clock = pygame.time.Clock()
frame = 0
done = False
while not done:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
done = True

screen.fill((0,0,0))

screen.blit(ship_sprite,(100,100),(frame*frame_size,0,frame_size,frame_size))
pygame.display.update()

frame += 1
if frame == frames:
frame = 0

clock.tick(20)



Re: [pygame] CD Burning Of Games?

2008-03-06 Thread FT

Thanks, I want to make copies that are not on a hard drive to have a backup 
storage. Give it to some friends getting into programming, and family...

Bruce


This does audio in pygame programs:
http://www.pygame.org/docs/ref/cdrom.html



If you just want to distribute, can just burn programs onto a cd.  


I assume you mean having your program make cds, though?






Re: [pygame] get_wm_info on linux

2008-03-06 Thread Patrick Mullen
Well, I managed to get it to work by hacking pygame src/display.c :)
It is actually a string it is looking for, and I'm not totally sure
how the conversion works (not totally clear on what a void * really is
etc), but here is my addition to display.c that made the value usable:

get_wm_info (PyObject_* self )
{
//In the glx section

tmp = PyInt_FromLong (info.info.x11.display);
PyDict_SetItemString (dict, a_of_display, tmp);
Py_DECREF (tmp);

}

So now the info dictionary has a new value, a_of_display which I
assume is some kind of address.

In my python-ogre code, I call it like so:

self.screen = pygame.display.set_mode([opts[width],opts[height]])
settings = ogre.NameValuePairList()
inf = pygame.display.get_wm_info()
d1 = inf['a_of_display']
w2 = inf['window']
settings[parentWindowHandle]=str(d1)+:0:+str(w2)
self.renderWindow = self.root.createRenderWindow(
   name,opts[width],opts[height],opts[fs],settings)

Surprisingly it works.  It seems like it should be possible to get the
long from the PyCObject (info['display']) just as well as it was done
from the c code (PyInt_FromLong) but what do I know.  At least I have
it working.  Thanks for pointing out that file Rene.


Re: [pygame] CD Burning Of Games?

2008-03-06 Thread Ian Mallett
Well, that wouldn't have to be done by PyGame or Python.  It sounded like
that's what you wanted...

OK, to back up files to a cd, you must first make sure that your cd drive*can
*burn cds--some can only read.  If you can write, you can just open the
window: My Computer - Removeable Drive D (or whatever).  You can then just
drag and drop files.  Then, on Vista, there is a little burn button which
you press.  If you don't have Vista, you should be able to figure it out
from there.

HTH,
Ian


Re: [SPAM: 3.000] Re: [pygame] get_wm_info on linux

2008-03-06 Thread Greg Ewing

Patrick Mullen wrote:

Well, I managed to get it to work by hacking pygame src/display.c :)
It is actually a string it is looking for, and I'm not totally sure
how the conversion works


Looks like it's treating the memory address as an integer and
turning it into a decimal string.


It seems like it should be possible to get the
long from the PyCObject (info['display']) just as well
as it was done from the c code


PyCObjects are opaque from Python code -- there's no way
to extract an address from one without using C code.

--
Greg