Tag Info

Hot answers tagged

22

Mode 7 is a very simple effect. It projects a 2D x/y texture (or tiles) to some floor/ceiling. Old SNES use hardware to do this, but modern computers are so powerful that you can do this realtime (and no need of ASM as you mention). Basic 3D math formula to project a 3D point (x, y, z) to a 2D point (x, y) is : x' = x / z; y' = y / z; When you think ...


13

I've recently implemented an algorithm for a procedural city layout. It's still very much a work in progress, but seems promising to me. Take a look: The algorithm used to create this layout is loosely based on L-Systems. I have a base Element class, that has a rectangle marking its place on map and a method Grow, which creates other Elements inside the ...


10

Imagine the following setup: 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 As a side note, I refer to squares in the matrix like this: (row, column). I've represented mines with "1" and empty spaces with "0". Assume the user clicks on the empty space at (2, 2) (the corner at the top-left is (0, 0)). This is what would happen: ...


10

If you're running in full-screen mode, you can use the pygame.HWSURFACE flag when you initialise the display to tell pygame to try to use a hardware surface. I believe that if a hardware surface can't be used, pygame will silently use a software surface. If you're not using a hardware surface, consider using pygame.display.update(rectangle) rather than ...


9

No. Every year someone makes a new Pygame UI library and then abandons it after a few versions, probably once they realize that writing button layouts is easy but writing a complete UI library is real work. The gui tag on the Pygame site chronicles some of these.


6

Pygame doesn't even have OpenGL bindings; you'd need to use PyOpenGL with it. If your goal is to learn OpenGL, my suggestion would be to use PyOpenGL, with Pygame. The API is closer to actual OpenGL. (I'd also recommend not using NeHe and using the SuperBible instead.) If your goal is to make a quick game, I'd recommend pyglet. It has all the annoying ...


6

Back in January, 2011, I looked at five GUI toolkits for pygame, and tried to get all of them working with Python 3. The five were: Albow, GooeyPy, PGU, pqGUI, and sgc. I didn't succeed with GooeyPy, but I did get the other four to work with Python 3. (I wanted to also try poutine, by Shandy Brown, but I couldn't find it, and I entirely overlooked Ocemp.) ...


6

