Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40430
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.069 |
| X-Spam-Evidence | '*H*': 0.86; '*S*': 0.00; 'block.': 0.09; 'logic': 0.09; 'entirely.': 0.16; 'pygame': 0.16; 'range,': 0.16; 'subject:Pygame': 0.16; 'wrote:': 0.17; 'alex': 0.17; 'skip:p 30': 0.20; 'header:In-Reply-To:1': 0.25; 'updating': 0.27; 'replace': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:/': 0.28; 'falls': 0.29; 'class': 0.29; 'code': 0.31; 'to:addr:python-list': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'problems': 0.36; 'skip:p 20': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'your': 0.60; 'range': 0.60; 'you.': 0.61; 'solve': 0.62; '2013': 0.84; 'to:name:python': 0.84; 'updated,': 0.84 |
| 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:content-type; bh=RmouYfSrTwGrrNTT3Vp6Tj/Y+JHCwtMcTpEKLEZ1FQg=; b=C2NV/02QKscWZ2cwdlFGcggnPxhs7Gk43nExWS38NDZknb8/AyBE+YmFSkNS5zXR+o eDJjQ7LCBBmdLDCZ4lqfNqmAF5LgGjyySAqTTbVOUyDBeCS8tuTzmg/K2CIl1+FPv9ER /NO9JJb2vfpUhM7hbATBySKWvpxIrwytGGU4HG6ZUgyrcYOyKyFqt1fE96XCbESLm3di F9Owg4A/2yC5ZSM8a/K56YG7yzY21VY+mNlpuZu8zZ41b3zv3FSQFCuyX9sz1hQ6dUzG EgGrqS7rJuiyXtsyGAwV1ra9jPxggfYa9ywIZkj1l93wmVlO3uDTfGyvdaEs0Ak46da2 wjVA== |
| X-Received | by 10.52.177.163 with SMTP id cr3mr6084369vdc.94.1362354468556; Sun, 03 Mar 2013 15:47:48 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <9c352284-08c4-439e-b324-caffa3718429@googlegroups.com> |
| References | <d6374016-8863-4e8b-9ec9-17a826ca2eee@googlegroups.com> <9c352284-08c4-439e-b324-caffa3718429@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Sun, 3 Mar 2013 16:47:08 -0700 |
| Subject | Re: Pygame mouse cursor load/unload |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2828.1362354471.2939.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362354471 news.xs4all.nl 6867 [2001:888:2000:d::a6]:37735 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40430 |
Show key headers only | View raw
On Sun, Mar 3, 2013 at 3:09 PM, Alex Gardner <agardner210@gmail.com> wrote: > if (0,0) <= paddle_pos <= (300,300): This doesn't do what you think it does. Tuples are compared lexicographically, not element-wise. So (250, 350) < (300, 300), but (350, 250) > (300, 300). > paddle_pos = pygame.mouse.get_pos() > screen.blit(beeper, paddle_pos) > pygame.display.update() > clock.tick(50) You're updating paddle_pos inside the if block. Once paddle_pos falls outside that range, the if block won't trigger, and paddle_pos will no longer be updated, so it will never fall inside that range again. pygame has a Rect class for rectangle logic that can solve both of these problems for you. Given: paddle_rect = beeper.get_rect() bounds_rect = pygame.Rect(0, 0, 300, 300) your position update code then becomes: paddle_rect.center = pygame.mouse.get_pos() paddle_rect.clamp_ip(bounds_rect) Note that paddle_rect can replace paddle_pos entirely. The code: screen.blit(beeper, paddle_pos) simply becomes: screen.blit(beeper, paddle_rect)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-02 17:56 -0800
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-02 20:08 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-02 19:52 -0800
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-02 19:52 -0800
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-03 14:04 -0800
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-03 14:09 -0800
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-03 16:47 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-09 16:20 -0800
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-09 16:25 -0800
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-10 13:23 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-10 15:25 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-10 19:26 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 09:57 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 10:00 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 10:04 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-11 11:24 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 10:33 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-11 12:01 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 13:43 -0700
Re: Pygame mouse cursor load/unload MRAB <python@mrabarnett.plus.com> - 2013-03-11 20:54 +0000
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-11 15:23 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-12 16:33 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-12 21:00 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-14 15:16 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-14 16:31 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-14 15:56 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-18 13:24 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-18 16:05 -0700
csiph-web