Tag Info

Hot answers tagged

27

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 ...


15

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 ...


13

To briefly answer your main question first, the main advantages of a procedurally generated game world are that: The world can be huge, much larger than any manually designed game world could possibly be. The world (or at least parts of it) can be regenerated for each game, potentially increasing replay value, since the player will always have something ...


11

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 ...


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: ...


7

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.) ...


7

Advantages of Procedural Generation Can easily scale your maps / designs to truly large sizes, much larger than you could create by hand. By creating a system where chunks of terrain are created on the fly, you can avoid having to write pieces of code to load in chunks from permanent memory. Over the long term, you may be able to discover more viable ...


6

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.


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 ...


6

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 ...


6

It's only randomized the first time because you're only calling the random function one time (when you create the monster object). When you have ma=random.randmint(5, 20) in your class then you are creating that variable with a random amount at that time, but you are not altering it. In order to get a random value every time you need to reset the value every ...


6

In a game, music would be the a way to play background music and sound the way to play sound effects (ej. jumping, firing, etc). Music is a special streaming channel of the Mixer. This means the file is streamed from disk in small chuncks and not loaded at once. Pygame only supports one Music at a time but you can have several Sound objects playing at ...


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

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 ...


5

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 ...


5

Don't know python, but here is a basic arbitrary-language example. You should only have one game loop that updates all other entities. You can determine how much time has passed between each running of the loop and pass that information on to the entities who can use this information. For Example: main() { lastSystemTime = currentSystemTime; while ...


5

If I understand right, your map stores whether something is dirt or air, and the simplest thing would be to have dirt and air tiles. However, to make things look better, you have separate images for air above dirt, dirt above air, dirt left of air, and so on. So you're trying to figure out which image to use, given a tile and its neighbors. Is that right? ...


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

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

Traceback (most recent call last): File "C:\Users\Kylotan\Desktop\test_pg.py", line 31, in <module> if event.type==pg.event.QUIT: AttributeError: 'module' object has no attribute 'QUIT' I added from pygame.locals import * to the top and changed it to just 'QUIT', and it works for me. It's not the clicking that makes the window unresponsive, ...



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