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
133
votes
15 answers

How to block calls to print?

Is there a way to stop a function from calling print? I am using the pygame.joystick module for a game I am working on. I created a pygame.joystick.Joystick object and in the actual loop of the game call its member function get_button to check for…
dmlicht
  • 2,328
  • 2
  • 15
  • 16
98
votes
13 answers

How to disable welcome message when importing pygame

When I import pygame, it prints the version and welcome message. The message reads: pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html Why is this printed? How can I disable this message?
Aaron
  • 1,109
  • 1
  • 7
  • 4
95
votes
5 answers

Solving "DLL load failed: %1 is not a valid Win32 application." for Pygame

I installed Python 3.1 and the Pygame module for Python 3.1. When I type import python in the console I get the following error: Traceback (most recent call last): File "", line 1, in import pygame File…
Parseltongue
  • 11,157
  • 30
  • 95
  • 160
84
votes
28 answers

Unable to install Pygame using pip

I'm trying to install Pygame. I am running Windows 7 with Enthought Python Distribution. I successfully installed pip, but when I try to install Pygame using pip, I get the following error: "Could not install requirement Pygame because of HTTP…
NumberOneRobot
  • 1,691
  • 6
  • 17
  • 23
77
votes
12 answers

How to get keyboard input in pygame?

I am making a game in pygame 1.9.2. It's a faily simple game in which a ship moves between five columns of bad guys who attack by moving slowly downward. I am attempting to make it so that the ship moves left and right with the left and right arrow…
Dan G.
  • 982
  • 1
  • 8
  • 20
71
votes
25 answers

ImportError: No module named 'pygame'

I have installed python 3.3.2 and pygame 1.9.2a0. Whenever I try to import pygame by typing: import pygame I get following error message : Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32 Type…
user2398618
  • 719
  • 1
  • 5
  • 5
67
votes
7 answers

pygame - How to display text with font & color?

Is there a way I can display text on a pygame window using python? I need to display a bunch of live information that updates and would rather not make an image for each character I need. Can I blit text to the screen?
Max Hudson
  • 9,961
  • 14
  • 57
  • 107
66
votes
4 answers

How to display text in pygame?

I can't figure out to display text in pygame. I know I can't use print like in regular Python IDLE but I don't know how. import pygame, sys from pygame.locals import * BLACK = ( 0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = ( 255, 0,…
user3146817
  • 697
  • 1
  • 5
  • 9
59
votes
4 answers

Draw a transparent rectangles and polygons in pygame

How can I draw a rectangle that has a color with an alpha? I have: windowSurface = pygame.display.set_mode((1000, 750), pygame.DOUBLEBUF) pygame.draw.rect(windowSurface, pygame.Color(255, 255, 255, 128), pygame.Rect(0, 0, 1000, 750)) But I want…
John Stimac
  • 5,335
  • 8
  • 40
  • 60
53
votes
3 answers

How to make a surface with a transparent background in pygame

Can someone give me some example code that creates a surface with a transparent background in pygame?
Paul D. Eden
  • 19,939
  • 18
  • 59
  • 63
53
votes
9 answers

How to suppress console output in Python?

I'm using Pygame/SDL's joystick module to get input from a gamepad. Every time I call its get_hat() method it prints to the console. This is problematic since I use the console to help me debug and now it gets flooded with SDL_JoystickGetHat…
user102430
52
votes
3 answers

Pygame Xbox One Controller

I am trying to run some code that will allow the user to control with an Xbox Controller. I have it working with the Xbox 360 controller using Pygame. Then when I try to use the Xbox one controller and it is able to read the as "connected" but it…
Rjbeckwith
  • 720
  • 8
  • 16
52
votes
4 answers

Difference between pygame.display.update and pygame.display.flip

Just like the title implies, is there any difference? I was using pygame.display.flip and I saw on the Internet that instead of using flip they used pygame.display.update. Which one is faster?
Yubin Lee
  • 814
  • 2
  • 9
  • 26
51
votes
4 answers

Add scrolling to a platformer in pygame

Ok so I included the code for my project below, I'm just doing some experimenting with pygame on making a platformer. I'm trying to figure out how to do some very simple scrolling that follows the player, so the player is the center of the camera…
user1758231
  • 1,001
  • 3
  • 14
  • 20
50
votes
5 answers

How to scale images to screen size in Pygame

I was wondering how I would go about scaling the size of images in pygame projects to the resolution of the screen. For example, envisage the following scenario assuming windowed display mode for the time being; I assume full screen will be the…
Ilmiont
  • 2,032
  • 4
  • 27
  • 44
1
2 3
99 100