Re: [pygame] Make a sprite fall with realistic gravity?

2009-11-30 Thread Eric Pavey
On Mon, Nov 30, 2009 at 3:20 AM, René Dudfield  wrote:

> On Mon, Nov 30, 2009 at 11:37 AM, Rob  wrote:
> > I've been trying to get a sprite (the ball) to fall from the top of
> > the screen with realistic gravity. I did attempt it, however it's not
> > so great so I won't post it here.
> >
> > I wasn't quite sure how to do it, I had it dropping per frame instead
> > of per second, which meant it went about 60x too fast. I thought about
> > dividing by 60, but then I figured the frame rate wouldn't be the same
> > all the time. Also, the math seemed weird, because it would travel
> > horizontally for a while before dropping (until deltay >= 1). I tried
> > using math.ceil() but that made it unrealistically jerky instead of
> > smooth falling.
> >
> > Can anyone give me a little example of a sprite class that falls with
> > the effects of gravity?
> >
> > Thanks.
> >
>
>
> hi,
>
> have you looked at some of:
>http://www.pygame.org/tags/physics
>
> There's a bunch of gravity using things there.
>

Agreed.  I'd recommend looking at either pymunk or pybox2d for 2d stuff:
http://code.google.com/p/pymunk/
http://code.google.com/p/pybox2d/
I've used pymunk quite a bit in my pygame stuff, it's pretty approachable.

And PyODE has bindings to the Open Dynamics Engine for doing 3d, although I
haven't messed with it at all:  http://pyode.sourceforge.net/


[pygame] Re: Query Pygame window position after creation?

2009-10-26 Thread Eric Pavey
Bit more poking, and I got the problem solved.  If anyone was interested I
put it up on my blog with link to source code:
http://www.akeric.com/blog/?page_id=814


[pygame] Re: Pygame detect writable status of a file?

2009-10-19 Thread Eric Pavey
D'oh.  Wrong email list in Gmail!  Even got my title goofed up.
sorry
I'm tired.


[pygame] Pygame detect writable status of a file?

2009-10-19 Thread Eric Pavey
I feel like I'm missing something in the prefs, and this behavior has been
on three different machines (two winXP, one Vista) with Wing:
I have a file that is read-only, I open it in wing.  I can't edit it.  So I
make it writable (managed through Perforce).  The only way (that I can so
far find) for Wing to recognize that its writable is to close the file and
re-open it.  If I do the opposite:  Start with it writable and then make it
read-only, this seems to confuse Wing:  I save, it doesn't error, but
nothing saves either (but it makes you think you saved ok).  The other
editors I use seem to auto-detect the file-writable status.
Any thoughts?
thanks


[pygame] Re: Query Pygame window position after creation?

2009-10-17 Thread Eric Pavey
So, I can partly reply to my own post:  I found a way to do this on Windows
(shown below).  But I realize this returns the location of the window, I
need to know the location of the display screen (pygame surface).  The
values this returns are the outer window extents, including title-bar, outer
window frame, and these can vary based on the UI.  So I guess I should
re-ask my question:

For a given Pygame surface, how can I query its position in the screen
(computer screen, not pygame display)

from ctypes import POINTER, WINFUNCTYPE, windll
from ctypes.wintypes import BOOL, HWND, RECT

# get our window ID:
hwnd = pygame.display.get_wm_info()["window"]

# Jump through all the ctypes hoops:
prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
paramflags = (1, "hwnd"), (2, "lprect")
GetWindowRect = prototype(("GetWindowRect", windll.user32), paramflags)

# finally get our data!
rect = GetWindowRect(hwnd)
print "top, left, bottom, right: ", rect.top, rect.left, rect.bottom, rect.right
# bottom, top, left, right:  644 98 124 644


[pygame] Query Pygame window position after creation?

2009-10-17 Thread Eric Pavey
I've been searching, but not finding:  Is there any way to query the
location of the Pygame window after creation?  There doesn't seem to be an
event that is triggered when the window is moved, but there is an event for
when it is resized.  I've found the post describing how you can control its
creation position like so:

os.environ['SDL_VIDEO_WINDOW_POS'] = "10,10"

But once its made, and the user has moved it, how to query the updated
position?  Would also like to know if there was an event or callback
triggered when the window has been moved.
Presumably it'd return the location of one of the corners...
Many thanks.


Re: [pygame] Capture tablet pressure?

2009-10-14 Thread Eric Pavey
If anyone is interested, I got this working.  Posted on my blog\Pygame, with
pointers to source download:
http://www.akeric.com/blog/?p=777
http://www.pygame.org/project-Tablet+Pressure-1302-2287.html


