Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44848
| References | <9083ecbc-5666-41aa-aacb-3f08f062feed@googlegroups.com> <CALwzidnwKpy-gN9LE3JkgwKOFD8M3hvySDL_x9ter6Hi2ptOQQ@mail.gmail.com> <CAN1F8qWTM=Oh9VqkApUFNZ5x9bwX149r_kPGhuoPY+Y21+z_+w@mail.gmail.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2013-05-06 14:18 -0600 |
| Subject | Re: Collision of Two Rect |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1383.1367871542.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On May 6, 2013 10:39 AM, "Joshua Landau" <joshua.landau.ws@gmail.com> wrote: > > 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. There is the ball_rect, and there are also >> the x and y variables. > > <snip> >> >> 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. You don't need subpixel positioning for many games -- arguably including Pong, although I suppose the argument would be stronger if the OP were not using a ludicrously high frame rate of 200 fps, which is going to limit the number of reasonable integer velocities available. For games where logical coordinates and screen coordinates need to be separated though, I agree.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Collision of Two Rect Alex Gardner <agardner210@gmail.com> - 2013-05-03 15:23 -0700 Re: Collision of Two Rect Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-03 17:42 -0600 Re: Collision of Two Rect MRAB <python@mrabarnett.plus.com> - 2013-05-04 01:51 +0100 Re: Collision of Two Rect Tim Roberts <timr@probo.com> - 2013-05-04 22:28 -0700 Re: Collision of Two Rect Joshua Landau <joshua.landau.ws@gmail.com> - 2013-05-06 17:38 +0100 Re: Collision of Two Rect Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-06 14:18 -0600
csiph-web