Re: [pygame] Testing if a File Exists
Here[1] you will find full explanation about try\except\finally\else: [1] http://docs.python.org/tut/node10.html 2007/7/9, Richard Jones [EMAIL PROTECTED]: On Mon, 9 Jul 2007, Ian Mallett wrote: So, how exactly do try/except things work? I've seen them in various programs but I dn't know what they really do. I was just about to ask, and this seemed the perfect opportunity... You might find some value in running through the tutorial at http://docs.python.org/tut/. General python programming questions may also be asked on the python mailing list found via http://www.python.org/community/lists/ HTH, Richard -- Flávio Ribeiro [EMAIL PROTECTED] www.flavioribeiro.com (83) 9981.4441
Re: [pygame] multicpu machine for testing some pygame code?
On 08/07/07, René Dudfield [EMAIL PROTECTED] wrote: Hello, if someone has a multicore, or multi cpu system... can you please test some code for me? I'm trying to get some code into pygame to make it work better for multicore machines... but I need to test it some more. You'll need to be able to compile subversion pygame. Cheers, I can I've got a dual core running linux
[pygame] Rendering Text By Line
It's pretty simple to split your string on carriage returns (and/or line feeds), create surfaces for each line of text, and blit those surfaces to the destination surface. I'm doing something like that. I haven't yet gotten word-wrapping to work, but the following out-of-context code does wrapping by line. It keeps track of text sent to a class, and a list of drawing surfaces each containing one character. When it redraws, it figures out where to place each letter so that they're in order without overflowing the allowed drawing area. def AddText(self,text,newline_at_end=True): In progress -- adding smooth word breaks. Adds to a list of drawing surfaces each containing one rendered letter. self.dirty = True text = str(text) ## Ensure format is correct. if newline_at_end: text += \n self.text += text ## Add the text as rendered surfaces, one character at a time. for letter in text: if letter == \n: self.text_letter_surfaces.append(None) else: rendered_letter = self.pen.Write(letter) self.text_letter_surfaces.append(rendered_letter) def RedrawText(self): Draws all current letter surfaces, automatically wrapping text so that text doesn't go outside the allowed area. self.dirty = False self.text_surface.fill((0,0,0,0)) letter_locations = [] LEFT_EDGE = 0 RIGHT_EDGE = self.cursor_rightmost_x NEAR_RIGHT_EDGE = RIGHT_EDGE - 100 cursor = [0,0] for letter in self.text_letter_surfaces: newline = False letter_locations.append((cursor[0],cursor[1])) if letter: ## Ie. if it's not None (a newline): ## Move the cursor for the next letter. cursor[0] += letter.get_width() if cursor[0] RIGHT_EDGE: cursor[0] = LEFT_EDGE newline = True else: ## This is a newline marker. cursor[0] = LEFT_EDGE newline = True if newline: cursor[1] += self.spacing_between_lines if cursor[1] + self.spacing_between_lines self.text_surface.get_height(): ## Move everything up. letter_locations = [[l[0],l[1]-self.spacing_between_lines] for l in letter_locations] ## Move the cursor back up, too. cursor[1] -= self.spacing_between_lines ## Now, actually put the letter surfaces onto my drawing surface. for n in range(len(self.text_letter_surfaces)): if self.text_letter_surfaces[n]: self.text_surface.blit(self.text_letter_surfaces[n],letter_locations[n]) ## Clean up: Delete characters that aren't visible, for next time. top = 0 - self.spacing_between_lines if letter_locations and letter_locations[0][1] = top: n = 0 last = len(letter_locations)-1 while letter_locations[n][1] = top and n last: n += 1 self.text_letter_surfaces = self.text_letter_surfaces[n:] self.text = self.text[n:]
Re: [pygame] Using PyOpenGL for 2D graphics
On Tue, July 10, 2007 8:32 am, Simon Oberhammer wrote: you might also want to checkout soya3d, it handles smooth landscape generation from heightmap, billboards and has several predefined camera-modes. doesn't offer anything to help you with the interface though. http://home.gna.org/oomadness/en/soya3d/tutorials/index.html I looked into Soya. My trouble with that engine was that I wasn't able to import new models into the thing, and that somebody mentioned having trouble getting the thing to run. There's also Panda3D, which is sort of a Python wrapper and actually includes Python in its download version. That one seems to have its own special EXE builder, so you can't just build your application your own way.
Re: [pygame] Using PyOpenGL for 2D graphics
Ian Mallett wrote: 3D wings complete with those little supporting cross-sections on the inside that no one can remember the name of Ribs? -- Greg
Re: [pygame] Using PyOpenGL for 2D graphics
Perhaps. They're those things that look like cross-sections. See attached for what I made them look like. On 7/10/07, Greg Ewing [EMAIL PROTECTED] wrote: Ian Mallett wrote: 3D wings complete with those little supporting cross-sections on the inside that no one can remember the name of Ribs? -- Greg attachment: WingFrame.png
[pygame] Finding the current view settings
Hi, I'd like to know how to get the current view settings. The idea here is to set the screen dimensions for fullscreen based on the display settings already in place before the game starts. Is there a way to do that? Thanks, Ian
[pygame] File Listings
Hi, I would like to list all the files in a directory. What should I do to do that? Ian
Re: [pygame] File Listings
Ian Mallett wrote: Hi, I would like to list all the files in a directory. What should I do to do that? Most file operations can be handled using the os module. In this case, you can use the following: import os directory_listing = os.listdir(path/to/target/directory) Ian -Luke