As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [pygame]

A game development library based on the Python programming language. It wraps SDL for easy use alongside Python.

Filter by
Sorted by
Tagged with
21 votes
2 answers
20k 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 (...
2D_Guy's user avatar
  • 211
19 votes
3 answers
8k 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. ...
Ken's user avatar
  • 860
18 votes
2 answers
5k 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 ...
Drumnbass's user avatar
  • 295
10 votes
6 answers
21k 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 ...
Smashery's user avatar
  • 375
10 votes
2 answers
841 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 ...
mac's user avatar
  • 1,375
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 ...
EdinsonC's user avatar
  • 161
9 votes
2 answers
9k 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: ...
orlp's user avatar
  • 364
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 (...
astropanic's user avatar
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.
Nathon's user avatar
  • 265
8 votes
2 answers
29k 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 ...
DragonDePlatino's user avatar
8 votes
4 answers
17k 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 ...
HamsteR's user avatar
  • 91
7 votes
8 answers
16k 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 "...
stighy's user avatar
  • 867
7 votes
1 answer
4k 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 ...
TheMeaningfulEngineer's user avatar
6 votes
2 answers
26k 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 ...
user19642323's user avatar
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 ...
sec_goat's user avatar
  • 207
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 ...
apparat's user avatar
  • 163
5 votes
3 answers
24k 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 ...
TheMeaningfulEngineer's user avatar
5 votes
4 answers
17k views

How can I make the player "look" to the mouse direction? (Pygame / 2D)

Here's my code: ...
Ericson Willians's user avatar
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 ...
user avatar
5 votes
1 answer
11k 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 ...
orost's user avatar
  • 153
5 votes
2 answers
574 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 ...
Vlad's user avatar
  • 101
5 votes
2 answers
2k 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 ...
salmonmoose's user avatar
5 votes
2 answers
1k 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 ...
matousc's user avatar
  • 159
5 votes
2 answers
4k 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,...
Tor's user avatar
  • 183
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 ...
Ceasar's user avatar
  • 153
5 votes
4 answers
16k 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...
elijaheac's user avatar
  • 199
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 ...
Anonymous Entity's user avatar
4 votes
6 answers
20k 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 ...
Cnorwood7641's user avatar
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: ...
Straightfw's user avatar
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 ...
erik's user avatar
  • 1,368
4 votes
2 answers
2k 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 (...
James's user avatar
  • 183
4 votes
1 answer
7k views

Pygame Fullsreen Display Issue

Code: ...
Flutterguy135's user avatar
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 ...
rcs's user avatar
  • 41
4 votes
2 answers
1k 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 ...
DyingIsFun's user avatar
  • 1,527
4 votes
1 answer
2k 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: ...
Hrvoje's user avatar
  • 211
4 votes
3 answers
18k 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 ...
Nathan Chowning's user avatar
4 votes
2 answers
16k 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 ...
Jaka Novak's user avatar
4 votes
1 answer
513 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 ...
Mercury Platinum's user avatar
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 ...
Serial's user avatar
  • 238
4 votes
1 answer
226 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 ...
Blair's user avatar
  • 41
4 votes
1 answer
239 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 ...
Taylor's user avatar
  • 41
4 votes
2 answers
5k 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 ...
user3339168's user avatar
3 votes
4 answers
3k 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 ...
user3150635's user avatar
3 votes
2 answers
16k 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),...
MestreLion's user avatar
3 votes
3 answers
1k 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 ...
erik's user avatar
  • 1,368
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 ...
malvim's user avatar
  • 193
3 votes
1 answer
3k 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 ...
Southpaw Hare's user avatar
3 votes
5 answers
331 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 ...
tavish's user avatar
  • 33
3 votes
2 answers
4k 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 ...
iCodeLikeImDrunk's user avatar
3 votes
1 answer
17k views

How to remove the old sprites in pygame and show them at a different location

I am trying to show the motion of some basketballs towards walle using the pygae sprites. The idea is that I don't know how to remove the old ones so they won't show. Is there a move method so that it ...
user3009269's user avatar

1
2 3 4 5
10