Re: [pygame] Capture tablet pressure?

2009-10-12 Thread Eric Pavey
So I tried the cgkit\wintab route.  Had some success, but still can't get
the dang pressure.  Below is the code I came up with if anyone wants to poke
at it  When ran, it prints stuff like:

 0 0

With the last two values representing pressure.  Well, it's a start ;)

# pressure.py
import os
import pygame
from cgkit import wintab

pygame.init()

hwnd = 1024
os.environ["SDL_WINDOWID"] = str(hwnd)

def main():
screen = pygame.display.set_mode((640, 480))
background = pygame.surface.Surface(screen.get_size())
background.fill(pygame.color.Color("Black"))
screen.blit(background, (0,0))

#
# Creates a "Context" object:
tablet = wintab.Context()
tablet.open(hwnd, True)

looping = True
while looping:
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
# allow for exit:
looping = False

#
# Get a tuple of range of packets captured: (first, last)
packetExtents = tablet.queuePacketsEx()
if packetExtents[1] is not None:
# This is a sub-list of Packet objects:
packets = tablet.packetsGet(packetExtents[1])
# Get the last Packet object:
packet = packets[-1]
# Print packet info, and pressure data:
print packet, packet.normalpressure, packet.tangentpressure

pygame.display.flip()
pygame.quit()

if __name__ == "__main__":
main()


[pygame] Capture tablet pressure?

2009-10-11 Thread Eric Pavey
Been searching around, and haven't come up with anything:  Anyone know how
to capture tablet pressure in Pygame?  Pygame recognizes my tablet (Wacom
Bamboo) just fine as a mouse, buttonclicks etc, but no "pressure" based on
those clicks.  Any advice?  Is it possible that SDL doesn't support tablets?

thanks


Re: [pygame] Python IDE for windoz

2009-10-06 Thread Eric Pavey
I really enjoy Wing IDE
http://www.wingware.com/

Free to start, and once you learn more, the $$$ version is worth the money
IMO


Re: [pygame] "tint" a surface?

2009-09-19 Thread Eric Pavey
Based on your suggestion I tried
surface.fill(color, special_flags=BLEND_RGB_MULT)

And actually, it's working great.  From four lines to one, nice.

Thanks for the tip!


[pygame] "tint" a surface?

2009-09-19 Thread Eric Pavey
I've been searching around, trying to see if there is a 'best practice" way
of doing this in PyGame.  Havn't found much, time to ask.  I'm used to doing
this in Processing where it's pretty
easy,
so I feel like I may be missing something.  But don't worry, I'm a PyGame
convert :)

Example:

   - A texture (.png):  donut shape, (donut pixels are white) feathered
   edges blend into alpha.  Loaded as a Surface.
   - A predefined Color (say, "orange").
   - I want to 'tint' my whole Surface based on the Color.  Preferably, I'd
   do this at every loop, it wouldn't be 'baked' into the image.

Currently, I'm kind of hacking around this:

   - Load my featherd donut image.
   - Make a new "tint" surface based on the donut image resolution.
   - Fill the "tint" surface with the given color.
   - Then at each frame:
   - Blit the tint surface to a copy of my donut surface, with
  "special_flags=BLEND_RGBA_MULT"

This *does *work.  But seems like a lot of extra surfaces I'm making to pull
it off.  I'd rather see (given the ability)

Surface.tint(someColor)

Which would simply return a new surface tinted with the given color.
Am I missing something built-in?  Any other ideas?

Thanks


Re: [pygame] EXEs: Different Approach

2009-09-15 Thread Eric Pavey
Just to be clear, the setup.py he lists on this link didn't work?
http://hg.thadeusb.com/public/.r/Games/MyRTS/file/4dfc6b0d398b/src/setup.py

I'd been using a similar setup.py to what you listed in your previous post
with no luck.  The once I link to in this post gave me much better results.

Just wanted to make sure you didn't miss it.  You have to tweak it to your
own needs of course, and sometimes I have to figure out... by hand, which
dll's need to be copied over.  but if you've already been down that road,
never mind ;)


Re: [pygame] EXEs: Different Approach

2009-09-15 Thread Eric Pavey
I was having a real hard time, ran across this post:
http://blog.thadeusb.com/2009/04/15/pygame-font-and-py2exe/

Talked with the author, and he provided his setup.py script (available from
the comments of that post) which I modified, and have been making .exe's
with ever since, using Python 2.6.2, PyGame 1.9.1