Re: [pygame] immediate mode not working?
OK I noticed that by pumping the event queue, with pygame.event.get() , I actually manage to see the blue squares being drawn, but only when this command is written. If I flip again, I'd have to pump the event queue once again. --- On Tue, 7/8/08, Brian Fisher <[EMAIL PROTECTED]> wrote: From: Brian Fisher <[EMAIL PROTECTED]> Subject: Re: [pygame] immediate mode not working? To: pygame-users@seul.org Date: Tuesday, July 8, 2008, 4:46 PM Blit works just fine for me - it's not a fill vs. blit thing - the problem you just experienced is something else - it's possible events need to get processed again? try calling pygame.event.get() when things don't seem to work (if you are not pumping the event loop, btw, you are not using pygame in a supported fashion, and the results are unpredictable) anyways, I did the sequence of stuff below, and it all worked exactly as expected for me (demonstrating blits can work fine) C:\Documents and Settings\Owner>c:\python25\python Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pygame >>> pygame.init() (6, 0) >>> screen=pygame.display.set_mode((400,300)) >>> pygame.event.get() [, , >> blueSquare = pygame.surface.Surface((50,50)) >>> blueSquare.fill((0,0,255)) >>> screen.blit(blueSquare, (30,30)) >>> pygame.display.flip() >>> screen.blit(blueSquare, (100,100)) >>> pygame.display.flip() >>> screen.blit(blueSquare, (200,130)) >>> pygame.display.flip() On Tue, Jul 8, 2008 at 3:57 PM, Gabriel Hasbun <[EMAIL PROTECTED]> wrote: You are right, filling the screen seems to work, but not blitting to it. C:\Documents and Settings\Gabriel>python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pygame >>> pygame.init() (6, 0) >>> screen=pygame.display.set_mode((400,300)) >>> pygame.event.get() [, , , , ] >>> screen.fill((255,255,255)) >>> pygame.display.flip() >>> screen.fill((255,0,0)) >>> pygame.display.flip() >>> screen.fill((255,240,70)) >>> pygame.display.update() >>> blueSquare = ((0,0,255)) >>> blueSquare = pygame.surface.Surface((50,50)) >>> blueSquare.fill((0,0,255)) # everything alright up until here. >>> screen.blit(blueSquare, (30,30)) >>> pygame.display.update() # pygame window at this point is non >>> responsive. >>> --- On Tue, 7/8/08, Brian Fisher <[EMAIL PROTECTED]> wrote: From: Brian Fisher <[EMAIL PROTECTED]> Subject: Re: [pygame] immediate mode not working? To: pygame-users@seul.org Date: Tuesday, July 8, 2008, 3:03 PM The problem is that you need to tell SDL to process windows messages before your window can be used (any event getting function should do) try this: - import pygame pygame.init() screen = pygame.display.set_mode((400,300)) pygame.event.get() screen.fill((255,255,255)) pygame.display.flip() screen.fill((0,0,0)) pygame.display.flip() - it worked in a command prompt console for me On Tue, Jul 8, 2008 at 2:09 PM, Gabriel Hasbun <[EMAIL PROTECTED]> wrote: sure: C:\Documents and Settings\Gabriel>python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pygame >>> pygame.init() (6, 0) >>> screen = pygame.display.set_mode((400, 300)) >>> whiteSquare = pygame.surface.Surface((50,50)) >>> whiteSquare.fill((255,0,0)) >>> screen.blit(whiteSquare, (100,100)) >>> pygame.display.flip() >>> As you can guess nothing happens on my pygame window, while using the MSDOS(the real) python. --- On Tue, 7/8/08, Ian Mallett <[EMAIL PROTECTED]> wrote: From: Ian Mallett <[EMAIL PROTECTED]> Subject: Re: [pygame] immediate mode not working? To: pygame-users@seul.org Date: Tuesday, July 8, 2008, 1:16 PM Could we see the code? -I
Re: [pygame] immediate mode not working?
You are right, filling the screen seems to work, but not blitting to it. C:\Documents and Settings\Gabriel>python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pygame >>> pygame.init() (6, 0) >>> screen=pygame.display.set_mode((400,300)) >>> pygame.event.get() [, , , , ] >>> screen.fill((255,255,255)) >>> pygame.display.flip() >>> screen.fill((255,0,0)) >>> pygame.display.flip() >>> screen.fill((255,240,70)) >>> pygame.display.update() >>> blueSquare = ((0,0,255)) >>> blueSquare = pygame.surface.Surface((50,50)) >>> blueSquare.fill((0,0,255)) # everything alright up until here. >>> screen.blit(blueSquare, (30,30)) >>> pygame.display.update() # pygame window at this point is non >>> responsive. >>> --- On Tue, 7/8/08, Brian Fisher <[EMAIL PROTECTED]> wrote: From: Brian Fisher <[EMAIL PROTECTED]> Subject: Re: [pygame] immediate mode not working? To: pygame-users@seul.org Date: Tuesday, July 8, 2008, 3:03 PM The problem is that you need to tell SDL to process windows messages before your window can be used (any event getting function should do) try this: - import pygame pygame.init() screen = pygame.display.set_mode((400,300)) pygame.event.get() screen.fill((255,255,255)) pygame.display.flip() screen.fill((0,0,0)) pygame.display.flip() - it worked in a command prompt console for me On Tue, Jul 8, 2008 at 2:09 PM, Gabriel Hasbun <[EMAIL PROTECTED]> wrote: sure: C:\Documents and Settings\Gabriel>python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pygame >>> pygame.init() (6, 0) >>> screen = pygame.display.set_mode((400, 300)) >>> whiteSquare = pygame.surface.Surface((50,50)) >>> whiteSquare.fill((255,0,0)) >>> screen.blit(whiteSquare, (100,100)) >>> pygame.display.flip() >>> As you can guess nothing happens on my pygame window, while using the MSDOS(the real) python. --- On Tue, 7/8/08, Ian Mallett <[EMAIL PROTECTED]> wrote: From: Ian Mallett <[EMAIL PROTECTED]> Subject: Re: [pygame] immediate mode not working? To: pygame-users@seul.org Date: Tuesday, July 8, 2008, 1:16 PM Could we see the code? -I
Re: [pygame] immediate mode not working?
sure: C:\Documents and Settings\Gabriel>python Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pygame >>> pygame.init() (6, 0) >>> screen = pygame.display.set_mode((400, 300)) >>> whiteSquare = pygame.surface.Surface((50,50)) >>> whiteSquare.fill((255,0,0)) >>> screen.blit(whiteSquare, (100,100)) >>> pygame.display.flip() >>> As you can guess nothing happens on my pygame window, while using the MSDOS(the real) python. --- On Tue, 7/8/08, Ian Mallett <[EMAIL PROTECTED]> wrote: From: Ian Mallett <[EMAIL PROTECTED]> Subject: Re: [pygame] immediate mode not working? To: pygame-users@seul.org Date: Tuesday, July 8, 2008, 1:16 PM Could we see the code? -I
[pygame] immediate mode not working?
Hello there, I open python 2.5.2 and pygame 1.7.1 is being used on the MSDOS command prompt, I initialize python and create a display, and the window opens normally. The problem arises when I try to blit to the screen display. I thought that was an issue in the IDLE shell, but the same problem happens on MSDOS . Ironically I tried it on the python shell of GIMP(GNU Image Manipulation Program) and there everything seems to go by normally(well at least I can blit surfaces to the screen display). What could be going on? Cheers.
[pygame] weakref WeakKeyDictionary machinery.
Hello I searched the whole web for good examples on weakref module's WeakKeyDictionary, but have found none, All I find is the Python Docs explanations, and some examples which actually doesn't explain how the mechanism of key reference removal works: import weakref class Tracking: _instances_dict = weakref.WeakValueDictionary( ) _num_generated = 0 def _ _init_ _(self): Tracking._num_generated += 1 Tracking._instances_dict[Tracking._num_generated] = self def instances( ): return _instances_dict.values( ) instances = staticmethod(instances)
Re: [pygame] Dirty Rect updating
I think you are not correctly blitting the background to the screen Surface. Although I can't be sure about it since you did not post any real python code... --- On Sat, 5/17/08, etrek <[EMAIL PROTECTED]> wrote: From: etrek <[EMAIL PROTECTED]> Subject: [pygame] Dirty Rect updating To: pygame-users@seul.org Date: Saturday, May 17, 2008, 7:01 PM Hi, I'm trying to update just the portions of my screen that change per frame. The problem I'm having is that only the image I'm animating is showing up. My background is not showing up - background is now black. I'm not using Sprite/SpriteGroup, but I will soon, and I'm thinking I'll have the same problem when I try to render the dirty rects list returned by RnderUpdates.draw() method. pseudocode: background = pygame.image.load(background.png) surface = pygame.image.load(spaceship) while true: get events clear screen to white blit background blit spaceship create rect of where surface is on screen pygame.display.update(rect) # which in this case is a rectangle in the location of my animated surface I'm following procedure from http://www.pygame.org/docs/tut/newbieguide.html: Blit a piece of the background over the sprite's current location, erasing it. Append the sprite's current location rectangle to a list called dirty_rects. Move the sprite. Draw the sprite at it's new location. Append the sprite's new location to my dirty_rects list. Call display.update(dirty_rects) Thanks for help Ethan
Re: [pygame] I'm loving wills book :)
Wow this sounds like THE book. Very interesting, looking forward to help in any way. Nathan Whitehead <[EMAIL PROTECTED]> wrote: On Thu, Apr 3, 2008 at 12:16 AM, Lamonte(Scheols/Demonic) wrote: > The only pygame book availible to man? > http://www.apress.com/book/view/9781590598726 Hi, might as well introduce myself. I'm Nathan Whitehead, just got my computer science phd. My main research is in security models and certified software, but I also love love love messing about with computer games and python. Currently I'm working on a book on python game programming tentatively titled: **Adventures in Game Programming : Using Python and Pygame to create innovative games quickly** It's based on a class I taught last summer where bright high school kids (many with no programming experience) used macbook pros, pygame, and various controllers including gamepads and wiimotes to create small games. It was an absolute blast, so this summer I'm writing up what we did and expanding it so other people can have the same fun we did. Right now I'm working on adding wiimote support to pygame, in collaboration with Luke Paireepinart, Michael Laforest, and Gary Bishop. The goal is a nice addition to pygame that fits the existing interfaces, is stable and as bug-free as possible, and works on all major platforms with the least amount of hassle. If you know anyone else that I should talk to, or if you are interested in working on this as well, please let me know (email [EMAIL PROTECTED]). The book is designed for people with some programming experience but who are perhaps not python masters. So there's not a review of "what is a loop", but there is a short section on defining classes and inheritance (needed for sprites). A sampling of chapter titles: * Sprites (static image sprites, animations, timing and speed issues, player sprites, keeping track of sprites) * Case Study: Zefferia (the story, Zefflonian invasion, bosses) * Rhythm: Feel the Beat (rhythm game mechanics, recording timing tracks, processing player input, scoring combos) * Case Study: Dance or Die! * Wave the Wiimote (connecting to wiimote, interpreting buttons, accelerometers and gravity, angles) * Track the Wiimote (using the Wiimote IR sensors, target practice, rotation and distance to the screen) * Artificial Intelligence (triggered behavior, finite state machines, pathfinding) If you are interested in helping out with testing code, proofreading chapters, or just giving me advice, please email me at [EMAIL PROTECTED] It will be a while until the finished book is out, but the code should be done in the next couple months and will be freely available under an open source license. Cheers, -- Nathan Whitehead between -00-00 and -99-99
Re: [pygame] I'm loving wills book :)
I use it as a reference. "Lamonte(Scheols/Demonic)" <[EMAIL PROTECTED]> wrote: that pygame book, its nice, anyone learn anything new? -- Join cleanscript.com Come here for professional PHP coding. - You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
Re: [pygame] If statements paused at click hold on window title bar?!
"since one sprite is moved by time, and the other is moved by your code executing, they move based on different conditions and there you go." Both sprites are moved based on distance_moved, which is a variable resulting from the pygame.time.Clock() instance times the speed, so both variables have the same conditions, unless I misunderstood your statement. Brian Fisher <[EMAIL PROTECTED]> wrote: in windows, when people are clicking the title bar they are moving the window (even if not moving the mouse). And by default, moving or resizing blocks in your message loop (basically this line doesn't return in the way you'd like: "for event in pygame.event.get():") since one sprite is moved by time, and the other is moved by your code executing, they move based on different conditions and there you go. There is a way to get an app in windows to not be blocked by event processing like that (something about calling your update from a particular message or returning the right value from some weird barely documented message or something like that) but I can't remember the exact thing there off the top of my head - I think pyglet had trouble with this and found a resolution. Pygame may be able to do the same, but it may require some SDL changes or unpleasant hacks. On Feb 12, 2008 9:30 AM, Gabriel Hasbun wrote: > Probably you already noticed this. > > I am using Windows XP pro, no service pack, python 2.4 and pygame 1.7.1 , > ran this script: > > import pygame > from pygame.locals import * > from sys import exit > > background_filename='sushiplate.jpg' > sprite_filename = 'fugu.png' > pygame.init() > screen = pygame.display.set_mode((640,480),0,32) > background = pygame.image.load(background_filename).convert() > sprite = pygame.image.load(sprite_filename).convert_alpha() > > # Our clock object > clock = pygame.time.Clock() > > # X coordinate of our sprite > x1 = -sprite.get_width() > x2 = -sprite.get_width() > # Speed in pixel(s) per second > speed = 250. > > frame_num = 0 > > while True: > for event in pygame.event.get(): > if event.type == QUIT: > exit() > > screen.blit(background,(0,0)) > screen.blit(sprite,(x1,50)) > screen.blit(sprite,(x2,250)) > > time_passed_in_sec = clock.tick(30)/1000. > distance_moved = time_passed_in_sec*speed > x1+=distance_moved > > if (frame_num%5)==0: > x2 = x2+distance_moved*5. > > if x1>screen.get_width() or x2>screen.get_width() : > x1, x2 = -sprite.get_width(),-sprite.get_width() > > frame_num+=1 > pygame.display.update() > > When I press and hold the mouse on the window title bar, the first sprite > (The one with x value blited = x1) advances, while the second one (The one > with x value blited = x2) is stuck in the same old x2 value, which makes me > think that the > > > if (frame_num%5)==0: > x2 = x2+distance_moved*5. > > statements are not read while the mouse button is pressed in the window's > title. Also when I leave it for about 5 seconds, when I am sure value of x1 > should be > screen.get_width() , the sprites are drawn from > > x1, x2 = -sprite.get_width(),-sprite.get_width() > > after I release the mouse button. The same happens if I leave the mouse > button from ~3 seconds up. It makes me think the if statement is not read as > well > >if x1>screen.get_width() or x2>screen.get_width() : > x1, x2 = -sprite.get_width(),-sprite.get_width() > > > > > Hope you have any ideas why this happens, and if you've experienced same > issues in other OSs and on Windows but with python 2.5 and pygame 1.8. > > Cheers. > > > > Looking for last minute shopping deals? Find them fast with Yahoo! Search. - Looking for last minute shopping deals? Find them fast with Yahoo! Search.
[pygame] If statements paused at click hold on window title bar?!
Probably you already noticed this. I am using Windows XP pro, no service pack, python 2.4 and pygame 1.7.1 , ran this script: import pygame from pygame.locals import * from sys import exit background_filename='sushiplate.jpg' sprite_filename = 'fugu.png' pygame.init() screen = pygame.display.set_mode((640,480),0,32) background = pygame.image.load(background_filename).convert() sprite = pygame.image.load(sprite_filename).convert_alpha() # Our clock object clock = pygame.time.Clock() # X coordinate of our sprite x1 = -sprite.get_width() x2 = -sprite.get_width() # Speed in pixel(s) per second speed = 250. frame_num = 0 while True: for event in pygame.event.get(): if event.type == QUIT: exit() screen.blit(background,(0,0)) screen.blit(sprite,(x1,50)) screen.blit(sprite,(x2,250)) time_passed_in_sec = clock.tick(30)/1000. distance_moved = time_passed_in_sec*speed x1+=distance_moved if (frame_num%5)==0: x2 = x2+distance_moved*5. if x1>screen.get_width() or x2>screen.get_width() : x1, x2 = -sprite.get_width(),-sprite.get_width() frame_num+=1 pygame.display.update() When I press and hold the mouse on the window title bar, the first sprite (The one with x value blited = x1) advances, while the second one (The one with x value blited = x2) is stuck in the same old x2 value, which makes me think that the if (frame_num%5)==0: x2 = x2+distance_moved*5. statements are not read while the mouse button is pressed in the window's title. Also when I leave it for about 5 seconds, when I am sure value of x1 should be > screen.get_width() , the sprites are drawn from x1, x2 = -sprite.get_width(),-sprite.get_width() after I release the mouse button. The same happens if I leave the mouse button from ~3 seconds up. It makes me think the if statement is not read as well if x1>screen.get_width() or x2>screen.get_width() : x1, x2 = -sprite.get_width(),-sprite.get_width() Hope you have any ideas why this happens, and if you've experienced same issues in other OSs and on Windows but with python 2.5 and pygame 1.8. Cheers. - Looking for last minute shopping deals? Find them fast with Yahoo! Search.
Re: [pygame] piman's tutorial.Class variable usage.
I thought so, That is what got me so confused. Lenard Lindstrom <[EMAIL PROTECTED]> wrote: Gabriel Hasbun wrote: > Hello, > > The piman's tutorial on sprites: > > http://kai.vm.bytemark.co.uk/~piman/writing/sprite-tutorial.shtml > > class MySprite(pygame.sprite.Sprite): > image = None > > def __init__(self): > pygame.sprite.Sprite.__init__(self) > > if MySprite.image is None: > # This is the first time this class has been instantiated. > # So, load the image for this and all subsequence instances. > MySprite.image = pygame.image.load("image.png") > > self.image = MySprite.image The assignment is unnecessary. MySprite.image is already visible as self.image. > Refers to MySprite.image , as variable common to all instances, I > guess, somewhat a static member in C++, Am I right? > > This is more of a python question, I went through the docs but found > nothing related. > > Thanks in advance. -- Lenard Lindstrom - Never miss a thing. Make Yahoo your homepage.
[pygame] piman's tutorial.Class variable usage.
Hello, The piman's tutorial on sprites: http://kai.vm.bytemark.co.uk/~piman/writing/sprite-tutorial.shtml class MySprite(pygame.sprite.Sprite): image = None def __init__(self): pygame.sprite.Sprite.__init__(self) if MySprite.image is None: # This is the first time this class has been instantiated. # So, load the image for this and all subsequence instances. MySprite.image = pygame.image.load("image.png") self.image = MySprite.image Refers to MySprite.image , as variable common to all instances, I guess, somewhat a static member in C++, Am I right? This is more of a python question, I went through the docs but found nothing related. Thanks in advance. - Never miss a thing. Make Yahoo your homepage.
Re: [pygame] Alternative to pygame.Surface.subsurface
You mean 4 boxes of 25x25 Ronald Lew <[EMAIL PROTECTED]> wrote: .hmmessage P { margin:0px; padding:0px } body.hmmessage { FONT-SIZE: 10pt; FONT-FAMILY:Tahoma } Is there another way to get a portion of an image without having a reference to the parent? I have a 100x100 surface and would like to have 4 surfaces that takes 1/4 of the surface so the end result would have 4 boxes of 50x50. Here's an example - | 1 | 2 | - | 3 | 4 | - Thanks. Ron - Peek-a-boo FREE Tricks & Treats for You! Get 'em! __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: [pygame] Re: Review Pygame book
Good day my name is Gabriel Hasbun-Comandari. I am willing to review your Pygame book with much joy. I also have experience reading lots of programming books wich make me an ideal book reviewer. Thanks for the oportunity. Have a nice day. Will McGugan <[EMAIL PROTECTED]> wrote: Will McGugan wrote: > Hi folks, > > I'm looking for a few people to review my Pygame book, on their blog > and perhaps Amazon or other places. The publisher has offered to give > away a few free copies for this. If you are interested, then please > let me know. I'm getting a lot of responses to this, which is great, but Apress said they have 5 copies to give away. Although I can ask them for more. I will select some people at random tomorrow (I'll write a Python script!) and send email to who ever it selects. If you don't hear from me, then it is nothing personal! Just send me your snail mail address off list to be included in the lotto. Thanks, Will - Pinpoint customers who are looking for what you sell.
Re: [pygame] app killing in Python 2.5 , Pygame 1.7.1 Windows XP Pro Spanish.
I guessed that solution was the only workaround. My other option is to switch from editor? I'll think about that... Thanks. Ian Mallett <[EMAIL PROTECTED]> wrote: If you're using IDLE, running the program with F5 causes this. I have this problem too. If you still like IDLE, you can run python shell and open your program from that. F5 will then work. This can cause problems, (for instance, it annoys me to have that extra window open), so you can save your program and then use a finder window to run the program by double-clicking on the icon. Ian - Don't let your dream ride pass you by.Make it a reality with Yahoo! Autos.
[pygame] app killing in Python 2.5 , Pygame 1.7.1 Windows XP Pro Spanish.
Good day, I had python 2.4 with Pygame 1.7.1 before and all basic applications, including the aliens example included with the source release; and the application killed itself by just clicking on the x in the created Windows XP Window. I use now : Python 2.5 , Pygame 1.7.1 Windows XP Pro Spanish, and the applications do not close properly when clicking on the x on the app window, neither with the quit() or exit() function in the shell. The only way is to close the script, in that case the shell and the app also kill themselves(but by force). Maybe this is a well known issue but I haven´t found any info on it. Solutions to avoid closing and reopening the script, would be greatly apreciated. (All example scripts have this issue) Gabriel Hasbun-Comandari. - Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
Re: [pygame] PyODE
I think that´s because you haven't separeted your graphics code with the physics one. In a pro game, there are 2 updates: the renderer, and the gameplay. The renderer would update every... say, 1/40 of a second, while the gameplay would update every 1/100; that would avoid problems such as colision misperception(Being carefull always, to not exagerate in the acceleration).Ryan Charpentier <[EMAIL PROTECTED]> wrote: Yea well the good news is that either putting those planes in or just zeroing any z axes or a combination seems to have fixed the problems I had with my motion getting messed up.Now however i'm noticing that my boxes get stuck together if the speed is too great. If I accelerate my square really quickly it'll even pass straight through. I've had this happen when I was using rects with pygame, but I assumed ode handled this problem. Or is this normal behaviour? __Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: [pygame] Best 3d library.
I'm having difficulties with closing pygame applications. Windows' Task Manager shows the pygame application as not-responding. This means there's something pygame doesn't realese? the strange thing is that I've tried pygame games on other computers and does not do the same thing. Only on my computer. Any suggestions? I've already tried re-installing pygame-win32-installer. __Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com