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

Play Music And Sound Effects On Top Of Each other (PyGame)

I was wondering if it is possible to play a sound over a different sound using the pygame mixer. So for example I would have quiet background music playing, and then something happens and another sound played on top if it. Currently for the…
Mihkel
  • 689
  • 7
  • 34
3
votes
1 answer

PyOpenGL fragment shader texture sampling

All right, thankfully you guys I have a little deeper understanding how OpenGL in (almost) the modern work. But there is something I can't figure out. How can the fragment shader sampling my texture even if I missing it set up correctly? I think…
tenjohn
  • 197
  • 6
3
votes
2 answers

Why is my Pygame window only displaying for only a few seconds?

I'm new to PyGame (and python in general) and I am just trying to get a window to pop up. That's all I'm after for now. Here's my code: import pygame pygame.init() win = pygame.display.set_mode((600, 600)) pygame.display.set_caption('First…
3
votes
1 answer

How do you overcome the "RuntimeError: Gamma ramp size is reported as 0." without changing the window type when using psychopy?

I have developed a program to play videos in psychopy using a machine with Ubuntu 16.04, a NVIDIA GPU and associated driver. The program works perfectly fine on this machine. The program is rather large but of note, it uses…
3
votes
0 answers

Pygame: Analog trigger initial value is not the neutral trigger position

I'm developing an application that uses pygame to read analog trigger values from an XBox 360-Style gamepad. This application relies on the triggers being initialized to the neutral position, or else it results in undefined behaviour. The problem:…
Prunebutt
  • 31
  • 2
3
votes
1 answer

Pygame Combine Sprites

I am trying to build a game in which combining images (pygame sprites) is an essential tool. I have set up my code such that I can move sprites across x,y with the mouse and rotate them. The sprites are blitted to the display surface and so this…
Didgeridude
  • 123
  • 6
3
votes
3 answers

How to find perfect collision of a moving object into an obstacle

I have two sprites: a robot sprite and an obstacle sprite. I am using mask.overlap to determine if there is an overlap to prevent the robot from moving into the area of the obstacle (it functions as a blocking obstacle). Below is a portion of the…
The4thIceman
  • 3,709
  • 2
  • 29
  • 36
3
votes
3 answers

Imports failing in VScode for pylint when importing pygame

When importing pygame pylint is going crazy: E1101:Module 'pygame' has no 'init' member E1101:Module 'pygame' has no 'QUIT' member I have searched the net and I have found this: "python.linting.pylintArgs": ["--ignored-modules=pygame"] It solves…
Umbrelluck
  • 33
  • 1
  • 6
3
votes
1 answer

Unit testing in Python Pygame for key.get_pressed()

I am new to python coding and need some help with unit testing. I want to test my modules that move the images location in Pygame based on what the user has pressed. Here are my modules: def moveRight(self): self.x = self.x + self.speed def…
dragonfromdreams
  • 129
  • 3
  • 12
3
votes
1 answer

Exception using sprite with pyganim

Good day. I'm trying to write a platformer. Basic actions like creating a map, creating a character, interaction and camera movement are already implemented. There are 4 files: Game.py: Responsible for creating the window, and drawing the rest. Also…
3
votes
1 answer

How to fade in and out a text in Pygame

I know how to show a text on screen, but I don't like the way it appears and disappears. I want it to fade in and out. Changing the RGB is impossible because there is a background image. Can you tell me a code which changes the text's opacity?
jwoojin9
  • 295
  • 1
  • 5
  • 16
3
votes
3 answers

Pygame window freezes on quit

I'm relatively new to python and very new to pygame. I'm trying to use pygame. All programs seem to work fine, except when I try to quit. The window freezes ("application not responding") and I have to force quit it. I'm using OSX, python 3.6, and…
Elliott17
  • 31
  • 1
3
votes
1 answer

Detect mouse event on masked image pygame

I create a clicker game and I have a transparent image (that I set in Mask for Pixel Perfect Collision ) but when I also click on the transparent part, the MOUSEBUTTONDOWN event is detected. Actually, my code in the Player Class is: self.image =…
Djanito
  • 197
  • 1
  • 13
3
votes
1 answer

PyGame, waiting for computer to decide its move

Okay So I am building a tic-tac-toe on pygame in which A player can play against player, computer vs player or computer vs computer. I have already developed the code for a MiniMaxAgent() which takes its input as a 2D matrix and returns the (row,…
97amarnathk
  • 957
  • 2
  • 11
  • 30
3
votes
1 answer

pygame doesn't refresh the screen

I'm actually making a program which recognised two PS3 controllers and blits images of them to screen, along with their controller names and other 'background sprites'. I want the users to click on a controller and a circle or such-like appears over…
thescoop
  • 504
  • 5
  • 20