Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'position,': 0.04; 'mouse': 0.07; 'stops': 0.07; 'python': 0.09; '(0,': 0.09; 'cursor': 0.09; 'moving.': 0.09; 'file,': 0.15; 'sat,': 0.15; '6:56': 0.16; 'docstring': 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; 'second': 0.24; 'header:In-Reply-To:1': 0.25; 'appear': 0.26; 'instead.': 0.27; 'library.': 0.27; 'message- id:@mail.gmail.com': 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; 'to:addr:python-list': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'screen': 0.34; 'replaced': 0.35; 'doing': 0.35; 'pm,': 0.35; 'there': 0.35; 'next': 0.35; 'explain': 0.36; 'received:74.125': 0.36; 'anything': 0.36; 'skip:p 20': 0.36; 'enough': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'instead': 0.39; 'to:addr:python.org': 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; 'useful.': 0.65; 'soon': 0.70; '2013': 0.84; 'replacements': 0.84; 'to:name:python': 0.84; 'draws': 0.91 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:content-transfer-encoding; bh=4nzYKV7eIQIm3mvP5t6F9c0wGuXuMFKzEKpoFC2RC7U=; b=q/Lchzjg52fJCOrdcyKOD/bYl4Qhm2zIpe82KyEUl3CKBu7T4dmvL8nfLyFIGBMGdV Ey+7WT7AAZYgAf+/KnlzeI/EQTcSnHxko9Wcs8fHL2uEScTZJgAVTTU1EE8/CwOAt+8+ Dv8lK3YfK1R9LUqEbjJIQx9aC8GXFtSsIav5Ye24ZjCPS9/4Gby/5x2jiRcMX6BCcpnQ imj6GvdGfOD2xOClTdiDFlUWAVhLKUzV6MiN6Xaa188X2HSgq02jjDFEGTeBO/9sDbIK ZB6ugH8ITW9TXW3pQqR0AxXu7hYry0p4CHmgwRz1wR2LhGSGqz1oc9/tHELMjUKT4kKd QufQ== X-Received: by 10.14.182.137 with SMTP id o9mr43603435eem.13.1362280139425; Sat, 02 Mar 2013 19:08:59 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Sat, 2 Mar 2013 20:08:18 -0700 Subject: Re: Pygame mouse cursor load/unload To: Python Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362280147 news.xs4all.nl 6893 [2001:888:2000:d::a6]:33653 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40390 On Sat, Mar 2, 2013 at 6:56 PM, Alex Gardner wrote: > I am in the process of making a pong game in python using the pygame libr= ary. My current problem is that when I move the mouse, it turns off as soo= n as the mouse stops moving. The way I am doing this is by making the defa= ult 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 =3D (0, 0) clock =3D pygame.time.Clock() while True: for event in pygame.event.get(): if event.type =3D=3D 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 i= t. pygame.draw.line(screen, game.lineColor, game.net1, game.net2, game.netWidth) # Get the new mouse position. paddle_pos =3D 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.