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

Walking animation loop

I've created a dragon that moves towards the player, and while doing so it has an animation where it flies. However, if the player stands at certain angles to the dragon, the flying animation stops until it is either directly above/to the side of…
Goose _
  • 267
  • 1
  • 9
3
votes
1 answer

Moving Camera on the background by Python

I am novice in programming and gamedevelopment. So, I want to create very simple 2D RTS using Python and pygame, and first problem what I collide is camera. I need to create complicated camera under background. It should be able to zoom in / out and…
3
votes
2 answers

How to put an additional image or rectangle on the bottom of Sprite?

I need to add an icon on the bottom of the Sprite worker and then change this icon randomly at each iteration. Please notice that the Sprite worker has 2 states: RUNNING and IDLE. In each of these states, the worker has a specific image. What I need…
ScalaBoy
  • 3,254
  • 13
  • 46
  • 84
3
votes
1 answer

Clicking on image will not work

I am using pygame to create a fully customizable enigma machine in python. One thing I decided to implement early is a help function. When I was testing this, nothing would show up on the console. Here is the code for the image clicking (not all of…
3
votes
1 answer

Clicking buttons in pygame

So I have created a small menu that contains a "Start" button and a "quit" button. Obviously what I want is when I click Start, it starts the game loop, and when I hit quit, it quits the game. I already coded something, but it doesn't work. I think…
RaZiiiGG
  • 203
  • 1
  • 15
3
votes
1 answer

Changing constraint colors in pymunk/pygame

I am working on a project using pymunk and pygame. I am using PivotJoint constraints to attach my bodies together. I would like to make the joints invisible if possible - is there any way to do this? Right now the joints appear purple in pygame and…
dottified
  • 45
  • 4
3
votes
1 answer

How to get all the available methods for a object in Pycharm (for ex. Pygame)

Please have a check on the screenshot, In that here self.image has got the pygame.image.load() method on it. but if i have to access all the available methods to self.image object, Pycharm autosuggestions does not list those. Actually, self.image…
3
votes
1 answer

How do I draw a rectangle at the center of another rectangle in pygame?

I have a rectangle, say, rect1 . I have another rectangle called rect2. I want to blit 'rect2' such that the center of rect2 is same as that of rect1?
Umesh Konduru
  • 361
  • 1
  • 6
  • 19
3
votes
2 answers

Storing unpicklabe pygame.Surface objects in external files

So I've got a problem - I'm writing a game prototype in Python, using Pygame, and I want to save my games. All of the game-related data is in three instances of certain classes, and I want to save these three instances to a file. However, I've…
Saldan
  • 31
  • 2
3
votes
1 answer

collision detection not functioning properly

Im trying to add collision detection on a rock sprite using the following code; import pygame BLACK = (0, 0, 0) WHITE = (255, 255, 255) class Player(pygame.sprite.Sprite): def __init__(self, filename, x, y): super().__init__() …
Goose _
  • 267
  • 1
  • 9
3
votes
1 answer

pygame.time.wait() crashes the program

In a pygame code I wannted to do a title that changes colors. I tried to do a simple title that changes colors, but it not even turned the color to blue (or do it for a second), and the program crash. The code: title_font =…
Python
  • 127
  • 1
  • 14
3
votes
3 answers

Create a button to control background music on and off in pygame

I want to create a button in my game that can control the background music on and off. The first click will stop the background music, and the second click can bring back the music. Now my button can control the music on and off, but I need to click…
SherlockLTS
  • 165
  • 1
  • 7
3
votes
2 answers

Pygame ValueError: invalid rectstyle object

I downloaded a pygame example from here called rabbitone, and followed the corresponding youtube video. So I have studied the code and tried it: import pygame pygame.init() width, height = 640, 480 screen = pygame.display.set_mode((width,…
T Eom
  • 85
  • 1
  • 2
  • 11
3
votes
1 answer

How can I change the resolution of my screen in pygame

I want to create a game in pygame but want it to have pixelated graphics, so instead of resizing a pixelated image, i was hoping to just change the resolution of the pygame screen . screen = pygame.display.set_mode((width, height)) Thanks.
Thomas Ayling
  • 95
  • 2
  • 10
3
votes
2 answers

How to draw a semi-transparent circle in Pygame?

I'm trying to draw a semi-transparent circle in Pygame. Here is my code: import pygame pygame.init() clock = pygame.time.Clock() screen=pygame.display.set_mode((width,height)) while True: msElapsed = clock.tick(100) …
mokazemi
  • 58
  • 1
  • 6