[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Patch for 'stars.py' and 'moveit.py' pygame examples
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Patch for 'stars.py' and 'moveit.py' pygame examples
- From: Rene Dudfield <renesd@xxxxxxxxx>
- Date: Sat, 16 Jul 2005 15:43:09 +1000
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Sat, 16 Jul 2005 01:43:23 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=W/H4nl60NIZUZT8oFfyegYLgL2bQ2fn648j8ZgKwFkEt1je4QPTPdtzPQ0kApn9pkpKzCoevIaWIhkP2u9D9LvBB/edJqiDVryHTraEv2PPtLbMnrWeFAEDTMGRsCvSdeHHXDU2EPYObCyNtr8C6xIqRu8lzoVB2RX1t6ksMPGo=
- In-reply-to: <20050716004610.GA22359@rosa.blake>
- References: <20050716004610.GA22359@rosa.blake>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Thanks!
Applied to cvs.
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.
>
>