Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.079 X-Spam-Evidence: '*H*': 0.85; '*S*': 0.01; 'variables': 0.07; 'integers': 0.09; 'pixels': 0.09; 'screen.': 0.09; 'variables.': 0.09; 'cc:addr:python-list': 0.11; 'posted': 0.15; '*never*': 0.16; 'pygame': 0.16; 'subject:Two': 0.16; 'wrote:': 0.18; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'rid': 0.24; 'sorry,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'received:209.85.217': 0.29; 'thus': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'about.': 0.31; 'agree': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'representing': 0.36; 'should': 0.36; 'two': 0.37; 'received:209': 0.37; '8bit%:4': 0.38; 'sure': 0.39; 'ian': 0.60; 'worry': 0.60; 'times': 0.62; "you'll": 0.62; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'default': 0.69; 'agreement.': 0.91; 'careful': 0.91; 'notion': 0.91; 'suspicious': 0.91; '\xa0there': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=qMnJ92WnFoZ54K03IHJdy36B0KopAksEaWWaLIlnRw0=; b=uIyVaeTFYv/QdaWuQUaHz/HeJeJyYEfKVFg5FJR0hFGrgCCa+izVjaSprbH7sO3AIk ydRnIY3u6t663rw0TQ4j5X2AoVswDr9IPA3RSfe77922Wn9fUr3MXukm/pEqmyxJP6bc Jsk9VsS5XT4/4VkQkxDgNRb2eedgedNahnBuQsSK/iID3qEPVvxQc5p2br4wWAF5+Nqt BubbmePKcLEdLxM1cmACB15znikuhI8ApUgJu8y7LItLCQhC2Jqkmz6VBS18UgANocC2 jBaLCd0Uzx8eaNqDTSpq0ZXBT+vsLBWRPHEnuF028eFqlgmfOZCljhvdt4qwPxZzOpqt lxqQ== X-Received: by 10.112.89.104 with SMTP id bn8mr7798834lbb.92.1367858374703; Mon, 06 May 2013 09:39:34 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <9083ecbc-5666-41aa-aacb-3f08f062feed@googlegroups.com> From: Joshua Landau Date: Mon, 6 May 2013 17:38:54 +0100 Subject: Re: Collision of Two Rect To: Ian Kelly Content-Type: multipart/alternative; boundary=001a11c36b4287032504dc0f5810 Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367858382 news.xs4all.nl 15899 [2001:888:2000:d::a6]:46451 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44837 --001a11c36b4287032504dc0f5810 Content-Type: text/plain; charset=ISO-8859-1 On 4 May 2013 00:42, Ian Kelly wrote: > The other thing that is suspicious about the code you posted is that > it has two different notions of the ball's position that are not > necessarily in agreement. There is the ball_rect, and there are also > the x and y variables. > You should be careful to make sure these > variables agree at all times -- or better yet, get rid of x and y > entirely, so that you only have one notion of the ball's position to > worry about. Pygame uses integers for its Rects and thus I advise much the opposite: *never* store position in Rects. Sorry, but it's true. You'll need to keep x and y around and try to use Rects only when representing pixels on the screen. Pygame has a lot of deficiencies with its default set of objects and functions, so it's something to get used to. --001a11c36b4287032504dc0f5810 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On 4 May 2013 00:42, Ian Kelly <ian.g.kelly@gmail.com= > wrote:
The other thing that is suspicious about the code you posted is that
it has two different notions of the ball's position that are not
necessarily in agreement. =A0There is the ball_rect, and there are also
the x and y variables.
<snip>=A0
You should be careful to make sure these
variables agree at all times -- or better yet, get rid of x and y
entirely, so that you only have one notion of the ball's position to worry about.

Pygame uses integers for its R= ects and thus I advise much the opposite: *never* store position in Rects.<= /div>

Sorry, but it's true. You'll need to keep = x and y around and try to use Rects only when representing pixels on the sc= reen. Pygame has a lot of deficiencies with its default set of objects and = functions, so it's something to get used to.
--001a11c36b4287032504dc0f5810--