Questions tagged [pygame]

Pygame is a set of Python modules designed for writing video games. Use this tag only if you are using the Pygame library and not if you have a question about programming a game in Python in general.

Pygame is a free Python library released under the Lesser General Public License (GNU LGPL) version 2.1 (according to its GitHub page), aimed at creating video games. It's built on top of , is highly portable and runs on nearly every platform and operating system.

References

Documentation

Games using Pygame

19430 questions
3
votes
1 answer

pygame sprite group draw not drawing all sprites

I wrote a program that creates 4 sprites as rectangles that bounce around within the pygame surface. The position is updated in the update procedure for the sprite. When I run the program, only 1-3 of the rectangles appear and which rectangles…
3
votes
1 answer

Unexpected behaviour inside a simple function, can't find why

I'm trying to write a simple game using the Pygame Lib. I coded a very simple behaviour of an "enemy" in order to follow the player. The problem comes when I run the game and the "enemy" object moves faster when it goes to the right direction and…
Pauete Galopa
  • 153
  • 1
  • 1
  • 9
3
votes
1 answer

Pygame fill and blit does not edit screen

I'm getting familiar with Pygame and I want to write a simple game, I already have following code: import sys, pygame pygame.init() size = width, height = 640, 480 speed = [2, 2] black = 0, 0, 0 screen = pygame.display.set_mode(size) ball =…
korjak
  • 123
  • 1
  • 6
3
votes
1 answer

How to make ball bounce off triangle in pygame?

Hello I'm a pretty new programmer and I'm trying to make a ball bounce off a 45 degree triangle. Here is my code: This program makes the ball bounce when it hits the sides of the window, but I don't know how to make it bounce off a triangle. import…
galaxies
  • 63
  • 7
3
votes
2 answers

How to get object to move in a random pattern in pygame?

I have been working on an "Asteroids" remake. However I can not get the objects to move in a random motion. I'm sure this evolves using vectors, however I do not know how to randomly generate a vector for each individual asteroid. I am looking for…
Misha
  • 57
  • 5
3
votes
1 answer

Python 3 non-blocking synchronous behavior

I'm making the classic atari snake game in python3 using Pygame. I want to spawn a subprocess to listen for key strokes so that whenever the player enters a key (UP, DOWN, LEFT, or RIGHT), the subprocess sends the parent process the key. But this…
bli00
  • 2,215
  • 2
  • 19
  • 46
3
votes
1 answer

how to make an animation in pygame

i am trying to make an animation of when my player gets shot to make it seem like he is falling to the ground. i have tried the code below but that doesn't seem to work. it slows down the frames and only shows the last image of my animation is there…
BOBTHEBUILDER
  • 345
  • 1
  • 4
  • 20
3
votes
0 answers

Speed issues with round bodys in pyopengl

I recently build a obj file loader in python 3 using pygame and pyopengl. It works perfectly fine, but when I load a round object it starts running realy slow. I'd like to load multiple complex objects at a decent framerate, but this aproach…
GreenJoFlo
  • 33
  • 7
3
votes
2 answers

How to control individual bullets in pygame

I am trying to create a 2D side shooting game. For bullets, I am using a list so everytime I shoot a bullet gets appended to that list and I "draw" the list on the screen. Whenever the bullet gets out of screen I delete that bullet off the list.…
Leo Feng
  • 59
  • 8
3
votes
1 answer

How could I use a binary list to draw squares in PyGame?

I was wondering if I could draw an image using a list of ones and zeros where a 1 would mean pygame.draw.rect(DISPLAY_SURF,(0,0,0), (0,0,10,10)) and 0 would mean a space. it would look something like this: blockMap = [ [0,1,1,0,0,0,1,1,0], …
John Mobey
  • 79
  • 1
  • 8
3
votes
1 answer

Pygame not loading image

I cannot display the image that is in the same source folder as my project. Also it gives me squiggly lines under (x, y) and it tells me "Shadows name "x" & "y" from outer scope" It shows each one for the "x" and "y" so I just put & Lastly my…
Roketteere
  • 31
  • 6
3
votes
1 answer

How to add non-english characters on a screen title in pygame?

I wanted to make a program with some cyrillic text in it. I made this code that would open up a window, have a title in Russian, and would put some Russian text (meaning Rasputin) on screen.The cyrillic font file supports cyrillic text. import…
3
votes
1 answer

How to measure time in Python?

I want to start my program, measure the time when the program starts and then wait some seconds, push a button (K_RIGHT) and messure the time when I push the button. I am using Pygame to registrate the Keydown. But in my code below it does not…
ddd
  • 167
  • 1
  • 7
3
votes
1 answer

How do I make OpenGL draw do a non-display surface in pygame?

I am trying to make a game that looks like a retro space shooter, where the lines are 3d wireframe. To achieve 3D in Python, I am using pygame for the window and PyOpenGL to render the objects. I want to get OpenGL to render to a surface (not the…
3
votes
1 answer

Pygame: How do I slowly fade and kill a sprite?

When I run this code sprite.spritecollide(a,group,True) the sprite is removed from the screen. But it disappears instantly. How do I apply a fading effect to it? I want it to slowly fade out before it gets removed completely. I have read the…
Nuh Yamin
  • 343
  • 3
  • 15