Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40397

Re: Pygame mouse cursor load/unload

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <agardner210@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'position,': 0.04; 'mouse': 0.07; 'stops': 0.07; 'python': 0.09; '(0,': 0.09; 'cursor': 0.09; 'moving.': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; "wouldn't": 0.11; 'file,': 0.15; 'sat,': 0.15; '6:56': 0.16; 'docstring': 0.16; 'ian.': 0.16; 'invisible': 0.16; 'observations': 0.16; 'pygame': 0.16; 'subject:Pygame': 0.16; 'true:': 0.16; 'wrote:': 0.17; 'alex': 0.17; 'module': 0.19; 'clock': 0.22; 'finally,': 0.22; 'cc:2**0': 0.23; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'appear': 0.26; 'instead.': 0.27; 'library.': 0.27; 'subject:/': 0.28; 'cpu': 0.29; 'loop,': 0.29; 'second,': 0.29; 'sleep': 0.29; 'thus,': 0.29; 'probably': 0.29; 'this.': 0.29; "i'm": 0.29; 'position.': 0.30; 'code': 0.31; 'problem.': 0.32; 'generally': 0.32; 'idle': 0.33; 'turns': 0.33; 'problem': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'screen': 0.34; 'replaced': 0.35; 'doing': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'next': 0.35; 'explain': 0.36; 'anything': 0.36; 'thank': 0.36; 'skip:p 20': 0.36; 'enough': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'instead': 0.39; 'help': 0.40; 'end': 0.40; 'think': 0.40; 'your': 0.60; 'first': 0.61; 'times': 0.63; 'more': 0.63; 'making': 0.64; 'here': 0.65; 'learned': 0.65; 'useful.': 0.65; 'soon': 0.70; '2013': 0.84; 'much,': 0.84; 'replacements': 0.84; 'draws': 0.91
X-Received by 10.49.24.164 with SMTP id v4mr1688072qef.6.1362282720480; Sat, 02 Mar 2013 19:52:00 -0800 (PST)
Newsgroups comp.lang.python
Date Sat, 2 Mar 2013 19:52:00 -0800 (PST)
In-Reply-To <mailman.2809.1362280147.2939.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=108.95.20.220; posting-account=kGHztQoAAABWYt08oBIrT5-Wm777e-qb
References <d6374016-8863-4e8b-9ec9-17a826ca2eee@googlegroups.com> <mailman.2809.1362280147.2939.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 108.95.20.220
MIME-Version 1.0
Subject Re: Pygame mouse cursor load/unload
From Alex Gardner <agardner210@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc Python <python-list@python.org>
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>
Message-ID <mailman.2813.1362282722.2939.python-list@python.org> (permalink)
Lines 97
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362282722 news.xs4all.nl 6930 [2001:888:2000:d::a6]:55567
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40397

Show key headers only | View raw


On Saturday, March 2, 2013 9:08:18 PM UTC-6, Ian wrote:
> On Sat, Mar 2, 2013 at 6:56 PM, Alex Gardner <agardner210@gmail.com> wrote:
> 
> > I am in the process of making a pong game in python using the pygame library.  My current problem is that when I move the mouse, it turns off as soon as the mouse stops moving.  The way I am doing this is by making the default cursor invisible and using .png files as replacements for the cursor.  Perhaps my code would best explain my problem.  I will take help in any way that I can.  Here are the links that contain my code:
> 
> 
> 
> Your mouse motion code draws the paddle in the new position, waits
> 
> 1/10th of a second, and then draws over it again with the "invisible"
> 
> paddle.  Thus, approximately 1/10th of a second after you stop moving
> 
> the mouse, it disappears.
> 
> 
> 
> Mouse motion events are probably not the best way to do this.  You can
> 
> instead just capture the current position of the mouse on every frame
> 
> and use that instead.  I replaced your main loop with the following:
> 
> 
> 
> paddle_pos = (0, 0)
> 
> clock = pygame.time.Clock()
> 
> 
> 
> while True:
> 
>     for event in pygame.event.get():
> 
>         if event.type == QUIT:
> 
>             sys.exit()
> 
> 
> 
>     # Erase the paddle from the old mouse position.
> 
>     screen.blit(bpaddle, paddle_pos)
> 
>     # Redraw the net before the paddle so that the paddle can appear over it.
> 
>     pygame.draw.line(screen, game.lineColor, game.net1, game.net2,
> 
>                      game.netWidth)
> 
>     # Get the new mouse position.
> 
>     paddle_pos = pygame.mouse.get_pos()
> 
>     # Draw the paddle at the new mouse position.
> 
>     screen.blit(beeper, paddle_pos)
> 
>     # Update the screen if it's double-buffered.
> 
>     pygame.display.update()
> 
>     # Finally, let the CPU idle until it's time for the next frame.
> 
>     # 50 here means that it will sleep long enough to achieve 50 FPS.
> 
>     clock.tick(50)
> 
> 
> 
> And I think you will find that this does what you want.
> 
> 
> 
> A couple more observations while I'm at it.  Generally there is no
> 
> need to be calling pygame.display.update() multiple times per frame.
> 
> Just draw everything that you need, and then call it once at the end
> 
> of the loop, as I have shown above.  Also, the shebang line only does
> 
> anything if it's the very first line in the file, so it would need to
> 
> appear before the module docstring to do anything useful.

Thank you very much, Ian.  I understand the code and have learned from it.  If I were more knowledgeable in python I wouldn't have had to ask; I am learning as I go with this project.  Again, thank you :)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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