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

Re: [pygame] Patch for 'stars.py' and 'moveit.py' pygame examples



Hey John,

I added your patch as is.

Cheer.


On 7/17/05, John Popplewell <john@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> On Sat, Jul 16, 2005 at 03:43:09PM +1000, Rene Dudfield wrote:
> > Thanks!
> >
> > Applied to cvs.
> >
> Rene,
> 
> thanks for applying.
> 
> I too, tried changing the star coordinates to integers, but this has a
> side-effect of restricting the possible trajectories of the stars. I get
> a harsh vertical and horizontal 'cross' in the stars distribution.
> 
> Using round() as you do might be useful, but keeping the accumulated
> position as a float (or fraction) is required.
> 
> Also, it looks more like the 'flying through space' screen-saver I
> assume it is mimicking *with* the frame-rate limiter. Without, it's just
> a fuzzy mess on my fastest machine.
> 
> But, it is only an example script, so I'll shut-up :-)
> 
> cheers,
> John.
> 
> 
> > On 7/16/05, John Popplewell <john@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> > > Hi,
> > >
> > > I was just trying PyGame 1.7.1 from CVS on my Linux laptop and came
> > > across a couple of bugs in the supplied example scripts. Here is a
> > > patch:
> > >
> > > Index: moveit.py
> > > ===================================================================
> > > RCS file: /home/cvspsrv/cvsroot/games/pygame/examples/moveit.py,v
> > > retrieving revision 1.2
> > > diff -c -r1.2 moveit.py
> > > *** moveit.py   5 Jan 2002 09:17:53 -0000       1.2
> > > --- moveit.py   2 Jul 2005 01:32:50 -0000
> > > ***************
> > > *** 40,45 ****
> > > --- 40,47 ----
> > >
> > >       player = load_image('player1.gif')
> > >       background = load_image('liquid.bmp')
> > > +     background = pygame.transform.scale2x(background)
> > > +     background = pygame.transform.scale2x(background)
> > >       screen.blit(background, (0, 0))
> > >
> > >       objects = []
> > >
> > > This patch scales the background image so that it fills the window and
> > > successfully overwrites the old sprite position. See the script
> > > 'liquid.py' for details. The image 'liquid.bmp' was 'shrunk' a while
> > > back, but 'moveit.py' wasn't updated.
> > >
> > >
> > > Index: stars.py
> > > ===================================================================
> > > RCS file: /home/cvspsrv/cvsroot/games/pygame/examples/stars.py,v
> > > retrieving revision 1.7
> > > diff -c -r1.7 stars.py
> > > *** stars.py    7 Jan 2002 17:09:59 -0000       1.7
> > > --- stars.py    2 Jul 2005 01:32:50 -0000
> > > ***************
> > > *** 42,47 ****
> > > --- 42,48 ----
> > >   def draw_stars(surface, stars, color):
> > >         "used to draw (and clear) the stars"
> > >         for vel, pos in stars:
> > > +               pos = (int(pos[0]), int(pos[1]))
> > >                 surface.set_at(pos, color)
> > >
> > >
> > > ***************
> > > *** 62,67 ****
> > > --- 63,69 ----
> > >         #create our starfield
> > >         random.seed()
> > >         stars = initialize_stars()
> > > +       clock = pygame.time.Clock()
> > >
> > >         #initialize and prepare screen
> > >         pygame.init()
> > > ***************
> > > *** 84,89 ****
> > > --- 86,92 ----
> > >                                 break
> > >                         elif e.type == MOUSEBUTTONDOWN and e.button == 1:
> > >                                 WINCENTER[:] = list(e.pos)
> > > +               clock.tick(50)
> > >
> > > I'm using Python 2.3.5 on Gentoo.
> > > This fixes a warning:
> > >
> > > stars.py:45: DeprecationWarning: integer argument expected, got float
> > >   surface.set_at(pos, color)
> > >
> > > generated for every star when it is drawn and erased and slows the
> > > program down tremendously! The warning subsystem suppresses all but the
> > > first warning, but they are still being generated.
> > >
> > > I added the frame-rate regulation clock to make it slow enough to see
> > > after the fix.
> > >
> > > Good luck with the new release,
> > >
> > > cheers,
> > > John Popplewell.
> > >
> > >
> >
>