Let me list some general compared optimizations related to Blitting pixels to a surface(from my experience). 1)Usually palette images(indexed images) when blitted, will under go one extra level of redirection (to get the color).So they will be slow when blitting when compared to true color images. 2)True color pixel data (assume With out Alpha - say24 bit ...


6

There's this GDC talk on procedural building generation from a couple of years ago. It's for creating individual buildings based on a set of templates, but not for creating whole cities (laying out streets and so forth). There isn't any free code to go with it, unfortunately. The system described in the talk is implemented in Unreal although I'm not clear ...


6

Just separate the events from the drawing. The normal method is to redraw all the time, not to wait for something to change. Normally your loop should be like this: while loop: check events: # find routes, block path, whatever update things: # change the state of the game draw() You shouldn't be thinking in terms of drawing one ...


5

Try this in Photoshop: Make a new document. Make a new layer. It will be transparent. Delete the background layer. Your document should be all transparent now. It will look like a checkerboard. Draw the hexagon onto that transparent layer. Save this as a 24-bit PNG with transparency. Now bring that into PyGame. You may need to do some convert_alpha() ...


5

Love offers a similar level of complexity as PyGame, though I'm not sure you will find Lua much easier than Python. If you want to just go with something more direct, look for bindings for SDL (SDL.NET for example) for your favorite language, or even just use it directly in C. Many PyGame APIs are just thin wrappers for SDL functionality.


5

The standard way of doing that is to set up a transform matrix to do the conversion during rendering. For 3D rendering it's the view transform matrix for the camera that does it. Most 2D APIs have a way of specifying a view transform too, as either a 2x3 matrix or as a separate scale, translation and rotation. A quick look at the pygame documentation ...


5

however there is not an awful lot of commercial games using PyGame, and I'd like to invest my time in the best way and ideally to make an extra buck in the future. And who cares? The toolchain is not what makes a game commercial or not, it's not what makes it a AAA title or not. PyGame will not prevent you from realizing your goal of creating a ...


5

Like Tetrad said, it's a really good idea to constrain all of your conversions to a single place on your code. This will ensure consistency across the game. I'm not familiar with Python, but in C# I'd create a small helper class to help me with this. For instance: public static class UnitsConverter { public static float M2P(float meters) { return ...


4

Fear, uncertaincy and doubt are a crippling combination. Just do it. What's the worst that can happen? The python fairy appears in a flash of magic and turns you into a mushroom? Now that I think of it, I remember a scifi tv show where "lower" creatures tried to develop too much too fast (it was an immortality treatment that required killing others to ...


4

In addition to talljosh's answer, I'd like to throw in a few more suggestions: Avoid rotations and scaling wherever you possibly can. Such operations are done purely on the CPU and tend to be very, very slow. If you're doing direct pixel reads/modifications, use the Surface.get_buffer() method and work with that, rather than using the ...


4

A couple of things that I do when debugging games: Use a console to output relevant information. Output debug data directly on top of your game screen. Since you are dealing with a game loop, breakpoints are sometimes quite difficult to use when debugging such things as character movement. Displaying the data you want to verify on screen while you are ...


4

What you're looking for are surfarrays. A simple tutorial on how to get started with them can be found here. Essentially what a surfarray does is directly modify the pixel values of pygame surfaces, and can operate on each of the R, G, and B channels for every pixel "simultaneously," which I put in quotes because I just mean you can change all the pixels ...


4

Here's how I'd approach it: There is always a single open area, represented by a polygon. All other areas are irrelevant. A line starts when you move from the perimeter of the polygon into the polygon's interior. A line stops when you move from the polygon's interior back onto the perimeter. When you stop the line, you have divided the polygon into two ...


4

Presumably you're using a center position and a radius to draw the circle. Just create a rect like this: crect = pygame.Rect(center[0]-radius, center[1]-radius, \ radius*2, radius*2) Then draw the circle like this: pygame.draw.circle(screen, yellow, crect.center, radius)


4

When you use Surface.blit(), a rectangle is returned which you can associate with your label. You could consider keeping a list of these, or a list of tuples of the returned Rect and the text or label callback. In your main loop, you can iterate over this list and call Rect.collidepoint(pygame.mouse.get_pos()) to find out if the mouse is in the current ...


4

Conceptually you've got it, just think of the rectangle as a helper for you to deal with position and collision detection of your image. To implement it you could use: mySprite.image = pygame.transform.rotate(Surface, angle) This will give you a rotated Surface (image), then you can use: mySprite.rect = mySprite.image.get_rect() To give you your new ...


4

The program is trying to convert a unicode wide character format into a standard ascii format. The code you are trying to convert is out of the available ASCII format range. http://www.fileformat.info/info/unicode/char/444/index.htm This is the code you are trying to convert, and ASCII only supports 128 different values, with extended ASCII supporting 256. ...


4

The concept of a surface in this situation is simply describing a texture. To understand this better, you should also understand the rendering process. When rendering anything using modern graphics API's, the end result is always going to be the same, a buffer (texture) of color data that is presented to the screen. How you get to that buffer can vary quite ...


3

As you've written it, your Tank is both your model and your controller. Normally, you either have a view controller and a model controller that talk to each other and their appropriate other part, or a single controller that mediates between the view and model directly. There are a variety of ways to solve this: Accept that Tanks are models and ...


3

The Group class (for which RenderPlain has been a deprecated alias for many years) is more a logical tool than a performance tool. It provides no speed benefit over looping over the sprites yourself. If you are constructing it every frame, it's definitely a net negative. What you should do instead is replace your l_sprites list of sprites with a group ...


3

I want to be a game developer... now what? This is a pretty comprehensive guide to starting out in game development, covering what languages are available, then a list of the most popular tools and libraries, as well as free and commercial book suggestions. Most of what is inside is completely free and provides direct download links. However, it is a ...



Only top voted, non community-wiki answers of a minimum length are eligible