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

While loop in pygame

I'm trying to add PS4 input to my python code, so I wanted to make it whenever I'm holding down a button, it prints as long as it held down for, not just the one time. I tried many different variations of while loops but it just spams my console…
ark.pytm
  • 55
  • 1
  • 6
3
votes
3 answers

Pygame used in VS Code with Pygame Snippets

I have installed vs code and added pygame snippets to use pygame library. My big problem is, every time I try to use any key option of pygame, like pygame.KEYDOWN or pygame.QUIT it tells me that QUIT is not a function of pygame. Can someone help…
Anton Wolf
  • 31
  • 1
  • 5
3
votes
1 answer

Python Crash Course: "pygame.error: video system not initialized"

I'm trying to do one of the projects in the Python Crash Course book: Alien Invasion Chapter 12. I just started and for some reason the error: pygame.error: video system not initialized keeps popping up. I'm pretty sure I followed the directions…
Kaitlyn
  • 31
  • 3
3
votes
2 answers

Pygame shows image letters mirrored

Can you please help me understand why pygame shows my image as mirrored? Please see the attached image for more info: I am capturing an image from PiCamera into PiRGBArray stream, then creating a pygame surface module and displaying the image. This…
haykp
  • 435
  • 12
  • 29
3
votes
1 answer

Pygame Collision Bug

I'm quite new to pygame and came across a bug that i just can't fix on my own. I'm trying to program a Flappy Bird game. The Problem is that the collision detection works, but it also messes with my sprites. If i manage to get past the first…
Klappadu
  • 33
  • 4
3
votes
1 answer

Installing pygame for python3 in mac using anaconda

I am trying to install pygame for python 3 and get the error: conda install -c cogsci pygame Solving environment: failed UnsatisfiableError: The following specifications were found to be in conflict: - pygame - xlwt Use "conda info "…
Cranjis
  • 1,590
  • 8
  • 31
  • 64
3
votes
1 answer

A midi file exits but can't load using pygame

I ran the following code: import pygame import os music_file = os.path.join(os.getcwd(), "midi.mid") print(os.path.exists(music_file)) pygame.mixer.music.load(music_file) The output…
user8483278
3
votes
1 answer

How to read a Python Num-Lock Keypress Toggle events?

For a project I am making a program controlled completely by the number pad. A lot relies on buttons on the num-pad being able to be detected as being held down or not; I would set a Boolean to true when it is pressed and false when it is released.…
3
votes
2 answers

Jumping verification code not working using the y-axis (pygame)

When verifying the states of the player (running, jumping, idling), the jumping overrides them because y-axis velocity (the code has vectors included) does not stop although not moving(I think). Jumping verification code: if self.vel.y != 0: …
Tudor Popescu
  • 509
  • 1
  • 5
  • 16
3
votes
2 answers

Installing 64 bit pygame to work with 64 bit kivy

I'm trying to use kivy on my Macbook Pro running 10.12.1. The kivy version I have installed is 64 bit, but the pygame version is 32 bit, so when I run a basic kivy program I get returned this error: pygame - ImportError:…
Boi
  • 73
  • 1
  • 4
3
votes
1 answer

How do I pass a rect into pygame.display.update() to update a specific area of the window?

On the documentation page for pygame.display.update(), it says you can pass a rect into the method to update part of the screen. However, all of the examples I see just pass an existing rect from an image or shape in the program. How can I tell it…
Johnny Dollard
  • 708
  • 3
  • 11
  • 26
3
votes
1 answer

Embed a .wav file in Python with pyinstaller

This is the code I am running: import tkinter from pygame import mixer root =…
3
votes
1 answer

Changing a class so that when the mouse hovers over it, it changes colour - Pygame

import pygame as pg import sys import time # All pygame stuff under here pg.init() # Font definitions backFont = pg.font.SysFont("monospace", 40) titleFont = pg.font.SysFont("garamond", 100) cipherFont = pg.font.SysFont("garamond", 50) buttonFont…
Badger8808
  • 142
  • 1
  • 12
3
votes
3 answers

How would I be able to pan a sound in pygame?

Basically, what I want to accomplish here, is a way to pan the sound while the game is running. I'd like to make the volumes (left and right) change depending on the position of the player. For now I've got a simple code that I thought that would be…
Matheus Fernando
  • 159
  • 3
  • 11
3
votes
1 answer

pygame does not blit unless I call pygame.event.get()

After crashing my head against the monitor for 2 hours I realised that: display.blit(mypic, posx, posy) pygame.display.update() would just not work (i.e. wouldn't blit anything on the screen) unless I call: pygame.event.get() Is this the weirdest…
DaniPaniz
  • 1,058
  • 2
  • 13
  • 24
1 2 3
99
100