Questions tagged [pygame]
A game development library based on the Python programming language. It wraps SDL for easy use alongside Python.
487 questions
23
votes
2
answers
22k
views
Doing an SNES Mode 7 (affine transform) effect in pygame
Is there such a thing as a short answer on how to do a Mode 7 / mario kart type effect in pygame?
I have googled extensively, all the docs I can come up with are dozens of pages in other languages (...
19
votes
3
answers
9k
views
What is a good algorithm for fractal-based procedural city layout?
Background
I run a minecraft server where I'm going to design a starter city of fairly large scale. I have a series of things, like rule signs and mob cages, I would like to put in buildings there. ...
18
votes
2
answers
6k
views
Why does my sprite player move faster when I move the mouse?
I'm trying to develop a simple game made with Pygame (Python library).
I have a sprite object which's the player and I move it ...
10
votes
6
answers
23k
views
Make pygame's frame rate faster
By profiling my game, I see that the vast majority of the execution time of my hobby game is between the blit and the flip calls. Currently, it's only running at around 13fps. My video card is fairly ...
10
votes
2
answers
985
views
Common pattern to scale "real units" to pixels?
This is a follow-up question to this other one.
I would like to know if there is a common/typical/best pattern to scale my representation of the world (currently 160Kmx160Km) to fit it to the drawing ...
10
votes
1
answer
57k
views
Pygame for python 3.5?
I just got Python 3.5 from this link.
Previously I had Python 3.4 and the Pygame version 1.9.2a0. It worked perfectly. However, my the new Python 3.5 isn't compatible with that version of Pygame that ...
9
votes
2
answers
10k
views
Increase blitting speed?
I'm working on a 2d sidescroller in PyGame. For each map we use one texture (this is the actual size of the texture):
Then we load the image with this code:
...
9
votes
4
answers
3k
views
PyGame QIX clone, filling areas
I'm playing around with PyGame.
Now I'm trying to implement a QIX clone.
I have my game loop, and I can move the player (cursor) on the screen.
In QIX, the movment of the player leaves a trace (...
8
votes
5
answers
7k
views
Are there any good UI widget toolkits for Pygame? [closed]
Are there any good, modern widget toolkits for Pygame? I've looked at PGU, but it's apparently unmaintained.
8
votes
2
answers
31k
views
Locking the frame rate in pygame?
I am having trouble setting up the frame rate in my first game. I know that I can set it up with:
clock = pygame.time.Clock()
clock.tick(60)
but this is not ...
8
votes
4
answers
18k
views
Which language and tools should I choose for creating 2D games? [closed]
Recently I have returned to my childhood hobby (programming games) and found it quite enjoyable. I've been tinkering with PyGame (for Python) for a few months, made a couple of projects for ...
7
votes
8
answers
17k
views
Alternative to pyGame? [closed]
i'm learning something about game programming from a book about "pyGame". pyGame is simple, but... python is a little complex and different from my previous knoweledge about programming.
I know "...
7
votes
2
answers
29k
views
Any way to embed Pygame in webpages?
I have a Pygame game, and I was wondering if there was any way to embed it into a webpage to make it easily playable, or if there is a games website that accepts Pygame games.
EDIT: I am now using ...
7
votes
1
answer
5k
views
Meaning of offset in pygame Mask.overlap methods
I have a situation in which two rectangles collide, and I have to detect how much did they collide so I can redraw the objects in a way that they are only touching each other's edges.
It's a ...
6
votes
1
answer
2k
views
How do I measure the bounds of a string in PyGame?
I am trying to position some text on my screen using pygame, and knowing the size of the string would help.
When using C# and XNA I could use ...
6
votes
2
answers
5k
views
How do I support animation with frames of different sizes?
I'm trying to create a simple top-view 2D rpg, in the style of Zelda and Secret of Mana, using PyGame. I've managed to make the beginnings of a game, with an animated character walking around. However,...
6
votes
2
answers
1k
views
How to write reuseable components for pygame
Is there a recommended way to write reuseable components for pygame? Simple example would be a FPS counter. Should I write a class which has an init, update and draw method and call them from inside a ...
5
votes
3
answers
26k
views
Pygame surface rotation, rect rotation or sprite rotation?
i seem to have a conceptual misunderstanding of the surface and rect object in pygame.
I currently observe these objects this way:
Surface
Just the loaded image
rect
the 'hard' representation of the ...
5
votes
4
answers
21k
views
How can I make the player "look" to the mouse direction? (Pygame / 2D)
Here's my code:
...
5
votes
1
answer
2k
views
How to march tiles together like in Terraria?
I've been trying to get tile marching to work like in Terraria, and I got something to work. I don't think it's actually very good way of doing this, so I'm wondering what would be really the main way ...
5
votes
1
answer
13k
views
How do I get hardware accelerated graphics and shaders in PyGame?
I have created several simple games with PyGame, but until now, I have focused on mechanics rather than graphics. The graphics in my games have been extremely rudimentary, consisting of basic shapes ...
5
votes
2
answers
746
views
Pygame fails on KEYDOWN with Russian keyboard layout
When I press a keyboard button on a keyboard with a Russian layout, my application pygame game crashes with this message:
UnicodeEncodeError: 'ascii' codec can't encode character '\u0444' in ...
5
votes
2
answers
3k
views
Using Python what is the best way to perform heavy tasks in the background?
I'm generating large amounts of procedural map data on the fly, however my game engine doesn't rely on them to render the scene and I'd like to build it on in the background and pop it into the world ...
5
votes
2
answers
2k
views
Simple 2D games - what is faster to render - images or drawing?
I am developing simple 2D environment in Pygame (Python 3.6), however I think this question is general. The environment is moving (player is rendered on the same position and everything else is ...
5
votes
1
answer
1k
views
Separating Sprites from Models with PyGame
So I'm trying to code a game using the Model-View-Controller pattern, and therefore have a need to separate the models for my game objects with their sprite representations. The problem that I'm ...
5
votes
4
answers
18k
views
Fatal Python error: (pygame parachute) Segmentation Fault when using PyGame and cx_Freeze
I'm using cx_Freeze to package my PyGame game. I'm running Ubuntu Linux, so I used the source package. However, I got the following error when I run cxfreeze game.py...
4
votes
5
answers
2k
views
Collision detection performance problem
Using python and pygame I've built a collision detection system according to the instructions in this YouTube tutorial.
This is updated 40 times per second and controls movement and collision ...
4
votes
6
answers
22k
views
RPG movement holding down button
I've been writing a simple top down mini RPG in python.
My problem is that when I move the player I have to repeatedly tap the arrow key. Each time I tap the key the player moves 5 PX in the ...
4
votes
2
answers
2k
views
Why does my turn-based game loop allow the enemy to act repeatedly?
I'm trying to create a turn-based game in pyGame but hit a wall when trying to properly handle the main game loop. So I have something like this:
...
4
votes
1
answer
2k
views
Issue with implemented Minesweeper algorithm
So I'm attempting to learn Python by way of Minesweeper. I've got experience with SDL, so I figured playing around with PyGame sounded like a fun way to learn the syntax of the language.
Anywho, I'm ...
4
votes
2
answers
3k
views
Implementing Story and Quests in RPG
This question in very similar to this question, however I am still confused about how one would implement a story and quests in a finite state automaton RPG.
This is my first game that I am making (...
4
votes
1
answer
8k
views
Pygame Fullsreen Display Issue
Code:
...
4
votes
1
answer
2k
views
Pygame: circular motion with Bresenham's algorithm
I'm trying to figure out a way to move an object in a circular path. I read about Bresenham's circle algorithm, but all the codes available online draw an entire circle.
For my game, I want it so ...
4
votes
2
answers
2k
views
Collision Resolution of Axis-Aligned Bounding Boxes that Change Size
I am developing an action platformer in Python, with Pygame. That said, my question is a general one about collision resolution strategies.
I use an axis-aligned bounding box for the purposes of ...
4
votes
1
answer
3k
views
Pygame freezing on QUIT
I'm having problems with quitting a Pygame application (6502 based computer emulator).
The part regarding exit looks like this:
...
4
votes
3
answers
21k
views
Pygame set_colorkey transparency issues
I'm having a strange issue that I cannot seem to remedy. I am doing some prototyping with Pygame on a desktop running windows and a laptop running OS X. Both are running python v2.7.3 (installed via ...
4
votes
2
answers
17k
views
Pygame surfaces and their Rects
I am trying to understand how pygame surfaces work. I am confused about Rect position of Surface object.
If I try blit surface on screen at some position then Surface is drawn at right position,
but ...
4
votes
1
answer
573
views
Shooting function in pygame w/ 2 Players
I'm trying to program a shooting function in my game using pygame. Process:
Player one will press 'Space' and shoot their type of projectile
Player two would press 'E' and shoot their type of ...
4
votes
2
answers
4k
views
Detecting walls or floors in pygame
I am trying to make bullets bounce of walls, but I can't figure out how to correctly do the collision detection. What I am currently doing is iterating through all the solid blocks and if the bullet ...
4
votes
1
answer
244
views
What is the proper way to maintain the angle of a gun mounted on a car?
So I am making a simple game. I want to put a gun on top of a car. I want to be able to control the angle of the gun. Basically it can go forward all the way so that it is parallel to the ground ...
4
votes
1
answer
288
views
Issues with player movement and character interaction within Pygame
I am working on a small game that deals the main character, which is a cat, and dogs that chase it. The dogs are able to wander around like they are supposed to do, but the cat will only move a small ...
4
votes
2
answers
6k
views
Line Collision In Pygame?
I am working on a game(a platformer) that is physics and momentum based. I want to make it so that the player(a single dot) can bounce off of the lines with correct physics, but to do that, I need to ...
3
votes
4
answers
4k
views
Rotating hitboxes in PyGame?
I'm using pygame.rect.colliderect() to check hitbox collision between sprites in my game, but now that I'm rotating the sprites, I'm realizing I can't do this ...
3
votes
2
answers
19k
views
Pygame Surfaces: which (and when) do I need to .convert()?
I'm a bit puzzled about pygame's Surface.convert():
It's common sense that I should convert a surface after loading an image to it (presumably a jpg/png/etc file),...
3
votes
3
answers
2k
views
Problem in blitting a clean, crisp sprite
I am having a bit of a tooling problem...and I am unsure of how to solve it.
I am currently using PyGame to try and write a simple Minesweeper clone, except my sprites that I made are hexagon based ...
3
votes
3
answers
1k
views
What are the usual tools for importing models and animations?
I'm a total noob with regard to game programming (though not a noob to programming) and I'm using pygame + opengl to do some experiments with a little game I've been thinking of.
I've been trying to ...
3
votes
1
answer
4k
views
What's the difference between Pygame's Sound and Music classes?
What are the key differences between the Sound and Music classes in Pygame? What are the limitations of each? In what situation would one use one or the other? Is there a benefit to using them in ...
3
votes
5
answers
363
views
What can be a game-play element in a game with Shakespeare's plays as the main theme? [closed]
I was thinking of learning about making games, so I thought of an idea about making a game on a play, since the content is already there. I actually found well parsed XMLs of Shakespeare's plays. I ...
3
votes
1
answer
15k
views
Howdo I load a GIF animation in pygame?
How can I load a GIF animation in pygame? With a web search, I found a severely outdated library called GIFImage. I tried it to do it with 2 pictures but I'm getting stuck because I'm a beginner. I ...
3
votes
2
answers
5k
views
How do I detect multiple sprite collisions when there are >10 sprites?
I making a small program to animate the astar algorithm. If you look at the image, there are lots of yellow cars moving around. Those can collide at any moment, could be just one or all of them could ...