2 Jan 2004 01:44
4 Jan 2004 04:55
[pygame] draw.arc comment
Hi,
As you may have been able to tell, I've been working with draw.arc recently...
One problem that i have is that it has its 0 degree mark on the right hand side, 90 on the top, 180 on the left, and
270 on the bottom. This is problematic because as (0, 0) is the top left hand corner and the points increase
to the bottom corner, draw.arc is 90 degrees out of phase with any trig calculations one does - with zero on
the bottom, etc, viz:
=== BEGIN
import math
def get_sides(pt1, pt2):
x1, y1 = pt1
x2, y2 = pt2
return (x2 - x1), (y2 - y1) # opplen, adjlen
def pts_to_angle(pt1, pt2):
opplen, adjlen = get_sides(pt1, pt2)
angle = math.degrees(math.atan2(opplen, adjlen))
if angle < 0:
angle += 360
return angle
=== END
Of course draw.arc _can_ be wrapped - but any user who needs to do dynamic calculations will have to do so.
Whether or not it would be reasonable to change it at this stage is another matter (If indeed, it is agreed
that it is a problem).
(Continue reading)
4 Jan 2004 05:59
[pygame] Perspective distortion
Hello everyone, This may not be the right forum for asking this question, but since my project is mainly pygame based, I'll take a chance. ;) What I'd like to know is whether there is a Python module or example which will take a 2D bitmap and do a perspective tranformation so that it appears you are looking along its surface as in a 3D first person perspective game. I've had a look at pygame itself and there doesn't seem to be anything that goes that far. I realise that the simplest way of doing this is to use OpenGL and use the bitmap as a texture, but I'd like to avoid OpenGL if possible. Similarly, I know there are graphics packages that will do this operation, but it has to be done at run-time as the bitmap is dynamically generated. As you can see, I'm looking for a relatively low-tech solution. I could write the code to do this myself, but I'm a firm believer in not re-inventing the wheel. So the question is: does anyone know where such a wheel can be found, or have I got to add something else to my "to do" schedule. Thanks for your forebearance, Bill Hoggett
4 Jan 2004 07:51
Re: [pygame] Perspective distortion
> What I'd like to know is whether there is a Python module or example which > will take a 2D bitmap and do a perspective tranformation so that it appears > you are looking along its surface as in a 3D first person perspective game. > I've had a look at pygame itself and there doesn't seem to be anything that > goes that far. Haven't tried it myself but it might be useful info: http://freespace.virgin.net/hugo.elias/graphics/x_persp.htm That whole site is great. Alan
5 Jan 2004 11:04
[pygame] Right shift bug on Windows?
Hi, On my Windows computer, holding down the right shift key and pressing a key sends two KEYDOWN events: one with the pressed key and one with right shift as the key. The first one has right shift in mods, the second one doesn't. This doesn't happen with left shift, also this doesn't happen on my Linux computer and on another Windows computer I tested. Right shift works normally in other applications however... Anyone have any idea what could be wrong? -Jussi .............................................................. MTV3 Laajakaista - Hauskemman elämän puolesta. http://www.mtv3.fi/liittyma/hankinta/laajakaista/
7 Jan 2004 11:08
[pygame] free webserving..
http://1and1.com has free web site hosting, email, etc for three years if you sign up right now. No ads, no credit card asked for.. Maybe useful if anyone wants to create a nice site for their project? I've been playing with it for a week or so and like it.
7 Jan 2004 13:15
Re: [pygame] free webserving..
> http://1and1.com has free web site hosting, email, etc for three years > if you sign up right now. No ads, no credit card asked for.. Maybe > useful if anyone wants to create a nice site for their project? I've > been playing with it for a week or so and like it. > > It looks like it's only US and Canada, although there isn't really any way for them to check.
7 Jan 2004 13:25
Re: [pygame] free webserving..
>It looks like it's only US and Canada, although there isn't really any way >for them to check. > Oh, didn't even think of that problem. They do make you give them a phone number to verify your account with. A lil automated thing calls and gives you a pin number to activate your account with. Limit one account per phone number. I think it only works on 10 digit phone numbers so that might be a problem for you unless a friend in the US would let you have it call them.
8 Jan 2004 06:51
[pygame] optimization for my sprite rendering
I'm fairly new to both pygame and python, and I was wondering if someone could help a newbie optimize some
code I inherited.
Here's some background info: there are foreground sprites that pop up and go away, and there is an image
loaded into the background sprite that changes infrequently (not more than every 5 seconds). The problem
was, the old code updated the entire screen on every iteration, so I broke it apart and only the foreground
elements are updated unless the background image changes.
Yay, it's all fine, except that the framerate still sucks (85-120ms per iteration of the main loop). If I
take out the line in the foreground loop (below) where it draws the background sprite onto the mainscreen,
everything under the fg sprites ends up black (the surface self.background is all black - but... it takes
an acceptable 30ms to run the loop). I'd love to just update the areas where the foreground rects overlap
the background, but I don't know how (do I need to create a new sprite class?). I've tried something like:
bg_sprite.draw(self.background), but I get the same problem with the background not being redrawn properly.
Sorry for the verbose post (but it's late and I've been working on this for too long) and thanks for any help
you can give me in advance.
Chris
def update(self, fg_only=False):
"Update the screen"
if fg_only:
self.foregroundsprites.clear(self.mainscreen, self.background)
self.foregroundsprites.update()
self.backgroundsprites.draw(self.mainscreen)
changed_rects=self.foregroundsprites.draw(self.mainscreen)
else:
(Continue reading)
8 Jan 2004 07:32
Re: [pygame] optimization for my sprite rendering
solitare0@... wrote: > Sorry for the verbose post (but it's late and I've been working on this > for too long) and thanks for any help you can give me in advance. i'd start by using the RenderUpdates sprite group. This can do exactly what you want (i think) by clearing only the changed parts of the screen. You'll need to change your code so the background is not a sprite, but handled separately. the RenderUpdates class has a "clear()" method that takes a background. It will draw the background only underneath the sprites. The "draw()" method for RenderUpdates returns a list of rectangles representing all the areas onscreen that have changed. You can pass that list to pygame.display.update() for the fastest frame switch possible. When you do change you background image you will just need to draw the entire thing, and call pygame.display.update() to draw and update the entire screen. After that you can continue on normally.
RSS Feed