Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'syntax': 0.03; 'error:': 0.05; 'that?': 0.05; 'things.': 0.05; 'append': 0.07; 'etc.),': 0.09; 'separately': 0.09; '"for"': 0.16; 'clears': 0.16; 'entirely.': 0.16; 'equal.': 0.16; 'pygame': 0.16; 'subject:Pygame': 0.16; 'task.': 0.16; 'true:': 0.16; 'later': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'alex': 0.17; 'drawing': 0.17; 'replacing': 0.17; 'appears': 0.18; 'code,': 0.18; 'code.': 0.20; 'trying': 0.21; 'do.': 0.21; 'clock': 0.22; 'logical': 0.22; 'parse': 0.22; 'example': 0.23; 'split': 0.23; 'statement': 0.23; 'this:': 0.23; 'idea': 0.24; 'pass': 0.25; 'tried': 0.25; 'header :In-Reply-To:1': 0.25; '(e.g.': 0.27; 'separate': 0.27; 'message- id:@mail.gmail.com': 0.27; 'lines': 0.28; 'subject:/': 0.28; 'all.': 0.28; 'fine': 0.28; 'ball': 0.29; 'indentation': 0.29; 'piece': 0.29; 'spaces': 0.29; 'checks': 0.30; 'function': 0.30; 'checked': 0.30; 'code': 0.31; 'implement': 0.32; 'skip:s 30': 0.33; '11,': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; 'operations': 0.33; 'received:google.com': 0.34; 'done': 0.34; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'add': 0.36; 'but': 0.36; 'flow': 0.36; 'level.': 0.36; 'useful': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'display': 0.36; 'does': 0.37; 'level': 0.37; 'two': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'step': 0.39; 'skip:" 10': 0.40; 'help': 0.40; 'think': 0.40; 'your': 0.60; 'skip:u 10': 0.60; "you've": 0.61; 'first': 0.61; 'back': 0.62; 'provide': 0.62; 'more': 0.63; 'gone': 0.64; 'overall': 0.66; 'talking': 0.66; '2013': 0.84; 'about,': 0.84; 'ball,': 0.84; 'discrete': 0.84; 'moves': 0.84; 'presumably': 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; bh=nOK9t3vKP3H4bCxps630bWUwrnKrEI5qB9ZOwzr59k8=; b=KQVzboC7zzu3E0KjxmygFFAyeKR2oB3kcEBYiHp82cPDKx/StcISfXO3x3fCNxzO7Z hAf2gGQk4Vyo0mXuoByT913Hd+8+K4DzcrWomHqhB8rHegbse1hAqIONeO1fnXrJiAcb uBMhPi0BQ5mHvWquy9DtsiZuD6tIC2IUA3Pns+5rwnXBAH3YIJkMWjCXQqmU5AGql4xA P9Pse4wQ2RLAy/TeaCjndJ1bTxwJ3gEftJhA100UBePr8NpYUo3kHHXx7ohECfP/NxIC r0C+NmfbaiCraYWxBx2/udcmFdn3hjp43K/3rFXNr92KhJ3W0osTAOh5gCvgG5aogzJJ 3lVA== X-Received: by 10.58.18.201 with SMTP id y9mr5714180ved.36.1363037039714; Mon, 11 Mar 2013 14:23:59 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Mon, 11 Mar 2013 15:23:19 -0600 Subject: Re: Pygame mouse cursor load/unload To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 64 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363037048 news.xs4all.nl 6925 [2001:888:2000:d::a6]:46691 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41093 On Mon, Mar 11, 2013 at 2:43 PM, Alex Gardner wrote: > I tried to append what you told me to. Now it appears that I have a syntax error! I checked my indentations and they look fine to me, but I get this error: > > paddle_pos = pygame.mouse.get_pos() > ^ > IndentationError: unindent does not match any outer indentation level The "for" statement and the statement quoted above should both be at the same indentation level. If you look at the code, the "for" statement is indented 7 spaces whereas the other statement is indented 4 spaces. You need to make them equal. > I added "paddle_rect.center = pygame.mouse.get_pos()" and removed the double blank paddles. I have no idea if it works though because of the parse error! New code: http://pastebin.com/maqWCdNB It won't. You've removed both the position-clamping code and the clock tick code entirely. Why did you do that? You've also gone from having two separate lines drawing bpaddle and one line drawing beeper, to having two separate lines drawing beeper, and not drawing bpaddle at all. I think that you need to step back from this and try to understand better the logical flow that you're trying to implement here. Once you understand what it is that you're trying to accomplish, then you can set it down in code. The overall flow should look like this: while True: Try to implement each of those things as a discrete unit, and think hard about what operations need to be done and in what order to accomplish each of those things. It might help you conceptually to split the first three off into separate functions that each do one specific piece of the above, and then implement each of those functions thinking only about what that particular function needs to do. To provide a concrete example of what I am talking about, consider replacing your main loop with this: state = SomeClassRepresentingTheGameState() while True: # checks for a QUIT event process_events(state) # moves the ball and paddles, updates scores, etc. update_game(state) # clears the old state from the display and draws the current state onto it draw_game(state) pygame.display.update() clock.tick(50) And then separately implement all three of those functions, thinking only about how each function needs to interact with the state and what pygame calls it needs to make in order to accomplish its specific task. Right now the state object would only contain your paddle_rect, but later you will presumably have more state to add (e.g. the players' scores, the position and velocity of the ball, etc.), so it will be useful then to have a single object you can pass around to contain those.