Re: [pygame] pygame standard mouse
Wahid Marditama wrote: Hi all, I find the standard mouse in pygame is slow when display is set to fullscreen. Anyway around this? Or, is there a good 'virtual' mouse code? I tried writing one but it does not work as expected. Wahid Yeah, I had that happen too. The way I fixed it was in my main loop, I throw away all mouse movements except one. This forces you to update the mouse once per loop, instead of many times per loop. DirectX appears to be feeding every XY transformation to the event loop, instead of 'most recent coordinates' as happens in windowed mode. For simplicity, I throw all away except the first one. If you wanted to be more accurate, you should probably throw away all except the LAST movement. That way you're always guaranteed of being up to date. --Kamilche
Re: [pygame] Adjusting Timing With a User Event
Kris Schnee wrote: How can I go about adjusting the speed of in-game events based on the current FPS? That is, my physics sim works in steps with a known time interval, but the _game_ might have varying FPS, and I want a thrown ball to move at a constant rate in real time regardless of how many animation frames/simulation steps happen. Right now I've got a Pygame "clock" in my main loop to regulate game speed to a max of 30 FPS. I just now added the line: self.time_interval = min(1.0 / clock.get_fps(),.3) Which should change the amount of time that a simulation step represents to be either the amount of real time since the last step, or .3 s, whichever is smaller. (Bad things happen if the interval gets too big.) But it's stupid to make this adjustment every frame, right? Better to only do it once every few seconds at most. The most elegant way to do that in Pygame is probably to set a user event, but how do I do that and make it appear once every [spam] milliseconds? The only problem with a user event would be in that it would take up one event slot (since you're writing a library you'd want to try to restrict things like that, I'd assume.) actually, another problem is that your physics sim would have to have access to the event queue, or the client would have to call fix_yourself (or whatever you name the function) whenever the event arose. IMHO, the client shouldn't be required to keep your sim updated in that way. pygame.time.set_timer(EventCode,HowOftenToEnqueueIt) that's all you have to do, I believe. HowOften is in milliseconds, so 300 would be every .3 milliseconds. HTH, -Luke Kris
[pygame] Adjusting Timing With a User Event
How can I go about adjusting the speed of in-game events based on the current FPS? That is, my physics sim works in steps with a known time interval, but the _game_ might have varying FPS, and I want a thrown ball to move at a constant rate in real time regardless of how many animation frames/simulation steps happen. Right now I've got a Pygame "clock" in my main loop to regulate game speed to a max of 30 FPS. I just now added the line: self.time_interval = min(1.0 / clock.get_fps(),.3) Which should change the amount of time that a simulation step represents to be either the amount of real time since the last step, or .3 s, whichever is smaller. (Bad things happen if the interval gets too big.) But it's stupid to make this adjustment every frame, right? Better to only do it once every few seconds at most. The most elegant way to do that in Pygame is probably to set a user event, but how do I do that and make it appear once every [spam] milliseconds? Kris
Re: [pygame] pygame standard mouse
On Thu, Apr 19, 2007 at 03:42:57AM -0400, Ethan Glasser-Camp wrote: > Brian Fisher wrote: > >> I like fast mice :) > >> > > I think this might actually be why you are seeing a problem. I'll be > > blunt, you are a freak. Your freakish pecadillo for responsive pointer > > movement puts you in a very small category of people for whom > > Microsoft has not designed for with DirectX. > > Is it just me, or is this a little harsh for an email on this list? I > would have understood it as a joke if there was a smiley, but there > wasn't. Was it meant to be a joke or is this topic a sore spot for > pygame developers? > > Ethan I can attest from over two decades of personal experience that *almost every word* that Brian Fisher utters is intended to be taken humorously, so when he appears to type something mean, it means he was going for friendly sarcasm, and forgot the smileys. Bad Brian! Remember your smileys! --- James Paige
Re: [pygame] Rotate image around another point?
On 4/19/07, John Eriksson <[EMAIL PROTECTED]> wrote: Wher reading Ulfs answer a little more carefully I thinks that it's just what he is sugesting. *smile* Yeah, I was a bit unclear perhaps. If you really want to do make a large picture with a lot of empty space you have to create a clear surface and blit your rotated image onto that. In this way you can do what you describe, but unless you are writing an image editor I don't really see why you want to do that. If you just want to make a rotating sprite you really have to keep track of the "offset" of each image yourself, in this case surrounding transparent pixels are just a waste. I use a crop function to automatically remove such borders, but then you do need to keep track of this in the offset, so that the drawing position is consistent. Ulf
Re: [pygame] Rotate image around another point?
Wher reading Ulfs answer a little more carefully I thinks that it's just what he is sugesting. *smile* /John tor 2007-04-19 klockan 12:31 +0200 skrev John Eriksson: > But maybe it'll work if you first rotate the imagedata around the > centerpoint using pygame.transform.rotate(...) and then rotate the > centerpoint around the wanted rotation point? Havn't tried it yet > though. Sounds reasonably but what do you think? > > /John > > tor 2007-04-19 klockan 12:24 +0200 skrev altern: > > john is talking about the actual image surface data not just the sprite > > location. i guess you might need something like PIL library, but i would > > not really know how to do this. > > > > John Eriksson(e)k dio: > > > But that is not what I'm trying to do.I want to rotate the actual > > > imagedata (like rotating an image using PohotSshop or GIMP). Not just > > > the location where the image is drawn. > > > > > > The pygame.transform.rotate(...) function does that but always rotates > > > the imagedata about it's center. > > > > > > /John > > > > > > tor 2007-04-19 klockan 11:02 +0200 skrev Ulf Ekström: > > >> On 4/19/07, John Eriksson <[EMAIL PROTECTED]> wrote: > > >>> Well, no. > > >>> > > >>> I'm looking for a way to rotate the imagedata (like > > >>> pygame.transform.rotate(...)) but your example rotates the image > > >>> location. Right? > > >> It is actually the same thing. Rotation around some arbitrary point > > >> can be decomposed into a rotation around some other point followed by > > >> a translation. Suppose you have a function R which rotates things > > >> around the origin. To write a function Rp which rotates around the > > >> point p (p and q are vectors), you do > > >> > > >> Rp(q) = R(q-p)+p > > >> > > >> Since R is a linear function you can do > > >> > > >> Rp(q) = R(q) + p - R(p) > > >> > > >> So rotating around p is the same as rotating around the origin and > > >> then translating by p - R(p). > > >> > > >> Ulf > > > > > >
Re: [pygame] Rotate image around another point?
But maybe it'll work if you first rotate the imagedata around the centerpoint using pygame.transform.rotate(...) and then rotate the centerpoint around the wanted rotation point? Havn't tried it yet though. Sounds reasonably but what do you think? /John tor 2007-04-19 klockan 12:24 +0200 skrev altern: > john is talking about the actual image surface data not just the sprite > location. i guess you might need something like PIL library, but i would > not really know how to do this. > > John Eriksson(e)k dio: > > But that is not what I'm trying to do.I want to rotate the actual > > imagedata (like rotating an image using PohotSshop or GIMP). Not just > > the location where the image is drawn. > > > > The pygame.transform.rotate(...) function does that but always rotates > > the imagedata about it's center. > > > > /John > > > > tor 2007-04-19 klockan 11:02 +0200 skrev Ulf Ekström: > >> On 4/19/07, John Eriksson <[EMAIL PROTECTED]> wrote: > >>> Well, no. > >>> > >>> I'm looking for a way to rotate the imagedata (like > >>> pygame.transform.rotate(...)) but your example rotates the image > >>> location. Right? > >> It is actually the same thing. Rotation around some arbitrary point > >> can be decomposed into a rotation around some other point followed by > >> a translation. Suppose you have a function R which rotates things > >> around the origin. To write a function Rp which rotates around the > >> point p (p and q are vectors), you do > >> > >> Rp(q) = R(q-p)+p > >> > >> Since R is a linear function you can do > >> > >> Rp(q) = R(q) + p - R(p) > >> > >> So rotating around p is the same as rotating around the origin and > >> then translating by p - R(p). > >> > >> Ulf > > > >
Re: [pygame] Rotate image around another point?
john is talking about the actual image surface data not just the sprite location. i guess you might need something like PIL library, but i would not really know how to do this. John Eriksson(e)k dio: But that is not what I'm trying to do.I want to rotate the actual imagedata (like rotating an image using PohotSshop or GIMP). Not just the location where the image is drawn. The pygame.transform.rotate(...) function does that but always rotates the imagedata about it's center. /John tor 2007-04-19 klockan 11:02 +0200 skrev Ulf Ekström: On 4/19/07, John Eriksson <[EMAIL PROTECTED]> wrote: Well, no. I'm looking for a way to rotate the imagedata (like pygame.transform.rotate(...)) but your example rotates the image location. Right? It is actually the same thing. Rotation around some arbitrary point can be decomposed into a rotation around some other point followed by a translation. Suppose you have a function R which rotates things around the origin. To write a function Rp which rotates around the point p (p and q are vectors), you do Rp(q) = R(q-p)+p Since R is a linear function you can do Rp(q) = R(q) + p - R(p) So rotating around p is the same as rotating around the origin and then translating by p - R(p). Ulf
Re: [pygame] SVG and Pango support
On, Thu Apr 19, 2007, Noah Kantrowitz wrote: > Marcus von Appen wrote: > > On, Thu Apr 19, 2007, Noah Kantrowitz wrote: > > > > > >> As OLPC is in need of both SVG and Pango support in Pygame, I am looking > >> at making wrappers for SDL_svg and SDL_pango. Rene mentioned that > >> someone has some code for using Cairo, is this online somewhere? Also, > >> how would people feel about this as an addition to pygame itself vs. a > >> secondary library? > >> > > > > There is an Cookbook entry using py-cairo at > > http://www.pygame.org/wiki/CairoPygame?parent=CookBook. > > > > I wrote an own small module, which uses libsvg-cairo to load and > > renderer SVG graphics as pygame surfaces. As it's 'not really' my own > > code, I'll contact you in private about it ;-). > > > > A direct addition to pygame should be handled using the > > pygame.image.load() methods and the support should be optional. Using > > libsvg-cairo this could be achieved pretty fast, but I there does not > > seem to be any support for other platforms besides Win32, the common > > Unices and probably MacOS X. > > I wonder for which platforms SDL_svg is currently available. > > > I would actually disagree here. I would rather be able to load an svg > object, and then render it as needed. This makes it easy to have the Do you have a SVG library at hand, which supports all the platforms supported by pygame? If not, it would not make sense, to make an own module of it. As far as I know, cairo and cairo-svg are supporting the most platforms, but might still lack support for the one or other. Thus the module would be only availabe on a certain platform. As I understand at least Win32, Unices (X11), MacOS X and QNX should be supported. > same icon in two different sizes, while minimizing wasted cycles. I see > SVG support working much more like the Font object than an image. You > load from a file, set parameters, and then render to a surface. Right. That's what SVG is for. > > Regarding SDL_pango I already started some code to enhance the font and > > text rendering support in pygame. Pango brings some really important > > features such as (nearly) correct complex script handling, good text > > layout and formatting capabilities and more. My code however currently > > does not work and will take some more time to be suitable for > > pygame. > > > > Is your code actually based on Pango, or just on SDL_ttf? For a project SDL_ttf does not make use of Pango as far as I know. When I say Pango, I mean that ;-). The code is based on Pango 1.11. I think, I need to look through it in order to make it work with pygame and the latest pango release. > like OLPC there are a lot of issues with stuff like RTL languages and > Arabic scripts, both of which as painful with a simple font layout system. > Regards Marcus pgpZKbaF8t5im.pgp Description: PGP signature
Re: [pygame] SVG and Pango support
Marcus von Appen wrote: > On, Thu Apr 19, 2007, Noah Kantrowitz wrote: > > >> As OLPC is in need of both SVG and Pango support in Pygame, I am looking >> at making wrappers for SDL_svg and SDL_pango. Rene mentioned that >> someone has some code for using Cairo, is this online somewhere? Also, >> how would people feel about this as an addition to pygame itself vs. a >> secondary library? >> > > There is an Cookbook entry using py-cairo at > http://www.pygame.org/wiki/CairoPygame?parent=CookBook. > > I wrote an own small module, which uses libsvg-cairo to load and > renderer SVG graphics as pygame surfaces. As it's 'not really' my own > code, I'll contact you in private about it ;-). > > A direct addition to pygame should be handled using the > pygame.image.load() methods and the support should be optional. Using > libsvg-cairo this could be achieved pretty fast, but I there does not > seem to be any support for other platforms besides Win32, the common > Unices and probably MacOS X. > I wonder for which platforms SDL_svg is currently available. > I would actually disagree here. I would rather be able to load an svg object, and then render it as needed. This makes it easy to have the same icon in two different sizes, while minimizing wasted cycles. I see SVG support working much more like the Font object than an image. You load from a file, set parameters, and then render to a surface. > Regarding SDL_pango I already started some code to enhance the font and > text rendering support in pygame. Pango brings some really important > features such as (nearly) correct complex script handling, good text > layout and formatting capabilities and more. My code however currently > does not work and will take some more time to be suitable for > pygame. > Is your code actually based on Pango, or just on SDL_ttf? For a project like OLPC there are a lot of issues with stuff like RTL languages and Arabic scripts, both of which as painful with a simple font layout system. --Noah signature.asc Description: OpenPGP digital signature
Re: [pygame] SVG and Pango support
On, Thu Apr 19, 2007, Noah Kantrowitz wrote: > As OLPC is in need of both SVG and Pango support in Pygame, I am looking > at making wrappers for SDL_svg and SDL_pango. Rene mentioned that > someone has some code for using Cairo, is this online somewhere? Also, > how would people feel about this as an addition to pygame itself vs. a > secondary library? There is an Cookbook entry using py-cairo at http://www.pygame.org/wiki/CairoPygame?parent=CookBook. I wrote an own small module, which uses libsvg-cairo to load and renderer SVG graphics as pygame surfaces. As it's 'not really' my own code, I'll contact you in private about it ;-). A direct addition to pygame should be handled using the pygame.image.load() methods and the support should be optional. Using libsvg-cairo this could be achieved pretty fast, but I there does not seem to be any support for other platforms besides Win32, the common Unices and probably MacOS X. I wonder for which platforms SDL_svg is currently available. Regarding SDL_pango I already started some code to enhance the font and text rendering support in pygame. Pango brings some really important features such as (nearly) correct complex script handling, good text layout and formatting capabilities and more. My code however currently does not work and will take some more time to be suitable for pygame. Regards Marcus pgpv4nC6uHTKI.pgp Description: PGP signature
Re: [pygame] Rotate image around another point?
But that is not what I'm trying to do.I want to rotate the actual imagedata (like rotating an image using PohotSshop or GIMP). Not just the location where the image is drawn. The pygame.transform.rotate(...) function does that but always rotates the imagedata about it's center. /John tor 2007-04-19 klockan 11:02 +0200 skrev Ulf Ekström: > On 4/19/07, John Eriksson <[EMAIL PROTECTED]> wrote: > > Well, no. > > > > I'm looking for a way to rotate the imagedata (like > > pygame.transform.rotate(...)) but your example rotates the image > > location. Right? > > It is actually the same thing. Rotation around some arbitrary point > can be decomposed into a rotation around some other point followed by > a translation. Suppose you have a function R which rotates things > around the origin. To write a function Rp which rotates around the > point p (p and q are vectors), you do > > Rp(q) = R(q-p)+p > > Since R is a linear function you can do > > Rp(q) = R(q) + p - R(p) > > So rotating around p is the same as rotating around the origin and > then translating by p - R(p). > > Ulf
Re: [pygame] Rotate image around another point?
> > I'm looking for a way to rotate the imagedata (like > > pygame.transform.rotate(...)) but your example rotates the image > > location. Right? > > It is actually the same thing. No, what John wants is a function like this: rotationCenter = (myimage.center[0]+10,myimage.center[1]+20) myimage = rotateImage(myimage,rotationCenter, 45) So he wants to add some clear areas in the surface? Isn't it better to keep a drawing offset together with the image? Or is this related to clipping somehow? Ulf
[pygame] weekly pygame development sprints on irc
Hi, Marcus and I are starting up a weekly pygame sprint for a few hours on Wednesdays. Wednesdays: 10pm CEST (central eurpean summer time (UTC+2) (Germany) 6am AEST(Australian Eastern Standard Time) +10 GMT (Australia) It'll probably go for 3-4 hours. We're working on getting pygame released, as well as making plans, fixing bugs, writing docs, writing tests, testing, adding features and having a bit of a fun old pygame coding time. More people the merrier! If you want to try and get a bug fixed, talk about adding some feature, or learn about coding in C with python/SDL/pygame then it would be good to join in. Hopefully the regular sprints will add some more enthusiasm about pygame development. irc channel is the normal pygame one: #pygame irc.freenode.net Cheers,
Re: [pygame] Rotate image around another point?
On 4/19/07, Ulf Ekström <[EMAIL PROTECTED]> wrote: On 4/19/07, John Eriksson <[EMAIL PROTECTED]> wrote: > Well, no. > > I'm looking for a way to rotate the imagedata (like > pygame.transform.rotate(...)) but your example rotates the image > location. Right? It is actually the same thing. No, what John wants is a function like this: rotationCenter = (myimage.center[0]+10,myimage.center[1]+20) myimage = rotateImage(myimage,rotationCenter, 45)
[pygame] SVG and Pango support
As OLPC is in need of both SVG and Pango support in Pygame, I am looking at making wrappers for SDL_svg and SDL_pango. Rene mentioned that someone has some code for using Cairo, is this online somewhere? Also, how would people feel about this as an addition to pygame itself vs. a secondary library? --Noah signature.asc Description: OpenPGP digital signature
Re: [pygame] Rotate image around another point?
On 4/19/07, John Eriksson <[EMAIL PROTECTED]> wrote: Well, no. I'm looking for a way to rotate the imagedata (like pygame.transform.rotate(...)) but your example rotates the image location. Right? It is actually the same thing. Rotation around some arbitrary point can be decomposed into a rotation around some other point followed by a translation. Suppose you have a function R which rotates things around the origin. To write a function Rp which rotates around the point p (p and q are vectors), you do Rp(q) = R(q-p)+p Since R is a linear function you can do Rp(q) = R(q) + p - R(p) So rotating around p is the same as rotating around the origin and then translating by p - R(p). Ulf
Re: [pygame] pygame standard mouse
On 4/19/07, Brian Fisher <[EMAIL PROTECTED]> wrote: I checked out the game you mentioned, and the mouse speed was identical in both cases for me. I believe that the issue you are experiencing isn't that mouse-speed in fullscreen is inherently faster or slower than windowed, it's that directX based fullscreen modes don't apply the desktop pointer speed adjustments. This also applies to some X fullscreen modes, and for windowed modes if you "grab" the mouse pointer (to draw your own pointer, for example). [..] > I like fast mice :) > I think this might actually be why you are seeing a problem. I'll be blunt, you are a freak. No, this is wrong. This is probably hardware and OS dependent, but on my machine an unaccelerated mouse requires something like five trips across the mousepad to go from one end of the screen to the other. This is not good, and most importantly it disregards the user preference for mouse speed. It would be nice if pygame could accelerate the mouse behind the scenes, using preferences from the windowing environment. Ulf
Re: [pygame] Rotate image around another point?
Well, no. I'm looking for a way to rotate the imagedata (like pygame.transform.rotate(...)) but your example rotates the image location. Right? /John tor 2007-04-19 klockan 10:36 +0200 skrev altern: > hi john > > John Eriksson(e)k dio: > > Hi, > > > > The rotate function in the transform module rotates an image about its > > center. But what if I want to use another point? > > > > Is there another solution than to modify the size of the image to change > > its center point? > > I think something like this should do what you are looking for. > > from math import * > > def rotPoint(point, axis, ang): > """ Orbit. calcs the new loc for a point that rotates a given num > of degrees around an axis point, > +clockwise, -anticlockwise -> tuple x,y > """ > x, y = point[0] - axis[0], point[1] - axis[1] > radius = sqrt(x*x + y*y) # get the distance between points > > RAng = radians(ang) # convert ang to radians. > > h = axis[0] + ( radius * cos(RAng) ) > v = axis[1] + ( radius * sin(RAng) ) > > return h, v > > > myimage.center = rotPoint(myimage.center, (300,300), 45) > > this line should rotate myimage.center around point (300,300) by 45 degrees > > > > Best Regards > > /John Eriksson > > > >
Re: [pygame] Rotate image around another point?
hi john John Eriksson(e)k dio: Hi, The rotate function in the transform module rotates an image about its center. But what if I want to use another point? Is there another solution than to modify the size of the image to change its center point? I think something like this should do what you are looking for. from math import * def rotPoint(point, axis, ang): """ Orbit. calcs the new loc for a point that rotates a given num of degrees around an axis point, +clockwise, -anticlockwise -> tuple x,y """ x, y = point[0] - axis[0], point[1] - axis[1] radius = sqrt(x*x + y*y) # get the distance between points RAng = radians(ang) # convert ang to radians. h = axis[0] + ( radius * cos(RAng) ) v = axis[1] + ( radius * sin(RAng) ) return h, v myimage.center = rotPoint(myimage.center, (300,300), 45) this line should rotate myimage.center around point (300,300) by 45 degrees Best Regards /John Eriksson
[pygame] Rotate image around another point?
Hi, The rotate function in the transform module rotates an image about its center. But what if I want to use another point? Is there another solution than to modify the size of the image to change its center point? Best Regards /John Eriksson
Re: [pygame] pygame standard mouse
Brian Fisher wrote: >> I like fast mice :) >> > I think this might actually be why you are seeing a problem. I'll be > blunt, you are a freak. Your freakish pecadillo for responsive pointer > movement puts you in a very small category of people for whom > Microsoft has not designed for with DirectX. Is it just me, or is this a little harsh for an email on this list? I would have understood it as a joke if there was a smiley, but there wasn't. Was it meant to be a joke or is this topic a sore spot for pygame developers? Ethan signature.asc Description: OpenPGP digital signature